Search in sources :

Example 96 with BorderLayout

use of java.awt.BorderLayout in project jdk8u_jdk by JetBrains.

the class ExtraMouseClick method init.

public void init() {
    this.setLayout(new BorderLayout());
    frame.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent e) {
            System.out.println("MousePressed");
            pressed = true;
        }

        public void mouseReleased(MouseEvent e) {
            System.out.println("MouseReleased");
            released = true;
        }

        public void mouseClicked(MouseEvent e) {
            System.out.println("MouseClicked!!!!");
            clicked = true;
        }
    });
    frame.addMouseMotionListener(new MouseMotionAdapter() {

        public void mouseDragged(MouseEvent e) {
            System.out.println("MouseDragged--" + e);
            dragged = true;
        }

        public void mouseMoved(MouseEvent e) {
        }
    });
}
Also used : MouseMotionAdapter(java.awt.event.MouseMotionAdapter) MouseEvent(java.awt.event.MouseEvent) BorderLayout(java.awt.BorderLayout) MouseAdapter(java.awt.event.MouseAdapter)

Example 97 with BorderLayout

use of java.awt.BorderLayout in project jdk8u_jdk by JetBrains.

the class TexturePaintPrintingTest method doTest.

private static void doTest(Runnable action) {
    String description = " A TexturePaint graphics will be shown on console.\n" + " The same graphics is sent to printer.\n" + " Please verify if TexturePaint shading is printed.\n" + " If none is printed, press FAIL else press PASS";
    final JDialog dialog = new JDialog();
    dialog.setTitle("printSelectionTest");
    JTextArea textArea = new JTextArea(description);
    textArea.setEditable(false);
    final JButton testButton = new JButton("Start Test");
    final JButton passButton = new JButton("PASS");
    passButton.setEnabled(false);
    passButton.addActionListener((e) -> {
        f.dispose();
        dialog.dispose();
        pass();
    });
    final JButton failButton = new JButton("FAIL");
    failButton.setEnabled(false);
    failButton.addActionListener((e) -> {
        f.dispose();
        dialog.dispose();
        fail();
    });
    testButton.addActionListener((e) -> {
        testButton.setEnabled(false);
        action.run();
        passButton.setEnabled(true);
        failButton.setEnabled(true);
    });
    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.add(textArea, BorderLayout.CENTER);
    JPanel buttonPanel = new JPanel(new FlowLayout());
    buttonPanel.add(testButton);
    buttonPanel.add(passButton);
    buttonPanel.add(failButton);
    mainPanel.add(buttonPanel, BorderLayout.SOUTH);
    dialog.add(mainPanel);
    dialog.pack();
    dialog.setVisible(true);
    dialog.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            System.out.println("main dialog closing");
            testGeneratedInterrupt = false;
            mainThread.interrupt();
        }
    });
}
Also used : JPanel(javax.swing.JPanel) JTextArea(javax.swing.JTextArea) FlowLayout(java.awt.FlowLayout) BorderLayout(java.awt.BorderLayout) WindowEvent(java.awt.event.WindowEvent) JButton(javax.swing.JButton) WindowAdapter(java.awt.event.WindowAdapter) JDialog(javax.swing.JDialog)

Example 98 with BorderLayout

use of java.awt.BorderLayout in project jdk8u_jdk by JetBrains.

the class GifTransparencyTest method show.

public void show() {
    JPanel p = new JPanel(new BorderLayout()) {

        public void paintComponent(Graphics g) {
            g.setColor(Color.blue);
            g.fillRect(0, 0, getWidth(), getHeight());
        }
    };
    p.add(new ImageComponent(src), BorderLayout.WEST);
    if (dst != null) {
        p.add(new ImageComponent(dst), BorderLayout.EAST);
    }
    JFrame f = new JFrame("Transparency");
    f.add(p);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.pack();
    f.setVisible(true);
}
Also used : Graphics(java.awt.Graphics) JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) JFrame(javax.swing.JFrame)

Example 99 with BorderLayout

use of java.awt.BorderLayout in project jdk8u_jdk by JetBrains.

the class TSFrame method createGui.

