当前位置:首页 » 编程语言 » java用户界面

java用户界面

发布时间: 2023-08-29 02:53:35

java编程 设计一个图形用户界面。界面包括三个单选按钮、两个复选框、一个列表、一个文本区和一个按

程序如下:
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextArea;
public class JFrameDemo extends JFrame implements ActionListener
{
private JPanel panel;
private JButton button;
private JTextArea textArea;
private JCheckBox musicBox;
private JCheckBox danceBox;
private JRadioButton hanButton;
private JRadioButton manButton;
private JRadioButton huiButton;
private ButtonGroup buttonGroup;
public JFrameDemo()
{
panel = new JPanel();
button = new JButton("确定");
textArea = new JTextArea(40,30);
musicBox = new JCheckBox("唱歌"橡渗);
danceBox = new JCheckBox("跳舞梁念脊"高轮);
huiButton = new JRadioButton("回族");
hanButton = new JRadioButton("汉族");
manButton = new JRadioButton("满族");

buttonGroup = new ButtonGroup();
buttonGroup.add(huiButton);
buttonGroup.add(hanButton);
buttonGroup.add(manButton);

panel.setLayout(new FlowLayout(3));
panel.add(huiButton);
panel.add(hanButton);
panel.add(manButton);
panel.add(musicBox);
panel.add(danceBox);
panel.add(button);
panel.add(textArea);

add(panel);
setTitle("选择兴趣爱好");
setBounds(100, 100, 400, 280);
setResizable(false);
setVisible(true);

this.button.addActionListener(this);

}
public static void main(String[] args)
{
new JFrameDemo();
}
@Override
public void actionPerformed(ActionEvent e)
{
if(e.getSource() == this.button)
{
String info = "";
if(this.huiButton.isSelected())
{
info += this.huiButton.getText() + "\n";
}
if(this.hanButton.isSelected())
{
info += this.hanButton.getText() + "\n";
}
if(this.manButton.isSelected())
{
info += this.manButton.getText() + "\n";
}
if(this.danceBox.isSelected())
{
info += this.danceBox.getText() + "\n";
}
if(this.musicBox.isSelected())
{
info += this.musicBox.getText() + "\n";
}
this.textArea.setText(info);
}
}
}

有问题欢迎提问,满意请采纳,谢谢!

