import javax.swing.*; import java.awt.*; import java.awt.event.*; public class JSliderFrame extends StandardJFrame { JLabel top; JSliderPanel myJSliderPanel; MyJButton myButton; MyJButton close; ButtonHandler listener; //inner class for actionPerformed JPanel holdclose; //hold the close button public JSliderFrame(MyJButton mjb) { myButton = mjb; getContentPane().setLayout(new BorderLayout()); setSize(500,650); /*******************************/ setVisible(false); setTitle("U.S. Graph Information"); setResizable(false); myJSliderPanel = new JSliderPanel(); getContentPane().add(myJSliderPanel, BorderLayout.CENTER); close = new MyJButton(); close.setText("Close"); /* The button location will be controlled by FlowLayout, the JPanel default. */ close.setPreferredSize(new Dimension(80,40)); close.setVisible(true); holdclose = new JPanel(); holdclose.setBackground(Color.BLACK); holdclose.setOpaque(true); holdclose.add(close); getContentPane().add(holdclose, BorderLayout.SOUTH); listener = new ButtonHandler(); close.addActionListener(listener); top = new JLabel("Presidents and States Information!", JLabel.CENTER); top.setBackground(Color.BLACK); top.setForeground(Color.WHITE); top.setOpaque(true); top.setFont(new Font("Arial", Font.BOLD+Font.ITALIC, 18)); getContentPane().add(top, BorderLayout.NORTH); }// end of constructor //inner class private class ButtonHandler implements ActionListener { public void actionPerformed(ActionEvent ae) { /* Reset the sliders to zero. */ myJSliderPanel.j1.setValue(0); myJSliderPanel.j2.setValue(0); JSliderFrame.this.setVisible(false);//access instance of outer class myButton.setEnabled(true); } }// end of ButtonHandler inner class public void windowClosing(WindowEvent we) { myJSliderPanel.j1.setValue(0); myJSliderPanel.j2.setValue(0); JSliderFrame.this.setVisible(false);//access instance of outer class myButton.setEnabled(true); } }//end of class