gongju.java
来自「采用基础Java语言实现的一个类似于Windows中的画图程序。」· Java 代码 · 共 67 行
JAVA
67 行
/*
* gongju.java
*
* Created on 2007年6月23日, 下午6:15
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package huaban;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JToolBar;
public class gongju extends JToolBar implements ActionListener {
JButton[] button = new JButton[5];
ShapePanel panel1;
public gongju(ShapePanel pan) {
panel1 = pan;
button[0] = new JButton(new ImageIcon("zhixian1.GIF"));
button[1] = new JButton(new ImageIcon("quxian1.gif"));
button[2] = new JButton(new ImageIcon("tuoyuan.GIF"));
button[3] = new JButton(new ImageIcon("juxing1.GIF"));
button[4] = new JButton(new ImageIcon("zifu.GIF"));
this.setLayout(new GridLayout(12,1));
this.add(button[0]);
this.add(button[1]);
this.add(button[2]);
this.add(button[3]);
this.add(button[4]);
this.setRollover(true);
button[0].addActionListener(this);
button[1].addActionListener(this);
button[2].addActionListener(this);
button[3].addActionListener(this);
button[4].addActionListener(this);
}
public void actionPerformed(ActionEvent e) {
if(e.getSource() == button[0]){
panel1.set(1);
}
if(e.getSource() == button[1]){
panel1.set(2);
}
if(e.getSource() == button[2]){
panel1.set(3);
}
if(e.getSource() == button[3]){
panel1.set(4);
}
if(e.getSource() == button[4]){
panel1.sr = JOptionPane.showInputDialog(this,"输入你想显示的字符");
panel1.set(5);
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?