home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-12-14 | 2.2 KB | 82 lines |
-
- import javax.swing.*;
- import java.awt.event.*;
- import java.awt.*;
-
- public class IconButtons extends JPanel
- {
- public IconButtons()
- {
- ImageIcon buttonImage = new ImageIcon("images/T1.gif");
- ImageIcon pressImage = new ImageIcon("images/T2.gif");
- ImageIcon selImage = new ImageIcon("images/T3.gif");
- ImageIcon disabledImage = new ImageIcon("images/T4.gif");
- ImageIcon rolloverImage = new ImageIcon("images/T4.gif");
- ImageIcon selrolloverImage = new ImageIcon("images/T3.gif");
- ImageIcon DOJImage = new ImageIcon("images/T2.gif");
- ImageIcon shapeImage = new ImageIcon("images/T1.gif");
- AbstractButton button1;
- AbstractButton button2;
- AbstractButton button3;
- Font font1;
-
- font1 = new Font("Serif", Font.PLAIN,16);
- setFont(font1);
- setDoubleBuffered(true);
-
- setLayout(new GridLayout(1,3,5,5));
-
- button1 = new JButton();
- button1.setIcon(buttonImage);
- button1.setPressedIcon(pressImage);
- button1.setRolloverIcon(rolloverImage);
- add(button1);
-
- button2 = new JButton();
- button2.setIcon(buttonImage);
- button2.setDisabledIcon(disabledImage);
- button2.setEnabled(false);
- add(button2);
-
- button3 = new JToggleButton();
- button3.setIcon(DOJImage);
- button3.setSelectedIcon(shapeImage);
- button3.setRolloverIcon(shapeImage);
- button3.setRolloverSelectedIcon(selrolloverImage);
- add(button3);
-
- }//constructor
-
- public static void main(String s[])
- {
- JFrame f = new JFrame("Icon Buttons ");
- IconButtons panel = new IconButtons();
-
- f.setForeground(Color.black);
- f.setBackground(Color.lightGray);
- f.getContentPane().add(panel, "Center");
-
- f.setSize(200,70);
- f.setVisible(true);
- f.addWindowListener(new WindowCloser());
-
-
- }//main
- }//IconButtons
-
-
- class WindowCloser extends WindowAdapter
- {
- public void windowClosing(WindowEvent e)
- {
- Window win = e.getWindow();
- win.setVisible(false);
- win.dispose();
- System.exit(0);
- }//windowClosing
- }//class WindowCloser
-
-
-
-
-