public static Frame createGui(final boolean useSwing, final boolean useShape, final boolean useTransl, final boolean useNonOpaque, final float factor) {
    Frame frame;
    done = false;
    if (useNonOpaque) {
        if (useSwing) {
            frame = new NonOpaqueJFrame();
        //                frame = new NonOpaqueJAppletFrame(gc);
        } else {
            frame = new NonOpaqueFrame();
        }
        animateComponent(frame);
    } else if (useSwing) {
        frame = new JFrame("Swing Frame");
        JComponent p = new JButton("Swing!");
        p.setPreferredSize(new Dimension(200, 100));
        frame.add("North", p);
        p = new MyJPanel();
        animateComponent(p);
        frame.add("Center", p);
    } else {
        frame = new Frame("AWT Frame") {

            public void paint(Graphics g) {
                g.setColor(Color.red);
                g.fillRect(0, 0, 100, 100);
            }
        };
        frame.setLayout(new BorderLayout());
        Canvas c = new MyCanvas();
        frame.add("North", c);
        animateComponent(c);
        c = new MyCanvas();
        frame.add("Center", c);
        animateComponent(c);
        c = new MyCanvas();
        frame.add("South", c);
        animateComponent(c);
    }
    final Frame finalFrame = frame;
    frame.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            finalFrame.dispose();
            done = true;
        }
    });
    frame.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            finalFrame.dispose();
            done = true;
        }
    });
    frame.setPreferredSize(new Dimension(800, 600));
    if (useShape) {
        frame.setUndecorated(true);
    }
    frame.setLocation(450, 10);
    frame.pack();
    GraphicsDevice gd = frame.getGraphicsConfiguration().getDevice();
    if (useShape) {
        if (gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSPARENT)) {
            System.out.println("applying PERPIXEL_TRANSPARENT");
            frame.setShape(new Ellipse2D.Double(0, 0, frame.getWidth(), frame.getHeight() / 3));
            frame.setTitle("PERPIXEL_TRANSPARENT");
        } else {
            System.out.println("Passed: PERPIXEL_TRANSPARENT unsupported");
        }
    }
    if (useTransl) {
        if (gd.isWindowTranslucencySupported(WindowTranslucency.TRANSLUCENT)) {
            System.out.println("applying TRANSLUCENT");
            frame.setOpacity(factor);
            frame.setTitle("TRANSLUCENT");
        } else {
            System.out.println("Passed: TRANSLUCENT unsupported");
        }
    }
    if (useNonOpaque) {
        if (gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSLUCENT)) {
            System.out.println("applying PERPIXEL_TRANSLUCENT");
            frame.setBackground(new Color(0, 0, 0, 0));
            frame.setTitle("PERPIXEL_TRANSLUCENT");
        } else {
            System.out.println("Passed: PERPIXEL_TRANSLUCENT unsupported");
        }
    }
    frame.setVisible(true);
    return frame;
}
Also used : JFrame(javax.swing.JFrame) Frame(java.awt.Frame) MouseEvent(java.awt.event.MouseEvent) Canvas(java.awt.Canvas) Color(java.awt.Color) JButton(javax.swing.JButton) JComponent(javax.swing.JComponent) MouseAdapter(java.awt.event.MouseAdapter) WindowAdapter(java.awt.event.WindowAdapter) Dimension(java.awt.Dimension) Ellipse2D(java.awt.geom.Ellipse2D) Graphics(java.awt.Graphics) GraphicsDevice(java.awt.GraphicsDevice) BorderLayout(java.awt.BorderLayout) JFrame(javax.swing.JFrame) WindowEvent(java.awt.event.WindowEvent)

Example 100 with BorderLayout

use of java.awt.BorderLayout in project jdk8u_jdk by JetBrains.

the class java_awt_BorderLayout method getAnotherObject.

@Override
protected BorderLayout getAnotherObject() {
    BorderLayout layout = getObject();
    update(layout, BorderLayout.CENTER);
    return layout;
}
Also used : BorderLayout(java.awt.BorderLayout)

Aggregations

BorderLayout (java.awt.BorderLayout)761 JPanel (javax.swing.JPanel)514 JLabel (javax.swing.JLabel)238 JScrollPane (javax.swing.JScrollPane)191 Dimension (java.awt.Dimension)155 JButton (javax.swing.JButton)134 FlowLayout (java.awt.FlowLayout)90 ActionEvent (java.awt.event.ActionEvent)88 JTextField (javax.swing.JTextField)85 EmptyBorder (javax.swing.border.EmptyBorder)73 ActionListener (java.awt.event.ActionListener)70 JCheckBox (javax.swing.JCheckBox)69 Insets (java.awt.Insets)64 BoxLayout (javax.swing.BoxLayout)62 GridBagConstraints (java.awt.GridBagConstraints)57 GridBagLayout (java.awt.GridBagLayout)57 JTable (javax.swing.JTable)57 JTextArea (javax.swing.JTextArea)52 GridLayout (java.awt.GridLayout)49 Box (javax.swing.Box)45