java编程,谁能帮帮我啊
java.swing包中的类可以实现图形用户界面(GUI界面):
用java.swing包中的类实现如下的GUI界面:
java.swing包中的类可以实现图形用户界面(GUI界面):
编写一个计算器界面,界面如下:
java.swing包中的类可以实现图形用户界面(GUI界面):
编程实现一个计算器,界面如下:
要求:自定义的所有类、局部变量、成员变量和成员方法命名时,都要用自己的学号末2位作为变量名的结尾(例如:你学号的末两位是30,你想定义一个整形变量a,则应该写成int a30)。
追问:能帮我把下面的两道题给我做了吗 我一点都不会 摆脱了
答案:
蛮久没编过GUI 写了第一个 上面是效果 进度条直接用了JProgressBar
package GUI;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPasswordField;
import javax.swing.JProgressBar;
import javax.swing.JRadioButton;
import javax.swing.JTextArea;
import javax.swing.JTextField;
public class Register extends JFrame{
private static final long serialVersionUID = 1L;
JLabel jl_name,jl_password,jl_易做图,jl_interest,jl_income,jl_addr,jl_remark;
JTextField jt_name;
JPasswordField jp_password;
JRadioButton 易做图_b1,易做图_b2;
ButtonGroup group ;
JCheckBox jc_interest1,jc_interest2,jc_interest3,jc_interest4,jc_interest5;
JProgressBar progressBar;
JComboBox jc_addr;
JTextArea jt_area;
JButton jb1,jb2;
public static void main(String[] args) {
new Register();
}
Register(){
this.setLayout(null); //布局为null
jl_name = new JLabel("姓名");
jl_password = new JLabel("密码");
jl_易做图 = new JLabel("性别");
jt_name = new JTextField();
jp_password = new JPasswordField();
group = new ButtonGroup();//单选按钮分组以保证单一选择
易做图_b1 = new JRadioButton("男",true);
易做图_b2 = new JRadioButton("女",false);
jl_interest = new JLabel("兴趣");
jc_interest1 = new JCheckBox("读书",false);
jc_interest2 = new JCheckBox("音乐",false);
jc_interest3 = new JCheckBox("体育",false);
jc_interest4 = new JCheckBox("旅游",false);
jc_interest5 = new JCheckBox("看电影",false);
jl_income = new JLabel("月收入");
jl_addr = new JLabel("所在城市");
jc_addr = new JComboBox();
jl_remark = new JLabel("备注");
jt_area = new JTextArea();
jb1 = new JButton("提交");
jb2 = new JButton("取消");
jc_addr.addItem("北京");
jc_addr.addItem("天津");
jc_addr.addItem("上海");
jc_addr.addItem("大连");
progressBar = new JProgressBar();
jl_name.setBounds(20,10,30,20);
jt_name.setBounds(60,10,100,20);
jl_password.setBounds(20,40,30,20);
jp_password.setBounds(60,40,100,20);
jl_易做图.setBounds(20,70,30,20);
易做图_b1.setBounds(60,70,50,20);
易做图_b2.setBounds(120,70,50,20);
jl_interest.setBounds(20,100,30,20);
jc_interest1.setBounds(60,100,80,20);
jc_interest2.setBounds(20,130,80,20);
jc_interest3.setBounds(110,130,80,20);
jc_interest4.setBounds(20,160,80,20);
jc_interest5.setBounds(110,160,80,20);
jl_income.setBounds(20,190,50,20);
progressBar.setBounds(20,220,150,20);
jl_addr.setBounds(20,250,60,20);
jc_addr.setBounds(90,250,80,20);
jl_remark.setBounds(20,280,30,20);
jt_area.setBounds(20,310,160,100);
jb1.setBounds(20,420,70,30);
jb2.setBounds(100,420,70,30);
this.add(jl_name);
this.add(jl_password);
this.add(jt_name);
this.add(jp_password);
this.add(jl_易做图);
group.add(易做图_b1);
group.add(易做图_b2);
this.add(易做图_b1);
this.add(易做图_b2);
this.add(jl_interest);
this.add(jc_interest1);
this.add(jc_interest2);
this.add(jc_interest3);
this.add(jc_interest4);
this.add(jc_interest5);
this.add(jl_income);
this.add(progressBar);
this.add(jl_addr);
this.add(jc_addr);
this.add(jl_remark);
this.add(jt_area);
this.add(jb1);
this.add(jb2);
this.setVisible(true);
this.setBounds(400,100,200,500);
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}
}
计算器 及其实现 你自己做吧 也很简单 用到布局GridLayout
上一个:万年历 用java怎么编写啊?
下一个:什么叫分类继承?给一段Java或者C++示例