java界面怎么写的( 二 )


panel.add(ok,c);
cn.add(panel);
}
public void actionPerformed(ActionEvent e)
{
Object source = e.getSource();
if(source == ok)
{
String username = this.name.getText();
String password = this.password.getText();
String message = username + " "+password;
try
{
byte[] b = message.getBytes();
FileOutputStream fos = new FileOutputStream("login.txt");
fos.write(b,0,b.length);
this.dispose();
}catch(Exception ex)
{
}
}
}
public static void main(String args[])
{
new login().show();
}
}
5. 用Java怎么写一个简单完整的登陆界面 package com.oristand.cn;
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
public class QQlogin extends JFrame{
public QQlogin()
{
JFrame jf= new JFrame("QQ登陆界面");
jf.setLayout(new GridLayout(5,1,5,5));
JPanel jp=new JPanel();
JLabel jl=new JLabel("欢迎登陆");
jp.add(jl);
jf.add(jp);
JPanel jp1=new JPanel();
JLabel jl1=new JLabel("用户名");
JTextField jt=new JTextField(10);
jp1.add(jl1);
jp1.add(jt);
jf.add(jp1);
JPanel jp2=new JPanel();
JLabel jl2=new JLabel("密码");
JTextField jt1=new JPasswordField(10);
jp2.add(jl2);
jp2.add(jt1);
jf.add(jp2);
JPanel jp3=new JPanel();
JButton jb=new JButton("登陆");
JButton jb1=new JButton("注册");
JButton jb2=new JButton("设置");
jp3.add(jb);
jp3.add(jb1);
jp3.add(jb2);
jf.add(jp3);
JLabel jl3=new JLabel();
jf.add(jl3);
jf.setSize(300,400);
jf.setVisible(true);
jf.setResizable(false);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args)
{
new QQlogin();
}
}
6. JAVA的界面怎么做 它以抽象窗口工具包(AWT)为基础使跨平台应用程序可以使用任何可插拔的外观风格 。Swing开发人员只用很少的代码就可以利用Swing丰富、灵活的功能和模块化组件来创建优雅的用户界面 。
工具包中所有的包都是以swing作为名称 , 例如javax.swing,javax.swing.event
用Swing创建图形界面步骤:
(1)导入Swing包
(2)选择界面风格
(3)设置顶层容器
(4)设置按钮和标签
(5)将组件放到容器上
(6)为组件增加边框
(8)辅助技术支持
7. 编写一个Java的界面设计程序 import java.awt.BorderLayout; import java.awt.event.*;import javax.swing.*;import java.awt.*;public class Moble extends JFrame { private JTextField txtView; public static void main(String args[]) { try { Moble moble = new Moble(); moble.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } public Moble() { setTitle("模拟手机"); setBounds(100, 100, 200, 300); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); final JPanel panel = new JPanel(); getContentPane().add(panel, BorderLayout.CENTER); txtView = new JTextField(); panel.setLayout(null); panel.add(txtView); final JButton btn1 = new JButton(); btn1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { txtView.setText(txtView.getText().concat("1")); } }); btn1.setText("1"); btn1.setBounds(0, 73, 59, 23); panel.add(btn1); JButton btn2 = new JButton(); btn2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { txtView.setText(txtView.getText().concat("2")); } }); btn2.setText("2"); btn2.setBounds(68, 73, 59, 23); panel.add(btn2); JButton btn3 = new JButton(); btn3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { txtView.setText(txtView.getText().concat("3")); } }); btn3.setText("3"); btn3.setBounds(133, 73, 59, 23); panel.add(btn3); JButton btn4 = new JButton(); btn4.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { txtView.setText(txtView.getText().concat("4")); } }); btn4.setText("4"); btn4.setBounds(0, 102, 59, 23); panel.add(btn4); JButton btn5 = new JButton(); btn5.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { txtView.setText(txtView.getText().concat("5")); } }); btn5.setText("5"); btn5.setBounds(65, 102, 59, 23); panel.add(btn5); JButton btn6 = new JButton(); btn6.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { txtView.setText(txtView.getText().concat("6")); } }); btn6.setText("6"); btn6.setBounds(133, 102, 59, 23); panel.add(btn6); JButton b1 = new JButton(); b1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { txtView.setText(txtView.getText().concat("*")); } }); b1.setText("*"); b1.setBounds(0, 160, 59, 23); panel.add(b1); JButton b2 = new JButton(); b2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { txtView.setText(txtView.getText().concat("#")); } }); b2.setText("#"); b2.setBounds(133, 160, 59, 23); panel.add(b2); JButton btn7 = new JButton(); btn7.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { txtView.setText(txtView.getText().concat("7")); } }); btn7.setText("7"); btn7.setBounds(0, 131, 59, 23); panel.add(btn7); JButton btn8 = new JButton(); btn8.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { txtView.setText(txtView.getText().concat("8")); } }); btn8.setText("8"); btn8.setBounds(65, 131, 59, 23); panel.add(btn8); JButton btn9 = new JButton(); btn9.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { txtView.setText(txtView.getText().concat("9")); } }); btn9.setText("9"); btn9.setBounds(133, 131, 59, 23); panel.add(btn9); JButton btn0 = new JButton(); btn0.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { txtView.setText(txtView.getText().concat("0")); } }); btn0.setText("0"); btn0.setBounds(68, 160, 57, 23); panel.add(btn0); txtView = new JTextField(); txtView.setBounds(20, 24, 170, 21); panel.add(txtView); final JButton btnSend = new JButton(); btnSend.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if(txtView.getText().length()>3||txtView.getText().length() 评论0 0 0 。