Java使用JToggleButton – JAVA編程語言程序開發技術文章

[java]
package com.han; 
 
import java.awt.Container; 
import java.awt.FlowLayout; 
 
import javax.swing.JFrame; 
import javax.swing.JToggleButton; 
 
/**
 * 使用JToggleButton
 * @author HAN
 *
 */ 
public class JToggleButton_1 extends JFrame { 
 
    /**
     * 
     */ 
    private static final long serialVersionUID = -4145861896939853662L; 
 
    public JToggleButton_1() { 
        // TODO Auto-generated constructor stub  
        JToggleButton toggleButton = new JToggleButton("JToggleButton"); 
        Container container = getContentPane(); 
        container.setLayout(new FlowLayout()); 
        container.add(toggleButton); 
    } 
 
    /**
     * @param args
     */ 
    public static void main(String[] args) { 
        // TODO Auto-generated method stub  
        JToggleButton_1 frame = new JToggleButton_1(); 
        frame.setTitle("JToggleButton"); 
        frame.setVisible(true); 
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
        frame.setBounds(0, 0, 300, 100); 
    } 
 

package com.han;

import java.awt.Container;
import java.awt.FlowLayout;

import javax.swing.JFrame;
import javax.swing.JToggleButton;

/**
 * 使用JToggleButton
 * @author HAN
 *
 */
public class JToggleButton_1 extends JFrame {

 /**
  *   www.aiwalls.com
  */
 private static final long serialVersionUID = -4145861896939853662L;

 public JToggleButton_1() {
  // TODO Auto-generated constructor stub
  JToggleButton toggleButton = new JToggleButton("JToggleButton");
  Container container = getContentPane();
  container.setLayout(new FlowLayout());
  container.add(toggleButton);
 }

 /**
  * @param args
  */
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  JToggleButton_1 frame = new JToggleButton_1();
  frame.setTitle("JToggleButton");
  frame.setVisible(true);
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.setBounds(0, 0, 300, 100);
 }

}

 作者:Gaowen_HAN
 

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *