Java Swing学习笔记3_JButton

JButton

 
JButton bt3 = new JButton(); 
bt3.setText("right"); 
//设置文本相对于图标的垂直位置 
bt3.setVerticalTextPosition(AbstractButton.CENTER); 
//设置文本相对于图标的水平位置 
bt3.setHorizontalTextPosition(AbstractButton.RIGHT); 
bt3.setMnemonic(KeyEvent.VK_R); 
bt3.setIcon(new ImageIcon("D:\\Study\\J2SE\\SwingTutorial\\src\\hode\\swing\\text\\right.gif")); 
bt3.setVisible(true); 
// Default Button Set 
frame.getRootPane().setDefaultButton(bt2); 



JCheckBox
JCheckBox jcb1 = new JCheckBox();
jcb1.setText("checkbox");
jcb1.setVisible(true);
jcb1.addItemListener(new ItemListener(){
     @Override
   public void itemStateChanged(ItemEvent e) {
	// dosomething
   }
   });


JRadioButton
// like jbutton
JRadioButton jrb = new JRadioButton();

你可能感兴趣的:(java,swing,J2SE)