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);
});
}
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()");
}
}
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);
}
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)));
}
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();
}
Aggregations