用Java语言设计一个界面, 40
通过输入学生姓名,学号,通过单选按钮选择性别,通过复选框选择课程,通过组合框选择任课教师,点击确定按钮,在文本框中显示所填写的信息。是用Netbeans可以运行就可以...
通过输入学生姓名,学号,通过单选按钮选择性别,通过复选框选择课程,通过组合框选择任课教师,点击确定按钮,在文本框中显示所填写的信息。
是用Netbeans可以运行就可以 展开
是用Netbeans可以运行就可以 展开
3个回答
展开全部
首先:采用什么技术实现
java语言可以使用awt 和swing等技术实现图形界面
推荐使用Swing,因为Swing比AWT更专业,更漂亮,组件更丰富,功能更强大。
2. 其次:分析采用什么布局
边界布局BorderLayout,配合表格布局GridLayout,既简单又美观
3. 最后:分析需求中需要用的组件
学生姓名 学号 显示信息 需要用到文本框JTextField
单选按钮 需要用到组件 JRadioButton
复选框 需要用到组件 JCheckBox
组合框 需要用到组件 JComboBox
图片效果
参考代码如下
//导入所需要的包
import java.awt.event.*;
import javax.swing.border.*;
import javax.swing.*;
import java.awt.*;
public class ClassFrame extends JFrame {// 写一个类继承自JFrame 窗体
// 定义组件
private static final long serialVersionUID = 1L;
private JPanel contentPane;
private JTextField tfName, tfNum, allInfo;
private JRadioButton rb1, rb2;
private JCheckBox cb1, cb2, cb3;
private JComboBox<String> t1, t2, t3;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
ClassFrame frame = new ClassFrame();// 创建一个窗口实例
frame.setVisible(true);// 让该窗口实例可见
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* 窗口属性的设置,内部组件的初始化
*/
public ClassFrame() {
setTitle("选课ing...");//标题
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);// 设置关闭是退出JVM
setSize(450, 339);// 设置窗体大小
setLocationRelativeTo(null);// 窗体居中
contentPane = new JPanel();// 内容面板
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(new BorderLayout(0, 0));// 设置布局
setContentPane(contentPane);
JPanel panel = new JPanel(new GridLayout(5, 1, 5, 10));//5行1列的表格布局
panel.setBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null));
contentPane.add(panel, BorderLayout.CENTER);//给panel添加边框
JPanel panel_1 = new JPanel();
panel.add(panel_1);
JLabel label = new JLabel("姓名");
panel_1.add(label);
tfName = new JTextField();
panel_1.add(tfName);
tfName.setColumns(10);
JLabel label_2 = new JLabel("学号");
panel_1.add(label_2);
tfNum = new JTextField();
tfNum.setColumns(10);
panel_1.add(tfNum);
rb1 = new JRadioButton("男");
panel_1.add(rb1);
rb1.setSelected(true);//设置单选按钮中,默认选择的按钮
rb2 = new JRadioButton("女");
panel_1.add(rb2);
ButtonGroup bts = new ButtonGroup();//单选按钮需要加入同一个ButonGroup中才能生效
bts.add(rb1);
bts.add(rb2);
JPanel panel_2 = new JPanel();
panel.add(panel_2);
cb1 = new JCheckBox("高等数学");
panel_2.add(cb1);
t1 = new JComboBox<String>();
t1.setModel(new DefaultComboBoxModel<String>(new String[] { "林老师", "赵老师", "孙老师" }));
panel_2.add(t1);
JPanel panel_3 = new JPanel();
panel.add(panel_3);
cb2 = new JCheckBox("世界经济");
panel_3.add(cb2);
t2 = new JComboBox<String>();
t2.setModel(new DefaultComboBoxModel<String>(new String[] { "张老师", "刘老师" }));
panel_3.add(t2);
JPanel panel_4 = new JPanel();
panel.add(panel_4);
cb3 = new JCheckBox("音乐赏析");
panel_4.add(cb3);
t3 = new JComboBox<String>();
t3.setModel(new DefaultComboBoxModel<String>(new String[] { "王老师", "周老师" }));
panel_4.add(t3);
JPanel panel_5 = new JPanel();
panel.add(panel_5);
JButton jbOk = new JButton("确定");
panel_5.add(jbOk);
JButton jbRest = new JButton("重填");
panel_5.add(jbRest);
JPanel panelSouth = new JPanel();
contentPane.add(panelSouth, BorderLayout.SOUTH);
JLabel labe = new JLabel("选课信息");
labe.setHorizontalAlignment(SwingConstants.LEFT);
panelSouth.add(labe);
allInfo = new JTextField();
allInfo.setColumns(30);
panelSouth.add(allInfo);
JPanel panelNorth = new JPanel();
contentPane.add(panelNorth, BorderLayout.NORTH);
JLabel labelTitle = new JLabel("学生选课界面");
labelTitle.setForeground(Color.DARK_GRAY);
labelTitle.setFont(new Font("宋体", Font.BOLD, 20));
panelNorth.add(labelTitle);
//给确定按钮添加事件处理代码
jbOk.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
StringBuilder info = new StringBuilder();
String name = tfName.getText();
String num = tfNum.getText();
String sex;
if (rb1.isSelected()) {
sex = "男";
} else {
sex = "女";
}
info.append(name + num + sex);
if (cb1.isSelected()) {
String c = cb1.getText();
String t = t1.getSelectedItem().toString();
info.append(" " + c + t);
}
if (cb2.isSelected()) {
String c = cb2.getText();
String t = t2.getSelectedItem().toString();
info.append(" " + c + t);
}
if (cb3.isSelected()) {
String c = cb3.getText();
String t = t3.getSelectedItem().toString();
info.append(" " + c + t);
}
allInfo.setText(info.toString());//把学生信息和选课信息放到文本框
}
});
//给重填按钮 设置事件处理代码
jbRest.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
tfName.setText("");
tfNum.setText("");
rb1.setSelected(true);
cb1.setSelected(false);
t1.setSelectedIndex(0);
cb2.setSelected(false);
t2.setSelectedIndex(0);
cb3.setSelected(false);
t3.setSelectedIndex(0);
allInfo.setText("");
}
});
}
}
展开全部
你的意思是图形编辑器??
java开发工具eclipse和myeclipse都不具备图形编译功能
不过你可以试一试Dreamweaver 这个是专业的网页编辑工具
java开发工具eclipse和myeclipse都不具备图形编译功能
不过你可以试一试Dreamweaver 这个是专业的网页编辑工具
更多追问追答
追问
netbeans可以的
追答
netbeans 国内用的并不多,相对主流的eclipse的来说,较卡
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2015-06-11
展开全部
<!DOCTYPE html>
<html
class="chrome js no-touch rgba multiplebgs backgroundsize boxshadow textshadow opacity cssanimations cssgradients csstransitions generatedcontent
js no-touch rgba multiplebgs backgroundsize boxshadow textshadow opacity cssanimations cssgradients csstransitions generatedcontent">
<head>
<script type="text/javascript">
var viewInfo = function(){
var name=document.getElementById('name').value;
var number=document.getElementById('number').value;
var sex=document.getElementById('sex').value;
var selection1=document.getElementById('selection1').value;
var selection2=document.getElementById('selection2').value;
var selection3=document.getElementById('selection3').value;
var selection4=document.getElementById('selection4').value;
var message = "姓名:"+name+"\r\n"
+"学号:"+number+"\r\n"
+"性别:"+sex+"\r\n"
+"课程:"+selection1+"中的"+selection2+"\r\n"
+"教师:"+selection3+"中的"+selection4+"\r\n"
document.getElementById("message").value = message;
}
</script>
<style id="holderjs-style" type="text/css">
.bootstrap-frm {
margin-left:auto;
margin-right:auto;
max-width: 500px;
background: #FFF;
padding: 20px 30px 20px 30px;
font: 12px "Helvetica Neue", Helvetica, Arial, sans-serif;
color: #888;
text-shadow: 1px 1px 1px #FFF;
border:1px solid #DDD;
border-radius: 5px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
}
.bootstrap-frm h1 {
font: 25px "Helvetica Neue", Helvetica, Arial, sans-serif;
padding: 0px 0px 10px 40px;
display: block;
border-bottom: 1px solid #DADADA;
margin: -10px -30px 30px -30px;
color: #888;
}
.bootstrap-frm h1>span {
display: block;
font-size: 11px;
}
.bootstrap-frm label {
display: block;
margin: 0px 0px 5px;
}
.bootstrap-frm label>span {
float: left;
width: 20%;
text-align: right;
padding-right: 10px;
margin-top: 10px;
color: #333;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-weight: bold;
}
.bootstrap-frm input[type="text"], .bootstrap-frm input[type="email"], .bootstrap-frm textarea, .bootstrap-frm select{
border: 1px solid #CCC;
color: #888;
height: 20px;
line-height:15px;
margin-bottom: 16px;
margin-right: 6px;
margin-top: 2px;
outline: 0 none;
padding: 5px 0px 5px 5px;
width: 70%;
border-radius: 4px;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
}
.bootstrap-frm input[type="radio"]{
height: 15px;
line-height:15px;
margin-bottom: 16px;
padding: 5px 0px 5px 5px;
margin-right: 6px;
margin-top: 2px;
}
.bootstrap-frm select {
background: #FFF url('down-arrow.png') no-repeat right;
background: #FFF url('down-arrow.png') no-repeat right;
appearance:none;
-webkit-appearance:none;
-moz-appearance: none;
text-indent: 0.01px;
text-overflow: '';
width: 30%;
height: 35px;
line-height:15px;
}
.bootstrap-frm textarea{
height:100px;
padding: 5px 0px 0px 5px;
width: 70%;
}
.bootstrap-frm .button {
background: #FFF;
border: 1px solid #CCC;
padding: 10px 25px 10px 25px;
color: #333;
border-radius: 4px;
}
.bootstrap-frm .button:hover {
color: #333;
background-color: #EBEBEB;
border-color: #ADADAD;
}
</style>
</head>
<body>
<form action="" method="post" class="bootstrap-frm">
<h1>Table
<span>Please fill all the texts in the fields.</span>
</h1>
<label>
<span>姓名 :</span>
<input id="name" type="text" name="name" placeholder="姓名" />
</label>
<label>
<span>学号 :</span>
<input id="number" type="email" name="number" placeholder="学号" />
</label>
<label>
<span>性别 :</span>
<input id="sex" type="radio" name="email" value="男" />男
<input id="sex" type="radio" name="email" value="女" />女
</label>
<label>
<span>课程 :</span><select name="selection" id="selection1">
<option value="理科">理科</option>
<option value="文科">文科</option>
</select>
<select name="selection" id="selection2">
<option value="语文">语文</option>
<option value="数学">数学</option>
</select>
</label>
<label>
<span>任课教师 :</span><select name="selection" id="selection3">
<option value="理科老师">理科老师</option>
<option value="文科老师">文科老师</option>
</select>
<select name="selection" id="selection4">
<option value="语文老师">语文老师</option>
<option value="数学老师">数学老师</option>
</select>
</label>
<label>
<span>显示信息 :</span>
<textarea id="message" name="message" placeholder="显示信息"></textarea>
</label>
<label>
<span> </span>
<input type="button" class="button" value="Send" onclick="viewInfo();"/>
</label>
</form>
</body>
</html>
<html
class="chrome js no-touch rgba multiplebgs backgroundsize boxshadow textshadow opacity cssanimations cssgradients csstransitions generatedcontent
js no-touch rgba multiplebgs backgroundsize boxshadow textshadow opacity cssanimations cssgradients csstransitions generatedcontent">
<head>
<script type="text/javascript">
var viewInfo = function(){
var name=document.getElementById('name').value;
var number=document.getElementById('number').value;
var sex=document.getElementById('sex').value;
var selection1=document.getElementById('selection1').value;
var selection2=document.getElementById('selection2').value;
var selection3=document.getElementById('selection3').value;
var selection4=document.getElementById('selection4').value;
var message = "姓名:"+name+"\r\n"
+"学号:"+number+"\r\n"
+"性别:"+sex+"\r\n"
+"课程:"+selection1+"中的"+selection2+"\r\n"
+"教师:"+selection3+"中的"+selection4+"\r\n"
document.getElementById("message").value = message;
}
</script>
<style id="holderjs-style" type="text/css">
.bootstrap-frm {
margin-left:auto;
margin-right:auto;
max-width: 500px;
background: #FFF;
padding: 20px 30px 20px 30px;
font: 12px "Helvetica Neue", Helvetica, Arial, sans-serif;
color: #888;
text-shadow: 1px 1px 1px #FFF;
border:1px solid #DDD;
border-radius: 5px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
}
.bootstrap-frm h1 {
font: 25px "Helvetica Neue", Helvetica, Arial, sans-serif;
padding: 0px 0px 10px 40px;
display: block;
border-bottom: 1px solid #DADADA;
margin: -10px -30px 30px -30px;
color: #888;
}
.bootstrap-frm h1>span {
display: block;
font-size: 11px;
}
.bootstrap-frm label {
display: block;
margin: 0px 0px 5px;
}
.bootstrap-frm label>span {
float: left;
width: 20%;
text-align: right;
padding-right: 10px;
margin-top: 10px;
color: #333;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-weight: bold;
}
.bootstrap-frm input[type="text"], .bootstrap-frm input[type="email"], .bootstrap-frm textarea, .bootstrap-frm select{
border: 1px solid #CCC;
color: #888;
height: 20px;
line-height:15px;
margin-bottom: 16px;
margin-right: 6px;
margin-top: 2px;
outline: 0 none;
padding: 5px 0px 5px 5px;
width: 70%;
border-radius: 4px;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
}
.bootstrap-frm input[type="radio"]{
height: 15px;
line-height:15px;
margin-bottom: 16px;
padding: 5px 0px 5px 5px;
margin-right: 6px;
margin-top: 2px;
}
.bootstrap-frm select {
background: #FFF url('down-arrow.png') no-repeat right;
background: #FFF url('down-arrow.png') no-repeat right;
appearance:none;
-webkit-appearance:none;
-moz-appearance: none;
text-indent: 0.01px;
text-overflow: '';
width: 30%;
height: 35px;
line-height:15px;
}
.bootstrap-frm textarea{
height:100px;
padding: 5px 0px 0px 5px;
width: 70%;
}
.bootstrap-frm .button {
background: #FFF;
border: 1px solid #CCC;
padding: 10px 25px 10px 25px;
color: #333;
border-radius: 4px;
}
.bootstrap-frm .button:hover {
color: #333;
background-color: #EBEBEB;
border-color: #ADADAD;
}
</style>
</head>
<body>
<form action="" method="post" class="bootstrap-frm">
<h1>Table
<span>Please fill all the texts in the fields.</span>
</h1>
<label>
<span>姓名 :</span>
<input id="name" type="text" name="name" placeholder="姓名" />
</label>
<label>
<span>学号 :</span>
<input id="number" type="email" name="number" placeholder="学号" />
</label>
<label>
<span>性别 :</span>
<input id="sex" type="radio" name="email" value="男" />男
<input id="sex" type="radio" name="email" value="女" />女
</label>
<label>
<span>课程 :</span><select name="selection" id="selection1">
<option value="理科">理科</option>
<option value="文科">文科</option>
</select>
<select name="selection" id="selection2">
<option value="语文">语文</option>
<option value="数学">数学</option>
</select>
</label>
<label>
<span>任课教师 :</span><select name="selection" id="selection3">
<option value="理科老师">理科老师</option>
<option value="文科老师">文科老师</option>
</select>
<select name="selection" id="selection4">
<option value="语文老师">语文老师</option>
<option value="数学老师">数学老师</option>
</select>
</label>
<label>
<span>显示信息 :</span>
<textarea id="message" name="message" placeholder="显示信息"></textarea>
</label>
<label>
<span> </span>
<input type="button" class="button" value="Send" onclick="viewInfo();"/>
</label>
</form>
</body>
</html>
追问
求一个·能用netbeans运行的,不是网页,
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询