java程序设计期末代码 java期末项目设计

java面向对象程序设计期末考试编程题!急!!!

===============================第一题==============================

长安网站建设公司成都创新互联,长安网站设计制作,有大型网站制作公司丰富经验。已为长安上千多家提供企业网站建设服务。企业网站搭建\成都外贸网站制作要多少钱,请找那个售后服务好的长安做网站的公司定做!

import java.applet.Applet;

import java.awt.Color;

import java.awt.Label;

public class test extends Applet {

private Label label;

@Override

public void init() {

label=new Label("欢迎来到java世界!");

label.setBackground(Color.BLUE);

setBackground(Color.PINK);

add(label);

}

}

===============================第二题==============================

因为没图,所以自己设计的界面..

import java.awt.BorderLayout;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JPanel;

import javax.swing.JScrollPane;

import javax.swing.JTextArea;

public class test implements ActionListener {

private JFrame frame;

private JLabel label;

private JTextArea jt;

private JScrollPane jsp;

private JButton show;

public test() {

frame=new JFrame("Test");

label=new JLabel("显示内容");

jt=new JTextArea(10,20);

jsp=new JScrollPane(jt);

show = new JButton("显示给定内容");

JPanel panel=new JPanel();

panel.add(label);

panel.add(show);

frame.add(jsp,BorderLayout.NORTH);

frame.add(panel,BorderLayout.SOUTH);

show.addActionListener(this);

show();

}

public void show(){

frame.setLocation(200, 200);

frame.setSize(300, 260);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.setVisible(true);

}

@Override

public void actionPerformed(ActionEvent e) {

label.setText(jt.getText());

}

public static void main(String[] args) {

new test().show();

}

}

求文档: java语言程序设计期末题里仁学院

import java.awt.FlowLayout;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JTextField;

public class A implements ActionListener {

JFrame jf;

JLabel jl1;

JLabel jl2;

JLabel jl3;

JButton jb1;

JTextField jtf1;

JTextField jtf2;

JTextField jtf3;

public A(){

init();

showMe();

}

public void init(){

jf=new JFrame("拆分小数点");

jf.setLayout(new FlowLayout());

jl1=new JLabel("请输入小数");

jl2=new JLabel("整数为");

jl3=new JLabel("小数为");

jb1=new JButton("拆分");

jb1.addActionListener(this);

jtf1=new JTextField(10);

jtf2=new JTextField(10);

jtf2.setEditable(false);

jtf3=new JTextField(10);

jtf3.setEditable(false);

jf.add(jl1);

jf.add(jtf1);

jf.add(jl2);

jf.add(jtf2);

jf.add(jl3);

jf.add(jtf3);

jf.add(jb1);

}

public void showMe(){

jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

jf.setVisible(true);

jf.setLocation(300, 300);

jf.pack();

}

@Override

public void actionPerformed(ActionEvent e) {

String comm=e.getActionCommand();

if("拆分".equals(comm)){

String s=jtf1.getText();

System.out.println(s);

if(s.contains(".")){

String[] ss=s.split("\\.");

for (int i = 0; i ss.length; i++) {

System.out.println(ss[i]);

}

jtf2.setText(ss[0]);

jtf3.setText(ss[1]);

}

}

}

public static void main(String[] args) {

new A();

}

}

import java.awt.FlowLayout;

import java.awt.GridLayout;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.util.Arrays;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JPanel;

import javax.swing.JTextField;

