import java.awt.*; import java.awt.event.*; import javax.swing.*; public class CheckBoxDemoStress extends JPanel implements ItemListener { JCheckBox aButton; JCheckBox bButton; JCheckBox cButton; StringBuffer choices; JLabel pictureLabel; public CheckBoxDemoStress() { super(new BorderLayout()); JPanel checkPanel = new JPanel(); //Create the check boxes. for (int i=0; i<1000; i++) { aButton = new JCheckBox((new Integer(i)).toString()); //aButton.setMnemonic(KeyEvent.VK_A); aButton.setSelected(true); aButton.addItemListener(this); checkPanel.add(aButton); } add(checkPanel, BorderLayout.LINE_START); setBorder(BorderFactory.createEmptyBorder(20,20,20,20)); } /** Listens to the check boxes. */ public void itemStateChanged(ItemEvent e) { } /** * Create the GUI and show it. For thread safety, * this method should be invoked from the * event-dispatching thread. */ private static void createAndShowGUI() { //Create and set up the window. JFrame frame = new JFrame("CheckBoxDemoStress"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Create and set up the content pane. JComponent newContentPane = new CheckBoxDemoStress(); newContentPane.setOpaque(true); //content panes must be opaque frame.setContentPane(newContentPane); //Display the window. frame.pack(); frame.setVisible(true); } public static void main(String[] args) { //Schedule a job for the event-dispatching thread: //creating and showing this application's GUI. javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { createAndShowGUI(); } }); } }