- 分享
- 0
- 人气
- 0
- 主题
- 0
- 帖子
- 84
- UID
- 192730
- 积分
- 69
- 阅读权限
- 12
- 注册时间
- 2009-1-15
- 最后登录
- 2010-9-14
- 在线时间
- 30 小时
|
回复 #4 Super-Tomato 的帖子
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class AssignmentGUI extends Frame implements ActionListener, ItemListener{
private JTabbedPane tab;
private Panel pentry=new Panel();
private Panel pdisplay=new Panel();
private Panel psearch=new Panel();
private Panel pbutton=new Panel();
private Panel pbutton2=new Panel();
private Panel pbutton3=new Panel();
private Panel ptype=new Panel();
private int counter=0;
private int counter2=0;
private Label lblblank,lblblank2,lblblank3;
private Label lbltitle,lblid,lblname,lblpriority,lbltype,lbldescribtion,lblcompanyname,lbltypecompany;
private Label lbltitled,lblidd,lblnamed,lblpriorityd,lbltyped,lbldescribtiond,lblcompanynamed,lbltypecompanyd;
private Label lblidr,lblnamer,lblpriorityr,lbltyper,lbldescribtionr,lblcompanynamer,lbltypecompanyr;
private Label lbltitle1,lblsearch,lblid1,lblname1,lblpriority1,lbltype1,lbldescribtion1,lblcompanyname1,lbltypecompany1;
private Label lblid2,lblname2,lblpriority2,lbltype2,lbldescribtion2,lblcompanyname2,lbltypecompany2;
private TextField txtid,txtname,txtdesc,txtcompany;
private TextField txtsearch;
JComboBox [] t=new JComboBox[4];
private Button btnreset,btnsave,btnnext,btnprevious,btndisplay,btnsearch;
String choice;
char [] tempt=new char[4];
private boolean flag,flag2=false,flag3=false;
productmethod [] pm =new productmethod[4];
public AssignmentGUI(){
super("Product Record");
tab=new JTabbedPane();
Color blue=new Color(50,150,255);
Color red=new Color(255,150,150);
Color yellow=new Color(255,200,100);
Color gray=new Color(230,230,230);
for(int i=0;i<4;i++){
t=new JComboBox();
t.addItem("Accounting");
t.addItem("Anti-Virus");
t.addItem("Reader");
t.addItem("Customise");
t.setSelectedItem("Accounting");
choice=t.getSelectedItem().toString();
tempt=choice.charAt(0);
t.addItemListener(this);
}
lbltitle=new Label("Product Requirement Record");
lblid=new Label(counter+1+". Product ID: ");
lblname=new Label("Product Name: ");
lblpriority=new Label("Priority: ");
lbltype=new Label("Type of Product: ");
lbldescribtion=new Label("Product Describtion: ");
lblcompanyname=new Label("Company Name: ");
lbltypecompany=new Label("Type Of Company: ");
lbltitled=new Label("Product Requirement Result");
lblidd=new Label(counter2+1+". Product ID: ");
lblnamed=new Label("Product Name: ");
lblpriorityd=new Label("Priority: ");
lbltyped=new Label("Type of Product: ");
lbldescribtiond=new Label("Product Describtion: ");
lblcompanynamed=new Label("Company Name: ");
lbltypecompanyd=new Label("Type Of Company: ");
lblidr=new Label();
lblnamer=new Label();
lblpriorityr=new Label();
lbltyper=new Label();
lbldescribtionr=new Label();
lblcompanynamer=new Label();
lbltypecompanyr=new Label();
lbltitle1=new Label("Product Record Search");
lblsearch=new Label("Search ID: ");
lblid1=new Label("Product ID: ");
lblname1=new Label("Product Name: ");
lblpriority1=new Label("Priority: ");
lbltype1=new Label("Type of Product: ");
lbldescribtion1=new Label("Product Describtion: ");
lblcompanyname1=new Label("Company Name: ");
lbltypecompany1=new Label("Type Of Company: ");
lblid2=new Label();
lblname2=new Label();
lblpriority2=new Label();
lbltype2=new Label();
lbldescribtion2=new Label();
lblcompanyname2=new Label();
lbltypecompany2=new Label();
txtid=new TextField("",100);
txtname=new TextField("",100);
txtdesc=new TextField("",100);
txtcompany=new TextField("",100);
txtsearch=new TextField("",100);
btnreset=new Button("Reset");
btnreset.setBackground(blue);
btnreset.setForeground(Color.white);
btnreset.addActionListener(this);
btnsave=new Button("Save");
btnsave.setBackground(blue);
btnsave.setForeground(Color.white);
btnsave.addActionListener(this);
btnnext=new Button("Next");
btnnext.setBackground(red);
btnnext.setForeground(Color.white);
btnnext.addActionListener(this);
btnnext.setEnabled(false);
btnprevious=new Button("Previous");
btnprevious.setBackground(red);
btnprevious.setForeground(Color.white);
btnprevious.addActionListener(this);
btnprevious.setEnabled(false);
btndisplay=new Button("Display");
btnprevious.setBackground(red);
btnprevious.setForeground(Color.white);
btnprevious.addActionListener(this);
btnprevious.setEnabled(false);
btnsearch=new Button("Search");
btnprevious.setBackground(yellow);
btnprevious.setForeground(Color.white);
btnprevious.addActionListener(this);
btnprevious.setEnabled(false);
for(int j=0;j<pm.length;j++)
pm[j]=new productmethod();
pentry.setLayout(new GridLayout(13,2,0,2));
lbltitle.setBackground(blue);
lbltitle.setForeground(Color.white);
lblblank.setBackground(blue);
pentry.add(lbltitle);
pentry.add(lblblank);
pentry.add(lblid);
pentry.add(txtid);
pentry.add(lblname);
pentry.add(txtname);
pentry.add(lblpriority);
//radio button priority
pentry.add(lbltype);
//add the JComboBox Component
ptype.setLayout(new GridLayout(0,4,0,2));
ptype.add(t[0]);
ptype.add(new Label());
ptype.add(new Label());
ptype.add(new Label());
pentry.add(ptype);
pentry.add(lbldescribtion);
pentry.add(txtdesc);
pentry.add(lblcompanyname);
pentry.add(txtcompany);
pentry.add(lbltypecompany);
//radio button of company type
//group the button
pbutton.setLayout(new GridLayout(0,3,2,2));
pbutton.add(new Label());
pbutton.add(btnreset);
pbutton.add(btnsave);
pentry.add(pbutton);
//panel display
lbltitled.setBackground(red);
lbltitled.setForeground(Color.white);
lblblank2.setBackground(red);
pdisplay.setLayout(new GridLayout(15,2,0,2));
pdisplay.add(lbltitled);
pdisplay.add(lblblank2);
pdisplay.add(lblidd);
pdisplay.add(lblidr);
pdisplay.add(lblnamed);
pdisplay.add(lblnamer);
pdisplay.add(lblpriorityd);
pdisplay.add(lblpriorityr);
//priority radio panel
pdisplay.add(lbltyped);
pdisplay.add(lbltyper);
pdisplay.add(lbldescribtiond);
pdisplay.add(lbldescribtionr);
pdisplay.add(lblcompanynamed);
pdisplay.add(lblcompanynamer);
pdisplay.add(lbltypecompanyd);
pdisplay.add(lbltypecompanyr);
//type radio button
pbutton2.setLayout(new GridLayout(0,3,2,2));
pbutton2.add(btndisplay);
pbutton2.add(btnprevious);
pbutton2.add(btnnext);
pdisplay.add(pbutton2);
lbltitle1.setBackground(yellow);
lbltitle1.setForeground(Color.white);
lblblank3.setBackground(yellow);
psearch.setLayout(new GridLayout(15,2,0,2));
psearch.add(lbltitle1);
psearch.add(lblblank3);
psearch.add(lblsearch);
pbutton3.setLayout(new GridLayout(0,2,2,2));
pbutton3.add(txtsearch);
pbutton3.add(btnsearch);
psearch.add(pbutton3);
psearch.add(lblid1);
psearch.add(lblid2);
psearch.add(lblname1);
psearch.add(lblname2);
psearch.add(lblpriority1);
psearch.add(lblpriority2);
psearch.add(lbltype1);
psearch.add(lbltype2);
psearch.add(lbldescribtion1);
psearch.add(lbldescribtion2);
psearch.add(lblcompanyname1);
psearch.add(lblcompanyname2);
psearch.add(lblcompanyname1);
psearch.add(lblcompanyname2);
psearch.add(lbltypecompany1);
psearch.add(lbltypecompany2);
tab.addTab("Record",null,pentry,"Entry Record");
tab.addTab("Display",null,pdisplay,"Display Record");
tab.addTab("Search",null,psearch,"Search Record");
tab.setBackgroundAt(0,blue);
tab.setBackgroundAt(1,red);
tab.setBackgroundAt(2,yellow);
tab.setBackground(gray);
add(tab);
setSize(800,600);
setVisible(true);
} |
|