大二java课程设计题目和代码?基于java的毕业设计题目大全
今天给各位分享大二java课程设计题目和代码的知识,其中也会对基于java的毕业设计题目大全进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!
java课程设计题目及代码是什么
java课程设计题目及代码分别是:
1、题目:计算器。设计内容是设计一个图形界面(GUI)的计算器应用程序,完成简单的算术运算。
设计要求是设计的计算器应用程序可以完成家法、减法、乘法、除法和取余运算。且有小数点、正负号、求倒数、退格和清零功能。
2、代码:
数字按钮NumberButton类如下:
import java.awt.
import java.awt.event.
import javax.swing.
public class NumberButton extends Button.
{
int number.
public NumberButton(int number).
{
super(""+number).
this.number=number.
setForeground(Color.blue).
}
public int getNumber().
{
return number;
}
}
其它java课程设计题目及代码是:
题目:华容道。编写一个按钮的子类,使用该子类创建的对象代表华容道中的人物。通过焦点事件控制人物颜色,当人物获得焦点时颜色为蓝色,当失去焦点时颜色为灰色。
通过键盘事件和鼠标事件来实现曹操、关羽等人物的移动。当人物上发生鼠标事件或键盘事件时,如果鼠标指针的位置是在人物的下方(也就是组件的下半部分)或按下键盘的“↓“键,该人物向下移动。向左、向右和向上的移动原理类似。
代码是:
String name[]={"曹操","关羽","张","刘","马","许","兵","兵","兵","兵"}.
for(int i=0;i<name.length;i++).
{
person[i]=new Person(i,name[i]).
person[i].addKeyListener(this).
person[i].addMouseListener(this).
// person[i].addFocusListener(new Person).
add(person[i]).
}
person[0].setBounds(104,54,100,100).
person[1].setBounds(104,154,100,50).
person[2].setBounds(54,154,50,100).
person[3].setBounds(204,154,50,100).
person[4].setBounds(54,54,50,100).
person[5].setBounds(204,54,50,100);
person[6].setBounds(54,254,50,50);
person[7].setBounds(204,254,50,50);
person[8].setBounds(104,204,50,50);
person[9].setBounds(154,204,50,50);
请高手写个java课程设计的代码
只是简单的改了一下,在爱好的“其他”中加入了一个用来输入的文本框,不知道你想改成什么样子的呢?
类的名字最好首字母大写。
package game;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class survry extends JFrame implements ActionListener{
private JPanel jp= new JPanel();
private JRadioButton man= new JRadioButton("男",true);
private JRadioButton woman= new JRadioButton("女");
ButtonGroup sexBG= new ButtonGroup();
JLabel sexSTR= new JLabel("你的性别:");
JLabel likeSTR= new JLabel("你的爱好:");
JLabel ageSTR= new JLabel("你的年龄:");
private JCheckBox[] jcbArray={new JCheckBox("灌水"), new JCheckBox("游戏"),
new JCheckBox("发呆"), new JCheckBox("旅游"),
new JCheckBox("其他")};
private JRadioButton[] jrbArray={new JRadioButton("小学毕业"),
new JRadioButton("亭亭玉立", true),
new JRadioButton("而立之年"),
new JRadioButton("大展宏图"),
new JRadioButton("涛声依旧")};
private JButton[] jbArray={new JButton("提交"), new JButton("清空")};
private JLabel[] jlArray={new JLabel("年龄段:"), new JLabel("兴趣爱好:"),
new JLabel("调查的结果为:")};
private JTextField otherTF= new JTextField();
private JTextField jtf= new JTextField();
private ButtonGroup bg= new ButtonGroup();
boolean isViewOtherTF= false;
public survry(){
jp.setLayout(null);
sexBG.add(man);
sexBG.add(woman);
man.setBounds(100, 20, 50, 30);
woman.setBounds(150, 20, 50, 30);
jp.add(man);
jp.add(woman);
sexSTR.setBounds(30, 20, 75, 30);
jp.add(sexSTR);
likeSTR.setBounds(30, 50, 75, 30);
jp.add(likeSTR);
ageSTR.setBounds(30, 80, 75, 30);
jp.add(ageSTR);
for(int i= 0; i< jcbArray.length; i++){
jcbArray[i].setBounds(60* i+ 100, 50, 60, 30);
jp.add(jcbArray[i]);
}
otherTF.setBounds(410, 50, 100, 22);
jp.add(otherTF);
otherTF.setVisible(false);
jcbArray[jcbArray.length- 1].addActionListener(this);
for(int i= 0; i< jrbArray.length; i++){
jrbArray[i].setBounds(90* i+ 100, 80, 90, 30);
jp.add(jrbArray[i]);
bg.add(jrbArray[i]);
}
jbArray[0].setBounds(30, 110, 80, 30);
jp.add(jbArray[0]);
jbArray[1].setBounds(120, 110, 80, 30);
jp.add(jbArray[1]);
jbArray[0].addActionListener(this);
jbArray[1].addActionListener(this);
jtf.setBounds(120, 150, 500, 26);
jp.add(jtf);
jtf.setEditable(false);
this.add(jp);
this.setTitle("个人信息调查表");
this.setBounds(100, 100, 700, 280);
this.setVisible(true);
this.setResizable(false);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent e){
if(e.getSource()== jcbArray[jcbArray.length- 1]){
if(isViewOtherTF){
otherTF.setVisible(false);
isViewOtherTF= false;
}else{
otherTF.setVisible(true);
isViewOtherTF= true;
}
}
if(e.getSource()== jbArray[1]){
if(isViewOtherTF){
otherTF.setVisible(false);
isViewOtherTF= false;
}
for(int i= 0; i< jcbArray.length; i++){
jcbArray[i].setSelected(false);
}
jtf.setText("");
otherTF.setText("");
sexBG.setSelected(man.getModel(),true);
bg.setSelected(jrbArray[1].getModel(),true);
}
if(e.getSource()== jbArray[0]){
StringBuffer temp1= new StringBuffer("你是一个");
StringBuffer temp2= new StringBuffer();
for(int i= 0; i< 5; i++){
if(jrbArray[i].isSelected()){
temp1.append(jrbArray[i].getText());
}
if(jcbArray[i].isSelected()){
if(i== 4){
temp2.append(otherTF.getText());
} else{
temp2.append(jcbArray[i].getText()+",");
}
}
}
if(temp2.length()== 0){
jtf.setText("难道你没有爱好?");
} else{
temp1.append("的人,你比较喜欢");
temp1.append(temp2.substring(0, temp2.length()- 1));
jtf.setText(temp1.append("。").toString());
}
}
}
public static void main(String[] args){
new survry();
}
}
Java课程设计!急!!!(高分)
我帮你编写了一部分,实现了“输入十个同学的相关信息,并在文本框中显示”(图形界面实现)。
要实现接下去的功能其实也真的不难的,但是真的很麻烦、很浪费时间……我就帮你做到这里了,你自己添加一下代码就可以(或者提高悬赏的话可以考虑考虑啊!哈哈……)代码如下:
importjava.awt.BorderLayout;
importjavax.swing.JPanel;
importjavax.swing.JFrame;
importjava.awt.Dimension;
importjavax.swing.JButton;
importjava.awt.Rectangle;
importjavax.swing.JLabel;
importjavax.swing.SwingConstants;
importjavax.swing.JScrollPane;
importjavax.swing.JTextArea;
importjavax.swing.JOptionPane;
publicclassTongJiextendsJFrame{
privatestaticfinallongserialVersionUID=1L;
privateJPaneljContentPane=null;
privateJButtonjButton=null;
privateJLabeljLabel=null;
privateJScrollPanejScrollPane=null;
privateJTextAreajTextArea=null;
/**
*Thisisthedefaultconstructor
*/
publicTongJi(){
super();
initialize();
}
/**
*Thismethodinitializesthis
*
*@returnvoid
*/
privatevoidinitialize(){
this.setSize(412,372);
this.setContentPane(getJContentPane());
this.setTitle("成绩统计");
this.addWindowListener(newjava.awt.event.WindowAdapter(){
publicvoidwindowClosing(java.awt.event.WindowEvente){
System.exit(0);
}
});
this.setVisible(true);
}
/**
*ThismethodinitializesjContentPane
*
*@returnjavax.swing.JPanel
*/
privateJPanelgetJContentPane(){
if(jContentPane==null){
jLabel=newJLabel();
jLabel.setBounds(newRectangle(18,66,65,18));
jLabel.setHorizontalAlignment(SwingConstants.CENTER);
jLabel.setText("统计结果:");
jContentPane=newJPanel();
jContentPane.setLayout(null);
jContentPane.add(getJButton(),null);
jContentPane.add(jLabel,null);
jContentPane.add(getJScrollPane(),null);
}
returnjContentPane;
}
/**
*ThismethodinitializesjButton
*
*@returnjavax.swing.JButton
*/
privateJButtongetJButton(){
if(jButton==null){
jButton=newJButton();
jButton.setBounds(newRectangle(18,16,86,28));
jButton.setText("开始统计");
jButton.addActionListener(newjava.awt.event.ActionListener(){
publicvoidactionPerformed(java.awt.event.ActionEvente){
/////录入成绩信息
String[][]mymsg=newString[10][6];
for(inti=0;i<10;i++){
Stringstrnum=JOptionPane.showInputDialog(null,"请输入第"+(i+1)+"个学生的学号","信息录入",JOptionPane.WARNING_MESSAGE);
Stringstrname=JOptionPane.showInputDialog(null,"请输入第"+(i+1)+"个学生的姓名","信息录入",JOptionPane.WARNING_MESSAGE);
Stringdoublemath=JOptionPane.showInputDialog(null,"请输入第"+(i+1)+"个学生的数学成绩","信息录入",JOptionPane.WARNING_MESSAGE);
Stringdoubleeng=JOptionPane.showInputDialog(null,"请输入第"+(i+1)+"个学生的英语成绩","信息录入",JOptionPane.WARNING_MESSAGE);
Stringdoublejava=JOptionPane.showInputDialog(null,"请输入第"+(i+1)+"个学生的JAVA成绩","信息录入",JOptionPane.WARNING_MESSAGE);
Stringdoublecomp=JOptionPane.showInputDialog(null,"请输入第"+(i+1)+"个学生的计算机成绩","信息录入",JOptionPane.WARNING_MESSAGE);
mymsg[i][0]=strnum;
mymsg[i][1]=strname;
mymsg[i][2]=doublemath;
mymsg[i][3]=doubleeng;
mymsg[i][4]=doublejava;
mymsg[i][5]=doublecomp;
}
////显示成绩信息
jTextArea.setText("学号姓名数学英语JAVA计算机");
for(inti=0;i<10;i++){
jTextArea.setText(jTextArea.getText()+"
");
for(intj=0;j<6;j++){
jTextArea.setText(jTextArea.getText()+mymsg[i][j]+"");
}
}
}
});
}
returnjButton;
}
/**
*ThismethodinitializesjScrollPane
*
*@returnjavax.swing.JScrollPane
*/
privateJScrollPanegetJScrollPane(){
if(jScrollPane==null){
jScrollPane=newJScrollPane();
jScrollPane.setBounds(newRectangle(18,86,370,230));
jScrollPane.setViewportView(getJTextArea());
}
returnjScrollPane;
}
/**
*ThismethodinitializesjTextArea
*
*@returnjavax.swing.JTextArea
*/
privateJTextAreagetJTextArea(){
if(jTextArea==null){
jTextArea=newJTextArea();
jTextArea.setEditable(false);
}
returnjTextArea;
}
publicstaticvoidmain(Stringargs[]){
newTongJi();
}
}//@jve:decl-index=0:visual-constraint="10,10"
效果如下图:
好了,关于大二java课程设计题目和代码和基于java的毕业设计题目大全的问题到这里结束啦,希望可以解决您的问题哈!