② 用JAVA编写一个用户或注册登录界面。请哪位高手能够写下具体的代码,谢谢

  1. 效果图

    <!DOCTYPEhtml>
    <html>
    <head>
    <metacharset="UTF-8">
    <title>先锋图书馆管理系统-登录</title>
    <style>
    *{
    margin:0;
    padding:0;
    list-style:none;
    }
    #top{
    width:1000px;
    height:95px;
    margin:0auto;
    margin-top:25px;
    }
    #top_top{
    width:1000px;
    height:65px;
    background:deepskyblue;
    }
    #top_top_left{
    width:300px;
    height:65px;
    float:left;
    }
    #top_top_left>label{
    width:200px;
    height:65px;
    color:white;
    float:right;
    }
    #top_top_left>#a2{
    padding-left:10px;
    padding-top:20px;
    font-size:16px;
    }
    #top_bottom{
    width:1000px;
    height:30px;
    }
    #top_bottom_left{
    width:340px;
    height:30px;
    line-height:30px;
    font-size:12px;
    background:skyblue;
    color:white;
    text-indent:2em;
    float:left;
    }
    #top_bottom_right{
    width:660px;
    height:30px;
    line-height:30px;
    font-size:12px;
    color:blueviolet;
    text-align:center;
    float:right;
    background:lightskyblue;
    }
    #content{
    width:1000px;
    height:600px;
    margin:0auto;
    background:#587FBA;
    }
    #content>#text{
    width:1000px;
    height:50px;
    line-height:50px;
    padding-top:100px;
    font-size:36px;
    font-family:"楷体";
    font-weight:bold;
    text-align:center;
    }
    #content>#login{
    width:480px;
    height:210px;
    margin-top:20px;
    margin-left:260px;
    background:#85A0CB;
    }
    #content>#login>img{
    float:left;
    }
    #content>#login>#select{
    width:305px;
    height:210px;
    float:right;
    }
    #content>#login>#select>div{
    width:230;
    height:30px;
    margin-left:30px;
    }
    #content>#login>#select>#d1{
    margin-top:30px;
    margin-bottom:3px;
    }
    #content>#login>#select>p{
    font-size:14px;
    margin-left:95px;
    }
    #bottom{
    width:1000px;
    height:35px;
    line-height:35px;
    margin:0auto;
    background:deepskyblue;
    text-align:center;
    color:white;
    }
    </style>
    </head>
    <body>
    <divid="top">
    <divid="top_top">
    <divid="top_top_left">
    <imgsrc="img/test/a13.png"width="78px"height="65px"><labelid="a2">先锋图书馆系统管理平台</label>
    </div>
    </div>
    <divid="top_bottom">
    <divid="top_bottom_left">当前位置:首页>系统管理>登录</div>
    <divid="top_bottom_right">当前时间:<labelid="lable"></label></div>
    </div>
    </div>
    <divid="content">
    <divid="text">欢迎登录先锋图书馆管理系统</div>
    <divid="login">
    <imgsrc="img/test/a14.png"width="175px"height="210px"/>
    <formid="select">
    <divid="d1">用户名:&nbsp;&nbsp;<inputtype="text"/></div>
    <div>密&nbsp;码:&nbsp;&nbsp;<inputtype="password"/></div>
    <p>
    <inputtype="radio"name="user"value="read"/>读者&nbsp;&nbsp;&nbsp;&nbsp;
    <inputtype="radio"name="user"value="admin"/>管理员
    </p><br/>
    <p>
    <inputtype="button"value="确定"style="width:50px;"onclick="put()"/>&nbsp;&nbsp;&nbsp;&nbsp;
    <inputtype="reset"value="重置"style="width:50px;"/>
    </p>
    </form>
    </div>
    </div>
    <divid="bottom">欣欣科技有限公司版权所有</div>
    </body>
    <scripttype="text/javascript"src="JQuery/jquery.js"></script>
    <scripttype="text/javascript"src="js/GetCurrentTime.js"></script>
    <script>
    //验证用户名和密码
    functionput(){
    vard=$("#select>div>input");//获取用户名和密码
    varname=d[0].value;
    varpass=d[1].value;
    varuser=null;
    varr=document.getElementsByName("user");//获取用户类型
    for(i=0;i<r.length;i++){
    if(r[i].checked){
    user=r[i].value;
    }
    }
    //console.log(name+","+pass+","+user);//输出测试
    if(user==null){
    window.alert("请选择用户类型!");
    }elseif(user=="admin"&&name!="admin"){
    window.alter("用户名错误!");
    }elseif(user=="admin"&&name=="admin"&&pass!="123456"){
    window.alert("密码错误!");
    }elseif(name=="admin"&&pass=="123456"&&user=="admin"){
    window.location.href="work_02_welcome.html";//在js中在本页面中打开新链接
    }else{
    window.alert("用户名错误");
    }
    }
    </script>
    </html>

热点内容
国内唯一免费的云服务器 发布:2025-03-15 02:27:36 浏览:979
怎么重启远程服务器 发布:2025-03-15 02:26:53 浏览:247
u盘加密狗复制克隆软件 发布:2025-03-15 02:20:53 浏览:482
能玩VR的电脑要什么配置 发布:2025-03-15 02:19:36 浏览:715
明日之后电脑配置如何提高 发布:2025-03-15 02:08:39 浏览:862
c阶乘算法 发布:2025-03-15 02:08:39 浏览:364
挂锁忘记密码有什么办法 发布:2025-03-15 02:04:45 浏览:408
sql模糊查找 发布:2025-03-15 02:04:06 浏览:754
服务器如何不让玩家搞破坏 发布:2025-03-15 02:04:02 浏览:58
nmake编译win32 发布:2025-03-15 01:58:27 浏览:165