public class B implements ActionListener {

public JFrame jf;

private JLabel jl1,jl2,jl3,jl4,jl5,jl6,jl7,jl8,jl9,jl10,jl11,jl12;

private JTextField jtf1,jtf2,jtf3,jtf4,jtf5,jtf6,jtf7,jtf8,jtf9,jtf10,jtf11,jtf12;

private JPanel jp1,jp2,jp3,jp4,jp5,jp6,jp7,jp8,jp9,jp10,jp11,jp12,jp13;

private JButton jb;

public B(){

init();

showMe();

}

public void showMe(){

jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

jf.setVisible(true);

jf.setLocation(300, 300);

jf.pack();

}

public void init(){

jl1=new JLabel("输入第1个数字");

jl2=new JLabel("输入第2个数字");

jl3=new JLabel("输入第3个数字");

jl4=new JLabel("输入第4个数字");

jl5=new JLabel("输入第5个数字");

jl6=new JLabel("输入第6个数字");

jl7=new JLabel("输入第7个数字");

jl8=new JLabel("输入第8个数字");

jl9=new JLabel("输入第9个数字");

jl10=new JLabel("输入第10个数字");

jl11=new JLabel("最大值为");

jl12=new JLabel("最小值为");

jl11.setEnabled(false);

jl12.setEnabled(false);

jtf1=new JTextField(10);

jtf2=new JTextField(10);

jtf3=new JTextField(10);

jtf4=new JTextField(10);

jtf5=new JTextField(10);

jtf6=new JTextField(10);

jtf7=new JTextField(10);

jtf8=new JTextField(10);

jtf9=new JTextField(10);

jtf10=new JTextField(10);

jtf11=new JTextField(10);

jtf11.setEditable(false);

jtf12=new JTextField(10);

jtf12.setEditable(false);

jp1=new JPanel();

jp2=new JPanel();

jp3=new JPanel();

jp4=new JPanel();

jp5=new JPanel();

jp6=new JPanel();

jp7=new JPanel();

jp8=new JPanel();

jp9=new JPanel();

jp10=new JPanel();

jp11=new JPanel();

jp12=new JPanel();

jp13=new JPanel();

jb=new JButton("确定");

jb.addActionListener(this);

jp1.setLayout(new FlowLayout());

jp1.add(jl1);

jp1.add(jtf1);

jp2.setLayout(new FlowLayout());

jp2.add(jl2);

jp2.add(jtf2);

jp3.setLayout(new FlowLayout());

jp3.add(jl3);

jp3.add(jtf3);

jp4.setLayout(new FlowLayout());

jp4.add(jl4);

jp4.add(jtf4);

jp5.setLayout(new FlowLayout());

jp5.add(jl5);

jp5.add(jtf5);

jp6.setLayout(new FlowLayout());

jp6.add(jl6);

jp6.add(jtf6);

jp7.setLayout(new FlowLayout());

jp7.add(jl7);

jp7.add(jtf7);

jp8.setLayout(new FlowLayout());

jp8.add(jl8);

jp8.add(jtf8);

jp9.setLayout(new FlowLayout());

jp9.add(jl9);

jp9.add(jtf9);

jp10.setLayout(new FlowLayout());

jp10.add(jl10);

jp10.add(jtf10);

jp11.setLayout(new FlowLayout());

jp11.add(jl11);

jp11.add(jtf11);

jp12.setLayout(new FlowLayout());

jp12.add(jl12);

jp12.add(jtf12);

jf=new JFrame("最大值最小值");

jf.setLayout(new GridLayout(13, 1));

jf.add(jp1);

jf.add(jp2);

jf.add(jp3);

jf.add(jp4);

jf.add(jp5);

jf.add(jp6);

jf.add(jp7);

jf.add(jp8);

jf.add(jp9);

jf.add(jp10);

jf.add(jp11);

jf.add(jp12);

jf.add(jb);

}

@Override

public void actionPerformed(ActionEvent e) {

String comm=e.getActionCommand();

if("确定".equals(comm)){

int i1=Integer.parseInt(jtf1.getText());

int i2=Integer.parseInt(jtf2.getText());

int i3=Integer.parseInt(jtf3.getText());

int i4=Integer.parseInt(jtf4.getText());

int i5=Integer.parseInt(jtf5.getText());

int i6=Integer.parseInt(jtf6.getText());

int i7=Integer.parseInt(jtf7.getText());

int i8=Integer.parseInt(jtf8.getText());

int i9=Integer.parseInt(jtf9.getText());

int i10=Integer.parseInt(jtf10.getText());

int arr[]=;

Arrays.sort(arr);

int max=arr[9];

int min=arr[0];

jtf11.setText(max+"");

jtf12.setText(min+"");

}

}

public static void main(String[] args) {

new B();

}

}

import java.awt.FlowLayout;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.util.Arrays;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JTextField;

public class C implements ActionListener {

private JFrame jf;

private JLabel jl1,jl2;

private JTextField jtf1,jtf2;

JButton jb1;

public C(){

init();

showMe();

}

public void init(){

jf=new JFrame("字母排序");

jf.setLayout(new FlowLayout());

jl1=new JLabel("请输入字母");

jl2=new JLabel("排序后");

jb1=new JButton("排序");

jb1.addActionListener(this);

jtf1=new JTextField(10);

jtf2=new JTextField(10);

jtf2.setEditable(false);

jf.add(jl1);

jf.add(jtf1);

jf.add(jl2);

jf.add(jtf2);

jf.add(jb1);

}

public void showMe(){

jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

jf.setVisible(true);

jf.setLocation(300, 300);

jf.pack();

}

@Override

public void actionPerformed(ActionEvent e) {

String comm=e.getActionCommand();

if("排序".equals(comm)){

String s=jtf1.getText();

char[] c=new char[s.length()];

if(s.endsWith("#")){

for (int i = 0; i s.length(); i++) {

c[i]=s.charAt(i);

}

}

Arrays.sort(c);

String ss="";

for (int i = 0; i c.length; i++) {

ss=ss+c[i];

}

jtf2.setText(ss.substring(1));

}

}

public static void main(String[] args) {

new C();

}

}

都是有界面的,写界面不难 就是很麻烦。。。我自己写的 都是可以直接运行的,有什么问题可以再问我。。。

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;iname.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程序设计期末代码 java期末项目设计
标题网址:https://www.cdcxhl.com/article14/hjjcge.html

成都网站建设公司_创新互联,为您提供搜索引擎优化标签优化电子商务网站策划ChatGPT定制开发

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

手机网站建设