?? component.java
字號:
package ding;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
/**
* <p>Title: 門電路畫圖器</p>
* <p>Description: www.1shu.net</p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: EyeSome</p>
* @author ES
* @version 1.0
*/
public class component
extends JFrame
implements ActionListener {
mainFrame mFrame;
ImageIcon icon[];
JButton[] buttons;
Font tmpF = new Font("Dialog", Font.PLAIN, 12);
int i;
String mess;
public component() {
super();
}
public component(mainFrame frame) {
super("請選擇元件");
setSize(715, 505);
mFrame = frame;
GridLayout gr = new GridLayout( (int) (mFrame.yjtNo / 2), 4);
//System.out.println(Math.sqrt(mFrame.yjtNo)+" --- ");
//setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel pane = new JPanel();
pane.setLayout(gr);
JScrollPane scroll = new JScrollPane(pane,
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.
HORIZONTAL_SCROLLBAR_AS_NEEDED);
icon = new ImageIcon[mFrame.yjtNo];
buttons = new JButton[mFrame.yjtNo];
//System.out.println("picPath:"+mFrame.yjt[0].picPath+"yjtNo:"+mFrame.yjtNo);
for (i = 0; i < mFrame.yjtNo; i++) {
icon[i] = new ImageIcon(mFrame.yjt[i].picPath);
//System.out.println("picPath:" + mFrame.yjt[i].picPath);
buttons[i] = new JButton(frame.yjt[i].des,icon[i]);
buttons[i].setFont(tmpF);
mess = "按鈕 " + String.valueOf(i) + "被點擊";
buttons[i].addActionListener(
new ActionListener() {
String m2;
int j;
//yuanjian yjtmp;
public void actionPerformed(ActionEvent e) {
Object src = e.getSource();
for (j = 0; j < mFrame.yjtNo; j++) {
if (src == buttons[j]) {
//yjtmp = mFrame.yjt[j].getValue();
mFrame.yjc[mFrame.yjcNo] = mFrame.yjt[j].getValue();
mFrame.yjcNo++;
/*元件統計加一*/
mFrame.yjt[j].number++;
//System.out.println(mFrame.yjt[j].des+" :"+mFrame.yjt[j].number);
//m2 = "按鈕 "+String.valueOf(j)+"被點擊";
break;
}
}
//System.out.println(src);
//JOptionPane.showMessageDialog(null,m2);
dispose(); // 關閉窗口
}
}
);
pane.add(buttons[i]);
}
setContentPane(scroll);
//show();
}
public void actionPerformed(ActionEvent evt) {
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -