62,620
社区成员
发帖
与我相关
我的任务
分享import java.awt.*;
public class Demo{
public static void main(String[] args){
Frame fr=new Frame("媒体新闻");
fr.setLayout(new FlowLayout());
Button button1=new Button("确定");
Button button2=new Button("取消");
fr.add(button1);
fr.add(button2);
fr.setSize(200,300);
fr.setBackground(Color.cyan);
fr.validate();
}
}
import java.awt.*;
public class Demo{
public static void main(String[] args){
Frame fr=new Frame("媒体新闻");
fr.setLayout(new FlowLayout());
Button button1=new Button("确定");
Button button2=new Button("取消");
fr.add(button1);
fr.add(button2);
fr.setSize(200,300);
fr.setBackground(Color.cyan);
fr.setVisible(true);
}
}
package com.alpha.test;
/*
* QQ 登录界面
* date:2009-10-21 19:52:36
* author:JavaAlpha
*/
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
public class Main1 extends JFrame implements ActionListener
{
private static final long serialVersionUID = 1L;
JLabel jlb1, jlb2;
JButton jb1, jb2;
JTextField jtf;
JPasswordField jpf;
public Main1()
{
// 创建组件
jlb1 = new JLabel("Q号");
jlb2 = new JLabel("密码");
jb1 = new JButton();
jb2 = new JButton();
jtf = new JTextField();
jpf = new JPasswordField();
// 设置布局
this.setLayout(new GridLayout(3, 2));
// 添加组件
this.add(jlb1);
this.add(jtf);
this.add(jlb2);
this.add(jpf);
this.add(jb1);
this.add(jb2);
// 添加监听
// 展现窗体
this.setSize(330, 200);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
}
public static void main(String[] args)
{
new Main1();
}
public void actionPerformed(ActionEvent arg0)
{
}
}import java.awt.*;
public class Demo extends JFrame{ //要继承JFrame
public static void main(String[] args){
Frame fr=new Frame("媒体新闻");
fr.setLayout(new FlowLayout());
Button button1=new Button("确定");
Button button2=new Button("取消");
fr.add(button1);
fr.add(button2);
fr.setSize(200,300);
fr.setBackground(Color.cyan);
fr.validate();
this.setVisible(true);//这句是现实frame的
}
}