Search in sources :

Example 76 with ComponentEvent

use of java.awt.event.ComponentEvent in project jdk8u_jdk by JetBrains.

the class XDecoratedPeer method handleMoved.

void handleMoved(WindowDimensions dims) {
    Point loc = dims.getLocation();
    AWTAccessor.getComponentAccessor().setLocation((Component) target, loc.x, loc.y);
    postEvent(new ComponentEvent(target, ComponentEvent.COMPONENT_MOVED));
}
Also used : ComponentEvent(java.awt.event.ComponentEvent)

Example 77 with ComponentEvent

use of java.awt.event.ComponentEvent in project jdk8u_jdk by JetBrains.

the class XContentWindow method handleResize.

// NOTE: This method may be called by privileged threads.
//       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
public void handleResize(Rectangle bounds) {
    AWTAccessor.getComponentAccessor().setSize((Component) target, bounds.width, bounds.height);
    postEvent(new ComponentEvent(target, ComponentEvent.COMPONENT_RESIZED));
}
Also used : ComponentEvent(java.awt.event.ComponentEvent)

Example 78 with ComponentEvent

use of java.awt.event.ComponentEvent in project jdk8u_jdk by JetBrains.

the class WLightweightFramePeer method hide.

@Override
public void hide() {
    super.hide();
    postEvent(new ComponentEvent((Component) getTarget(), ComponentEvent.COMPONENT_HIDDEN));
}
Also used : ComponentEvent(java.awt.event.ComponentEvent) Component(java.awt.Component)

Example 79 with ComponentEvent

use of java.awt.event.ComponentEvent in project jdk8u_jdk by JetBrains.

the class WLightweightFramePeer method reshape.

@Override
public void reshape(int x, int y, int width, int height) {
    super.reshape(x, y, width, height);
    postEvent(new ComponentEvent((Component) getTarget(), ComponentEvent.COMPONENT_MOVED));
    postEvent(new ComponentEvent((Component) getTarget(), ComponentEvent.COMPONENT_RESIZED));
}
Also used : ComponentEvent(java.awt.event.ComponentEvent) Component(java.awt.Component)

Example 80 with ComponentEvent

use of java.awt.event.ComponentEvent in project jdk8u_jdk by JetBrains.

the class DeviceIdentificationTest method main.

public static void main(String[] args) {
    final Frame f = new Frame("DeviceIdentificationTest");
    f.addWindowListener(new WindowAdapter() {

        public void windowClosing(WindowEvent e) {
            f.dispose();
        }
    });
    f.addComponentListener(new ComponentAdapter() {

        public void componentMoved(ComponentEvent e) {
            f.setTitle("Currently on: " + f.getGraphicsConfiguration().getDevice());
        }
    });
    Panel p = new Panel();
    Button b = new Button("Print Current Devices");
    b.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            GraphicsDevice[] gds = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
            int i = 0;
            System.err.println("--- Devices: ---");
            for (GraphicsDevice gd : gds) {
                System.err.println("Device[" + i + "]= " + gd);
                System.err.println("  bounds = " + gd.getDefaultConfiguration().getBounds());
                i++;
            }
            System.err.println("-------------------");
        }
    });
    p.add(b);
    b = new Button("Print My Device");
    b.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            GraphicsConfiguration gc = f.getGraphicsConfiguration();
            GraphicsDevice gd = gc.getDevice();
            System.err.println("--- My Device ---");
            System.err.println("Device  = " + gd);
            System.err.println(" bounds = " + gd.getDefaultConfiguration().getBounds());
        }
    });
    p.add(b);
    b = new Button("Create FS Frame on my Device");
    b.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            GraphicsConfiguration gc = f.getGraphicsConfiguration();
            final GraphicsDevice gd = gc.getDevice();
            System.err.println("--- Creating FS Frame on Device ---");
            System.err.println("Device  = " + gd);
            System.err.println(" bounds = " + gd.getDefaultConfiguration().getBounds());
            final Frame fsf = new Frame("Full-screen Frame on dev" + gd, gc) {

                public void paint(Graphics g) {
                    g.setColor(Color.green);
                    g.fillRect(0, 0, getWidth(), getHeight());
                    g.setColor(Color.red);
                    g.drawString("FS on device: " + gd, 200, 200);
                    g.drawString("Click to exit Full-screen.", 200, 250);
                }
            };
            fsf.setUndecorated(true);
            fsf.addMouseListener(new MouseAdapter() {

                public void mouseClicked(MouseEvent e) {
                    gd.setFullScreenWindow(null);
                    fsf.dispose();
                }
            });
            gd.setFullScreenWindow(fsf);
        }
    });
    p.add(b);
    f.add("North", p);
    p = new Panel();
    b = new Button("Test Passed");
    b.setBackground(Color.green);
    b.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            System.out.println("Test Passed");
            f.dispose();
        }
    });
    p.add(b);
    b = new Button("Test Failed");
    b.setBackground(Color.red);
    b.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            System.out.println("Test FAILED");
            f.dispose();
            throw new RuntimeException("Test FAILED");
        }
    });
    p.add(b);
    f.add("South", p);
    f.pack();
    f.setVisible(true);
}
Also used : Frame(java.awt.Frame) MouseEvent(java.awt.event.MouseEvent) ActionEvent(java.awt.event.ActionEvent) MouseAdapter(java.awt.event.MouseAdapter) WindowAdapter(java.awt.event.WindowAdapter) GraphicsConfiguration(java.awt.GraphicsConfiguration) Graphics(java.awt.Graphics) Panel(java.awt.Panel) GraphicsDevice(java.awt.GraphicsDevice) ActionListener(java.awt.event.ActionListener) Button(java.awt.Button) WindowEvent(java.awt.event.WindowEvent) ComponentEvent(java.awt.event.ComponentEvent) ComponentAdapter(java.awt.event.ComponentAdapter)

Aggregations

ComponentEvent (java.awt.event.ComponentEvent)120 ComponentAdapter (java.awt.event.ComponentAdapter)97 Dimension (java.awt.Dimension)22 Component (java.awt.Component)18 ActionEvent (java.awt.event.ActionEvent)18 JPanel (javax.swing.JPanel)18 JScrollPane (javax.swing.JScrollPane)16 ComponentListener (java.awt.event.ComponentListener)15 MouseEvent (java.awt.event.MouseEvent)15 JButton (javax.swing.JButton)15 JLabel (javax.swing.JLabel)15 BorderLayout (java.awt.BorderLayout)12 Point (java.awt.Point)12 WindowAdapter (java.awt.event.WindowAdapter)12 WindowEvent (java.awt.event.WindowEvent)12 MouseAdapter (java.awt.event.MouseAdapter)11 ActionListener (java.awt.event.ActionListener)10 JTable (javax.swing.JTable)9 AbstractAction (javax.swing.AbstractAction)8 BoxLayout (javax.swing.BoxLayout)8