1. 怎么用java写一个界面怎么用java写一个界面 新建一个窗口 , 然后实现一个关闭按钮”窗口的功能
import java.awt.*;
import java.awt.event.*;
public class TestWindowEvent {
public static void main (String[] args) {
new Frame88 ("WindowAdapter");
}
}
class Frame88 extends Frame {
Frame88 (String s) {
super(s);
setBounds (300,300,200,70);
setLayout (null);
setVisible (true);
addWindowListener (new WindowAdapter() {
public void windowClosing(WindowEvent e) {
setVisible (false);
System.exit(0);
}
} );
}
}
2. 用java给一个系统写界面应该怎么写 简单例子可供参考:
import java.awt.*;
import javax.swing.*;
class text2 {
public static void main(String[] args) {
JTextField Name,Number,Class;
JFrame j = new JFrame();
j.setBounds(500, 300, 0, 0);
j.setTitle("Information");
JPanel jp = new JPanel();
jp.setLayout(new GridLayout(4, 1));
final JLabel label_1 = new JLabel();
label_1.setText("Name:");
jp.add(label_1);
Name = new JTextField();
jp.add(Name);
final JLabel label_2 = new JLabel();
label_2.setText("Number:");
jp.add(label_2);
Number = new JTextField();
jp.add(Number);
final JLabel label_3 = new JLabel();
label_3.setText("Class:");
jp.add(label_3);
Class = new JTextField();
jp.add(Class);
final JButton save = new JButton();
jp.add(save);
save.setText("确认");
j.add(jp);
j.pack();
j.setVisible(true);
j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
3. 登陆界面的java代码怎么写 原发布者:梦妙奇缘
用户登录的代码://LoginFrame.javaimportjavax.swing.*;importjava.awt.*;importjava.awt.event.*;classMyJPanelextendsJPanelimplementsActionListener{privateintcount=0;privateJLabellabel1,label2;privateJTextFieldtext;privateJPasswordFieldpass;privateJButtonbutton1,button2;MyJPanel(){label1=newJLabel("用户名");label2=newJLabel("密码");button1=newJButton("确定");button2=newJButton("取消");text=newJTextField(20);pass=newJPasswordField(20);button1.setMnemonic(KeyEvent.VK_O);//设置按钮快捷键button2.setMnemonic(KeyEvent.VK_C);button1.setActionCommand("entry");button2.setActionCommand("cancel");button1.addActionListener(this);//注册按钮事件button2.addActionListener(this);//注册按钮事件setBackground(Color.cyan);//设定面板背景色add(label1);add(text);add(label2);add(pass);add(button1);add(button2);}publicvoidactionPerformed(ActionEvente){if(e.getActionCommand().equals("entry")){count++;//计数Stringusername,password;if(count<3){
4. java写一个登录界面 import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
class login extends JFrame implements ActionListener
{
public JPasswordField password;
public JTextField name;
JButton ok;
login()
{
setSize(300,200);//大小
setLocation(200,100);
JPanel panel = new JPanel();//创建一个面板对象
panel.setLayout(new GridBagLayout());
Container cn = this.getContentPane();
GridBagConstraints c = new GridBagConstraints();
c.insets = new Insets(5,2,5,5);
c.gridheight = 1;
JLabel user = new JLabel("User:");
c.gridx = 1;
c.gridy = 1;
panel.add(user,c);
name = new JTextField(10);
c.gridx = 2;
panel.add(name,c);
JLabel pass = new JLabel("assword:");
c.gridx = 1;
c.gridy = 2;
panel.add(pass,c);
password = new JPasswordField(10);
c.gridx = 2;
c.gridy = 2;
panel.add(password,c);
c.gridx = 1;
c.gridy = 3;
ok = new JButton("login");
ok.addActionListener(this);
- 银杏湖作文怎么写
- 故事的启示怎么写
- 项目调研怎么写
- 怎么写email
- 鬃狮蜥如何辨别公母 鬃狮蜥怎么分辨公母
- 箭头怎么打 箭头怎么弄上去的
- 怎么打开软键盘 怎么打开软键盘里的符号键盘
- 2020款东风风行t5l怎么样
- 怎么制作文件夹 怎么制作文件夹视频
- 百度云怎么加好友 百度怎么添加好友