Java使用JToggleButton


Java使用JToggleButton:

  1. package com.han;  
  2.   
  3. import java.awt.Container;  
  4. import java.awt.FlowLayout;  
  5.   
  6. import javax.swing.JFrame;  
  7. import javax.swing.JToggleButton;  
  8.   
  9. /** 
  10.  * 使用JToggleButton 
  11.  * @author HAN 
  12.  * 
  13.  */  
  14. public class JToggleButton_1 extends JFrame {  
  15.   
  16.     /** 
  17.      *  
  18.      */  
  19.     private static final long serialVersionUID = -4145861896939853662L;  
  20.   
  21.     public JToggleButton_1() {  
  22.         // TODO Auto-generated constructor stub   
  23.         JToggleButton toggleButton = new JToggleButton("JToggleButton");  
  24.         Container container = getContentPane();  
  25.         container.setLayout(new FlowLayout());  
  26.         container.add(toggleButton);  
  27.     }  
  28.   
  29.     /** 
  30.      * @param args 
  31.      */  
  32.     public static void main(String[] args) {  
  33.         // TODO Auto-generated method stub   
  34.         JToggleButton_1 frame = new JToggleButton_1();  
  35.         frame.setTitle("JToggleButton");  
  36.         frame.setVisible(true);  
  37.         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
  38.         frame.setBounds(00300100);  
  39.     }  
  40.   
  41. }  

相关内容