求java的编程答案,我会加分的~~~

编写一个Application,创建并显示一个200*100的Frame,该Frame的标题为:”Hello”。向Frame容器中添加一个标签为”Press Me”的按钮。编写代码,使得按钮被点击后,系统输出”您好! 欢迎进入Java世界!”字符串。要求程序能够处理窗口的关闭,正常退出。

附:可能用到的工具:
WindowListener接口中包括的方法定义:
public void windowClosing(WindowEvent e);
public void windowOpened(WindowEvent e);
public void windowIconified(WindowEvent e);
public void windowDeiconified(WindowEvent e);
public void windowClosed(WindowEvent e);
public void windowActivated(WindowEvent e);
public void windowDeactivated(WindowEvent e);

ActionListener接口中包括的方法定义:
public void actionPerformed(ActionEvent e);

import javax.swing.*;
import java.awt.event.*;

class baidu extends JFrame{
JButton btnPressMe;
public baidu(){
super("Hello");
this.setLayout(null);

btnPressMe=new JButton("press me");
btnPressMe.setSize(100,30);
btnPressMe.addActionListener(new pressMe());
this.add(btnPressMe);

this.setSize(200, 200);
this.addWindowListener(new winClose());
this.setVisible(true);

}

public static void main(String[] args){
new baidu();
}

class pressMe implements ActionListener{
public void actionPerformed(ActionEvent ae){ /*响应单击事件*/
JOptionPane.showMessageDialog(null,"你好,欢迎进入Java世界!"); /*弹出对话框显示*/
}
}
class winClose implements WindowListener{
public void windowClosing(WindowEvent we){ /*响应windows窗体关闭事件*/
System.exit(0);
}
public void windowOpened(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public void windowClosed(WindowEvent e){}
public void windowActivated(WindowEvent e){}
public void windowDeactivated(WindowEvent e){}
}

}
温馨提示:内容为网友见解,仅供参考
无其他回答

java编程题 本人新手,求详解。
先看下最终的结果吧,是不是你想要的?项目结构如下图所示:其中,Student是父类,PostGraduate是子类,继承自父类Student,Main是主类,用于创建对象以及把这些对象的功能调用起来。---Student代码如下:--- \/ 学生类 author 逍遥 \/ public class Student { \/\/学号 private int sId;\/\/姓名 private ...

JAVA程序设计题解答,加分50
Staff该java Bean 有4个职员基本的信息 并且提供了设置和得到该职员信息的基本方法 author pisa \/ public class Staff { private String name; \/\/职员姓名 private Integer age; \/\/职员年龄 private String sex; \/\/职员性别 private String position;\/\/职员职位 public String getName() { ...

jAVA编程大神求帮忙
public class BasicTest {public static void main(String[] args) {int x=10;number(x);\/\/传入>0的值!x=-1;number(x);\/\/传入<0的值!x=0;number(x);\/\/传入=0的值!}\/\/判断方法!public static void number(int x) {int y;if(x>0)\/\/如果x大于0y=3*x+5;else if(x<0)\/\/否...

有没有大佬解决下java编程的问题,求
\/\/利用数组的排序功能将输入的10个数从小到大排序 \/\/最大的数就是数组最后一个数 \/\/最小的数就是数组第一个数

加分哦!编写java程序,计算0-10中每个整数的平方和立方,并将结果以如...
public static void main(String[] args){ System.out.println("number"+" square"+" cube"); \/\/ 结果0 for(int i=0;i<11;i++){ String fi = " ";String se = " ";if(i>=10){ fi = " ";} if(i*i>=10&&i*i<100){ se = " ";} if(i*i>=100...

JAVA编程,在线等答案
Number fraction;Number complex;Override protected void setUp() throws Exception { fraction=new Fraction(5,3);complex=new Complex(3,4);} Override protected void tearDown() throws Exception { fraction=null;complex=null;} public void testFractionCompare(){ assertEquals(0.6, fraction.get...

高分JAVA高手进~还会加分
import java.sql.PreparedStatement;public class TestStudent extends JFrame implements ActionListener { JTable table;Object a[][];Object name[] = { "学号","姓名" };JButton query, insert, update, delete;JTextField sno, sname;int rows = 1;JPanel p;TestStudent(String s){ super(s...

java题,请求解答,谢谢!发了好几遍了,会采纳求解答?
import java.util.Scanner;public class StudentTest { public static void main(String[] args) { int score = 0;String[] oprArr = { "+", "-", "*", "\/" };System.out.println("***小学生20以内加减乘除法模拟系统***");System.out.println();Scanner in = new Scanner(System....

java编程 求代码 4-6
public class Staff {public static void main(String[] args) throws Exception {String hellostr = "Hello World And You 123456!!!";\/\/(1)System.out.println("length : " + hellostr.length());\/\/(2)String[] helloary = hellostr.split(" ");System.out.println("Split by spacebar...

java入门编程作业思考题,求大神给程序,谢谢
public class LoveStory { public static void main(String[] args) { String question = "老婆,你爱我吗?"; String answer = ""; Scanner scan = new Scanner(System.in); while(true){ System.out.println(question); answer = scan.nextLine(); if("爱".equals...

相似回答