java界面怎么写的( 三 )


8. java如何写这个图形界面 //自己在微调一下坐标吧..import java.awt.BorderLayout;import java.awt.GridLayout;import java.awt.Rectangle;import java.io.Serializable;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JPanel;public class SwingTest extends JFrame implements Serializable{ private JPanel jp1,jp2,jp3; private JLabel ab1; private But[] list=But.values(); private static final long serialVersionUID = 1L; SwingTest(){ this.setTitle("系统首页"); this.setBounds(300, 300, 280, 200); this.setResizable(false); init(); this.setDefaultCloseOperation(EXIT_ON_CLOSE); this.setVisible(true); } private void init() { jp1=new JPanel(); jp1.add(new JLabel("欢迎你来到图书馆租借系统")); jp2=new JPanel(null); ab1=new JLabel("请选择服务项目"); ab1.setBounds(new Rectangle(0, 0, 220, 25)); jp2.add(ab1); jp3=new JPanel(new GridLayout(6,1)); jp3.setBounds(80, 20, 120, 120); for (int i = 0; i jp3.add(new JButton(list[i].toString())); } jp2.add(jp3); this.add(jp1,BorderLayout.NORTH); this.add(jp2,BorderLayout.CENTER); } public static void main(String[] args) { new SwingTest(); } enum But{ 馆藏查询 , 节约查询 , 欠费查询 , 借书登记 , 还书登记 , 退出系统; }} 。
9. 如何用JAVA编程编写一个界面程序(急求 我下面写了一个 , 初始账号和密码是 nihao 5201314 你可以改或设置
import java.awt.*;
import java.awt.event.*;
class MyDow extends Frame implements ActionListener{
private Label lName,lPassword;
private TextField tName,tPassword;
private Button login,rest,exitout;
private Label login_clew;
private int count=0;
private String myName="nihao";
private String myPassword="5201314";
public void setMyNP(String n,String p){
myName=n;
myPassword=p;
}
public MyDow(String str){
super(str);
}
public void init(){
setLayout(null);
setSize(400,300);
setVisible(true);
setResizable(false);
lName=new Label("姓名");
lName.setBounds(50, 70, 60, 30);add(lName);
lPassword=new Label("密码");
lPassword.setBounds(50, 120, 60, 30);add(lPassword);
tName=new TextField("");
tName.setBounds(110, 70, 200, 30);add(tName);
tPassword=new TextField("");
tPassword.setBounds(110, 120, 200, 30);add(tPassword);
login=new Button("登录");
login.setBounds(90, 200, 60, 30);add(login);
rest=new Button("重输");
rest.setBounds(170, 200, 60, 30);add(rest);
exitout=new Button("退出");
exitout.setBounds(250,200,60,30);add(exitout);
login_clew=new Label("");
login.addActionListener(this);
rest.addActionListener(this);
exitout.addActionListener(this);
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==login){
【java界面怎么写的】if(count