use of java.awt.Container in project jdk8u_jdk by JetBrains.
the class LinearGradientPrintingTest method createUI.
public static void createUI() {
f = new JFrame("LinearGradient Printing Test");
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
final LinearGradientPrintingTest gpt = new LinearGradientPrintingTest();
Container c = f.getContentPane();
c.add(BorderLayout.CENTER, gpt);
final JButton print = new JButton("Print");
print.addActionListener(new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
PrinterJob job = PrinterJob.getPrinterJob();
job.setPrintable(gpt);
final boolean doPrint = job.printDialog();
if (doPrint) {
try {
job.print();
} catch (PrinterException ex) {
throw new RuntimeException(ex);
}
}
}
});
c.add(print, BorderLayout.SOUTH);
f.pack();
f.setVisible(true);
}
use of java.awt.Container in project jdk8u_jdk by JetBrains.
the class RadialGradientPrintingTest method createUI.
public static void createUI() {
f = new JFrame("RadialGradient Printing Test");
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
final RadialGradientPrintingTest gpt = new RadialGradientPrintingTest();
Container c = f.getContentPane();
c.add(BorderLayout.CENTER, gpt);
final JButton print = new JButton("Print");
print.addActionListener(new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
PrinterJob job = PrinterJob.getPrinterJob();
job.setPrintable(gpt);
final boolean doPrint = job.printDialog();
if (doPrint) {
try {
job.print();
} catch (PrinterException ex) {
throw new RuntimeException(ex);
}
}
}
});
c.add(print, BorderLayout.SOUTH);
f.pack();
f.setVisible(true);
}
use of java.awt.Container in project jdk8u_jdk by JetBrains.
the class TexturePaintPrintingTest method printTexture.
private static void printTexture() {
f = new JFrame("Texture Printing Test");
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
final TexturePaintPrintingTest gpt = new TexturePaintPrintingTest();
Container c = f.getContentPane();
c.add(BorderLayout.CENTER, gpt);
final JButton print = new JButton("Print");
print.addActionListener(new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
PrinterJob job = PrinterJob.getPrinterJob();
job.setPrintable(gpt);
final boolean doPrint = job.printDialog();
if (doPrint) {
try {
job.print();
} catch (PrinterException ex) {
throw new RuntimeException(ex);
}
}
}
});
c.add(print, BorderLayout.SOUTH);
f.pack();
f.setVisible(true);
}
use of java.awt.Container in project jdk8u_jdk by JetBrains.
the class AddNoLeak method main.
public static void main(String[] args) {
System.setProperty("java.awt.headless", "true");
Container cont = new Container();
Image img = cont.createImage(new DummyImageSource());
for (int i = 0; i < 15000; i++) {
img.getWidth(new ImageObserver() {
public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height) {
return false;
}
});
if (i % 100 == 0) {
System.gc();
}
}
}
use of java.awt.Container in project jna by java-native-access.
the class WindowUtilsTest method xtestReveal.
public void xtestReveal() throws Exception {
final int SIZE = 200;
System.setProperty("sun.java2d.noddraw", "true");
GraphicsConfiguration gconfig = WindowUtils.getAlphaCompatibleGraphicsConfiguration();
Window w;
Container content;
if (true) {
JFrame frame = new JFrame(getName(), gconfig);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
content = frame.getContentPane();
w = frame;
} else {
Frame frame = JOptionPane.getRootFrame();
JWindow window = new JWindow(frame, gconfig);
content = window.getContentPane();
w = window;
}
final Window f = w;
WindowUtils.setWindowTransparent(f, true);
content.add(new JButton("Quit") {
private static final long serialVersionUID = 1L;
{
addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
}
}, BorderLayout.SOUTH);
content.add(new JComponent() {
private static final long serialVersionUID = 1L;
public Dimension getPreferredSize() {
return new Dimension(SIZE, SIZE);
}
protected void paintComponent(Graphics graphics) {
Graphics2D g = (Graphics2D) graphics.create();
g.setComposite(AlphaComposite.Clear);
g.fillRect(0, 0, SIZE, SIZE);
g.dispose();
g = (Graphics2D) graphics.create();
Color[] colors = { new Color(0, 0, 0), new Color(0, 0, 0, 128), new Color(128, 128, 128), new Color(128, 128, 128, 128), new Color(255, 255, 255), new Color(255, 255, 255, 128) };
for (int i = 0; i < colors.length; i++) {
g.setColor(colors[i]);
g.fillRect((SIZE * i) / colors.length, 0, (SIZE + colors.length - 1) / colors.length, SIZE);
}
g.setColor(Color.red);
g.drawRect(0, 0, SIZE - 1, SIZE - 1);
g.dispose();
SwingUtilities.getWindowAncestor(this).toFront();
}
});
f.pack();
f.addMouseListener(handler);
f.addMouseMotionListener(handler);
f.setLocation(100, 100);
f.setVisible(true);
while (f.isVisible()) {
Thread.sleep(1000);
//f.repaint();
}
}
Aggregations