⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gongju.java

📁 采用基础Java语言实现的一个类似于Windows中的画图程序。
💻 JAVA
字号:
/*
 * 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -