Search in sources :

Example 91 with JButton

use of javax.swing.JButton in project jdk8u_jdk by JetBrains.

the class AnimatedIcon method main.

public static void main(final String[] args) throws Exception {
    SwingUtilities.invokeAndWait(() -> {
        final BufferedImage bi = new BufferedImage(1, 1, TYPE_INT_RGB);
        final ImageIcon icon = new ImageIcon(bi);
        final JButton button = new JButton(icon);
        // Default icon is set => imageUpdate should return true for it
        isAnimated(bi, button);
        button.getModel().setPressed(true);
        button.getModel().setArmed(true);
        isAnimated(bi, button);
        button.getModel().setPressed(false);
        button.getModel().setArmed(false);
        button.getModel().setSelected(true);
        isAnimated(bi, button);
        button.getModel().setSelected(false);
        button.getModel().setRollover(true);
        button.setRolloverEnabled(true);
        isAnimated(bi, button);
        button.getModel().setSelected(true);
        isAnimated(bi, button);
        // Default icon is not set => imageUpdate should return true for
        // other icons if any
        button.setIcon(null);
        button.setPressedIcon(icon);
        button.getModel().setPressed(true);
        button.getModel().setArmed(true);
        isAnimated(bi, button);
    });
}
Also used : ImageIcon(javax.swing.ImageIcon) JButton(javax.swing.JButton) BufferedImage(java.awt.image.BufferedImage)

Example 92 with JButton

use of javax.swing.JButton in project jdk8u_jdk by JetBrains.

the class Test4461329 method main.

public static void main(String[] args) {
    JColorChooser chooser = new JColorChooser();
    if (null == chooser.getPreviewPanel()) {
        throw new Error("Failed: getPreviewPanel() returned null");
    }
    // NON-NLS: simple label
    JButton button = new JButton("Color");
    chooser.setPreviewPanel(button);
    if (button != chooser.getPreviewPanel()) {
        throw new Error("Failed in setPreviewPanel()");
    }
}
Also used : JButton(javax.swing.JButton) JColorChooser(javax.swing.JColorChooser)

Example 93 with JButton

use of javax.swing.JButton in project jdk8u_jdk by JetBrains.

the class TooMuchWheelRotationEventsTest method createUI.

private static void createUI() {
    final JFrame mainFrame = new JFrame("Trackpad scrolling test");
    GridBagLayout layout = new GridBagLayout();
    JPanel mainControlPanel = new JPanel(layout);
    JPanel resultButtonPanel = new JPanel(layout);
    GridBagConstraints gbc = new GridBagConstraints();
    JPanel testPanel = createTestPanel();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    mainControlPanel.add(testPanel, gbc);
    JTextArea instructionTextArea = new JTextArea();
    instructionTextArea.setText(INSTRUCTIONS);
    instructionTextArea.setEditable(false);
    instructionTextArea.setBackground(Color.white);
    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    mainControlPanel.add(instructionTextArea, gbc);
    JButton passButton = new JButton("Pass");
    passButton.setActionCommand("Pass");
    passButton.addActionListener((ActionEvent e) -> {
        testResult = true;
        mainFrame.dispose();
        countDownLatch.countDown();
    });
    JButton failButton = new JButton("Fail");
    failButton.setActionCommand("Fail");
    failButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            mainFrame.dispose();
            countDownLatch.countDown();
        }
    });
    gbc.gridx = 0;
    gbc.gridy = 0;
    resultButtonPanel.add(passButton, gbc);
    gbc.gridx = 1;
    gbc.gridy = 0;
    resultButtonPanel.add(failButton, gbc);
    gbc.gridx = 0;
    gbc.gridy = 2;
    mainControlPanel.add(resultButtonPanel, gbc);
    mainFrame.add(mainControlPanel);
    mainFrame.pack();
    mainFrame.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            mainFrame.dispose();
            countDownLatch.countDown();
        }
    });
    mainFrame.setVisible(true);
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) JTextArea(javax.swing.JTextArea) GridBagLayout(java.awt.GridBagLayout) ActionListener(java.awt.event.ActionListener) JFrame(javax.swing.JFrame) ActionEvent(java.awt.event.ActionEvent) WindowEvent(java.awt.event.WindowEvent) JButton(javax.swing.JButton) WindowAdapter(java.awt.event.WindowAdapter)

Example 94 with JButton

use of javax.swing.JButton in project jdk8u_jdk by JetBrains.

the class Test4247606 method init.

public void init() {
    // NON-NLS: the button text
    JButton button = new JButton("Button");
    button.setBorder(BorderFactory.createLineBorder(Color.red, 1));
    // NON-NLS: the panel title
    TitledBorder border = new TitledBorder("Bordered Pane");
    border.setTitlePosition(TitledBorder.BELOW_BOTTOM);
    JPanel panel = create(button, border);
    panel.setBackground(Color.green);
    getContentPane().add(create(panel, BorderFactory.createEmptyBorder(10, 10, 10, 10)));
}
Also used : JPanel(javax.swing.JPanel) JButton(javax.swing.JButton) TitledBorder(javax.swing.border.TitledBorder)

Example 95 with JButton

use of javax.swing.JButton in project jdk8u_jdk by JetBrains.

the class LWDispatcherMemoryLeakTest method init.

public static void init() throws Throwable {
    SwingUtilities.invokeAndWait(new Runnable() {

        @Override
        public void run() {
            frame = new JFrame();
            frame.setLayout(new FlowLayout());
            button = new WeakReference<JButton>(new JButton("Text"));
            p = new WeakReference<JPanel>(new JPanel(new FlowLayout()));
            p.get().add(button.get());
            frame.add(p.get());
            frame.setBounds(500, 400, 200, 200);
            frame.setVisible(true);
        }
    });
    Util.waitTillShown(button.get());
    Util.clickOnComp(button.get(), new Robot());
    SwingUtilities.invokeAndWait(new Runnable() {

        @Override
        public void run() {
            frame.remove(p.get());
        }
    });
    Util.waitForIdle(null);
    assertGC();
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) JFrame(javax.swing.JFrame) WeakReference(java.lang.ref.WeakReference) JButton(javax.swing.JButton) Robot(java.awt.Robot)

Aggregations

JButton (javax.swing.JButton)923 JPanel (javax.swing.JPanel)408 ActionEvent (java.awt.event.ActionEvent)389 ActionListener (java.awt.event.ActionListener)317 JLabel (javax.swing.JLabel)278 JScrollPane (javax.swing.JScrollPane)166 BoxLayout (javax.swing.BoxLayout)158 FlowLayout (java.awt.FlowLayout)142 BorderLayout (java.awt.BorderLayout)138 Dimension (java.awt.Dimension)138 Insets (java.awt.Insets)114 JTextField (javax.swing.JTextField)114 GridBagLayout (java.awt.GridBagLayout)110 JCheckBox (javax.swing.JCheckBox)103 GridBagConstraints (java.awt.GridBagConstraints)95 ImageIcon (javax.swing.ImageIcon)95 JTable (javax.swing.JTable)67 JDialog (javax.swing.JDialog)65 JComboBox (javax.swing.JComboBox)56 JTextArea (javax.swing.JTextArea)56