java有代码加界面 java怎么弄界面( 二 )


});
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==m11)//处理“添加信息”事件
{
new AddStudent();
}
if(e.getSource()==m12)//处理“查询信息”事件
{
new SelectStudent();
}
if(e.getSource()==m21)//处理“查询成绩”事件
{
new ChengJiStudent();
}
}
public static void main(String args[])
{new StudentJieMian();//创建一个对象}
求JAVA实现用户登录界面代码?你要先学会截图哦,你发的看不清楚,重新写了一个你参考参考!
import java.awt.GridLayout;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
public class Day30A extends JFrame {
private static final long serialVersionUID = 1L;
private JLabel labelName,labelId,labelPass,labelMoney,labelSelect,labelCar;
private JComboBoxString jcb;
private JPanel jp1,jp2,jp3,jp4,jp5,jp6,jp7;
private ButtonGroup btg;
private JRadioButton jr1,jr2;
Day30A(){
this.setTitle("注册账户");
this.setLayout(new GridLayout(7,1));
this.setSize(300,280);
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
init();
this.setVisible(true);
}
private void init() {
String str="卡片类型1,卡片类型2,卡片类型3,卡片类型4,卡片类型5";
jcb=new JComboBox(str.split(","));
labelId=new JLabel("账号: ");
labelName=new JLabel("姓名: ");
labelPass=new JLabel("密码: ");
labelMoney=new JLabel("开户金额:");
labelSelect=new JLabel("存款类型:");
labelCar=new JLabel("卡片类型:");
addFun1();
addFun2();
}
private void addFun2() {
this.add(jp1);
this.add(jp2);
this.add(jp3);
this.add(jp4);
this.add(jp5);
this.add(jp6);
this.add(jp7);
}
private void addFun1() {
jp1=new JPanel();
jp1.add(labelId);
jp1.add(new JTextField(15));
jp2=new JPanel();
jp2.add(labelName);
jp2.add(new JTextField(15));
jp3=new JPanel();
jp3.add(labelPass);
jp3.add(new JTextField(15));
jp4=new JPanel();
jp4.add(labelMoney);
jp4.add(new JTextField(13));
jp5=new JPanel();
jp5.add(labelSelect);
btg=new ButtonGroup();
jr1=new JRadioButton("定期");
jr2=new JRadioButton("活期",true);
btg.add(jr1);
btg.add(jr2);
jp5.add(jr1);
jp5.add(jr2);
jp6=new JPanel();
jp6.add(labelCar);
jp6.add(jcb);
jp7=new JPanel();
jp7.add(new JButton("确定"));
jp7.add(new JButton("取消"));
}
public static void main(String[] args) {
new Day30A();
}
}
一个java初级的界面问题(已有代码,帮忙添加几行就可以)——字体对话框我在你的基础上稍微添加了一些代码,现在可以改变字体大小了:
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
class FontDialog extends JDialog implements ItemListener, ActionListener {
JComboBox list;
JComboBox listSize;//显示可以选择的字体大小
JTextArea text;
Font font;
JButton yes, cancel;
JComponent com;
FontDialog(JComponent com) {
this.com = com;
setModal(true);
yes = new JButton("Yes");
cancel = new JButton("cancel");
yes.addActionListener(this);
cancel.addActionListener(this);
text = new JTextArea(2, 25);
list = new JComboBox();
listSize = new JComboBox();
GraphicsEnvironment ge = GraphicsEnvironment
.getLocalGraphicsEnvironment();

推荐阅读