java里jbutton,jlabel,jlist叫什么
1个回答
展开全部
package components;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.net.URL;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
public class JButtonTest extends JPanel implements ActionListener {
private static final long serialVersionUID = 1L;
JButton button1,button2,button3;
public JButtonTest() {
//创建button上的图标
ImageIcon imageIcon1 = createImage("images/right.gif");
ImageIcon imageIcon2 = createImage("images/middle.gif");
ImageIcon imageIcon3 = createImage("images/left.gif");
//创建Button,并设置Button的图标
button1 = new JButton("中间按钮不可用",imageIcon1);
//设置Button的文本位置
button1.setVerticalTextPosition(JButton.CENTER);
button1.setHorizontalTextPosition(JButton.LEADING);
//设置Button的快捷键
button1.setMnemonic(KeyEvent.VK_D);
//设置Button的反馈消息,消息处理者通过这个标记来辨别是哪个按钮被点击
button1.setActionCommand("disable");
//为Button添加监听者
button1.addActionListener(this);
//设置Button的提示信息
button1.setToolTipText("点击此按键,此按键和中间按键变为不可用,右边按键变为可用");
//将Button添加到panel中
add(button1);
}
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.net.URL;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
public class JButtonTest extends JPanel implements ActionListener {
private static final long serialVersionUID = 1L;
JButton button1,button2,button3;
public JButtonTest() {
//创建button上的图标
ImageIcon imageIcon1 = createImage("images/right.gif");
ImageIcon imageIcon2 = createImage("images/middle.gif");
ImageIcon imageIcon3 = createImage("images/left.gif");
//创建Button,并设置Button的图标
button1 = new JButton("中间按钮不可用",imageIcon1);
//设置Button的文本位置
button1.setVerticalTextPosition(JButton.CENTER);
button1.setHorizontalTextPosition(JButton.LEADING);
//设置Button的快捷键
button1.setMnemonic(KeyEvent.VK_D);
//设置Button的反馈消息,消息处理者通过这个标记来辨别是哪个按钮被点击
button1.setActionCommand("disable");
//为Button添加监听者
button1.addActionListener(this);
//设置Button的提示信息
button1.setToolTipText("点击此按键,此按键和中间按键变为不可用,右边按键变为可用");
//将Button添加到panel中
add(button1);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询