Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 31537 Details for
Bug 120279
OSX: Black bar shown instead of Frame title bar
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
Test case showing JFrame.printAll() problem.
SwingImageCaptureTest.java (text/plain), 2.38 KB, created by
Jeff Myers
on 2005-12-11 18:12:33 EST
(
hide
)
Description:
Test case showing JFrame.printAll() problem.
Filename:
MIME Type:
Creator:
Jeff Myers
Created:
2005-12-11 18:12:33 EST
Size:
2.38 KB
patch
obsolete
>import java.awt.BorderLayout; >import java.awt.Color; >import java.awt.FlowLayout; >import java.awt.Graphics; >import java.awt.Image; >import java.awt.event.ActionEvent; >import java.awt.event.ActionListener; >import java.awt.image.BufferedImage; >import java.awt.image.ColorModel; > >import javax.swing.ImageIcon; >import javax.swing.JButton; >import javax.swing.JFrame; >import javax.swing.JLabel; > > >public class SwingImageCaptureTest { > > private Image capturedImage = null; > private JLabel imageLabel = null; > > private JFrame childWindow = null; > > public SwingImageCaptureTest() > { > JFrame mainWindow = new JFrame("Host"); > mainWindow.setSize(500,500); > mainWindow.setLocation(50,50); > mainWindow.getContentPane().setLayout(new BorderLayout()); > JButton printButton = new JButton("Print child window"); > mainWindow.getContentPane().add(printButton, BorderLayout.SOUTH); > imageLabel = new JLabel(); > imageLabel.setHorizontalAlignment(JLabel.CENTER); > imageLabel.setVerticalAlignment(JLabel.CENTER); > mainWindow.getContentPane().add(imageLabel, BorderLayout.CENTER); > mainWindow.getContentPane().setBackground(Color.BLUE); > > mainWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); > > childWindow = new JFrame("Child Window"); > childWindow.setSize(250,250); > childWindow.setLocation(500,500); > childWindow.getContentPane().setLayout(new FlowLayout()); > childWindow.getContentPane().add(new JButton("Button")); > > childWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); > > printButton.addActionListener(new ActionListener() { > public void actionPerformed(ActionEvent arg0) { > ColorModel cm = childWindow.getColorModel(); > > capturedImage = new BufferedImage(cm, cm.createCompatibleWritableRaster(childWindow.getWidth(), childWindow.getHeight()), cm.isAlphaPremultiplied(), null); > if (capturedImage != null) > { > imageLabel.setText(null); > Graphics graphics = capturedImage.getGraphics(); > graphics.setColor(Color.BLACK); > graphics.fillRect(0, 0, childWindow.getWidth(), childWindow.getHeight()); > childWindow.printAll(graphics); > imageLabel.setIcon(new ImageIcon(capturedImage)); > } > else > { > imageLabel.setIcon(null); > imageLabel.setText("Error capturing window"); > } > } > }); > > mainWindow.setVisible(true); > childWindow.setVisible(true); > } > > /** > * @param args > */ > public static void main(String[] args) { > new SwingImageCaptureTest(); > } > >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 120279
:
31536
| 31537 |
33036