import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class getHtmlForm implements MouseListener{
JFrame frame=new JFrame("欢迎光临");
Container cp=frame.getContentPane();
JLabel label1=new JLabel("请输入您要抓取网页的内容的网址:");
JTextField txt1=new JTextField();
JButton b=new JButton( "输出:");
public getHtmlForm(){
cp.setLayout(new FlowLayout());
cp.add(label1);
cp.add(txt1);
cp.setBackground(Color.BLUE);
txt1.setColumns(10);
b.addMouseListener(this);
cp.add(b);
frame.setVisible(true);
frame.setSize(500,500);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String args[]){
new getHtmlForm();
}
public void mouseClicked(MouseEvent e){
System.out.println(txt1.getText());
}
public void mouseEntered(MouseEvent e){}
public void mouseExited(MouseEvent e){}
public void mousePressed(MouseEvent e){}
public void mouseReleased(MouseEvent e){}}
这个我想最后把文本框中的内容在窗口上输出而不是输出在控制台 该怎么修改啊?
import java.awt.*;
import java.awt.event.*;
public class getHtmlForm implements MouseListener{
JFrame frame=new JFrame("欢迎光临");
Container cp=frame.getContentPane();
JLabel label1=new JLabel("请输入您要抓取网页的内容的网址:");
JTextField txt1=new JTextField();
JButton b=new JButton( "输出:");
public getHtmlForm(){
cp.setLayout(new FlowLayout());
cp.add(label1);
cp.add(txt1);
cp.setBackground(Color.BLUE);
txt1.setColumns(10);
b.addMouseListener(this);
cp.add(b);
frame.setVisible(true);
frame.setSize(500,500);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String args[]){
new getHtmlForm();
}
public void mouseClicked(MouseEvent e){
System.out.println(txt1.getText());
}
public void mouseEntered(MouseEvent e){}
public void mouseExited(MouseEvent e){}
public void mousePressed(MouseEvent e){}
public void mouseReleased(MouseEvent e){}}
这个我想最后把文本框中的内容在窗口上输出而不是输出在控制台 该怎么修改啊?
解决方案 »
- 急!!!!!!请问:如何弹出窗口,关闭系统窗口?? 急!!!!!!急!!!!!!急!!!!!!急!!!!!!急!!!!!!急!!!!!!急!!!!!!
- 小生想买本书学习操作系统,不知道哪本书好~~
- 收集java的常用函数代码!大家分享,共同学习!请分享者到此接分[续三]!
- 日期分隔问题+分隔符问题~急急急
- javascript调用ocx控件时的参数传递问题
- 超级郁闷的问题,难道你们都没遇到过?##模式对话框的问题,请进!
- jdbc_odbc问题
- JAVA真的不能做一个很好的木马吗?
- 程序编好了,如何让它在其它机器上运行?
- 关于在application中(不是applet)用MediaTracker读图片的问题,高分酬谢。
- 为什么我点击标签,背景颜色不变化啊?请大吓帮忙碌!
- 这样在外部定义对象有问题吗?
JFrame frame = new JFrame("欢迎光临");
Container cp = frame.getContentPane();
JLabel label1 = new JLabel("请输入您要抓取网页的内容的网址:");
JTextField txt1 = new JTextField();
JButton b = new JButton("输出:");
JLabel label = new JLabel(); public getHtmlForm() {
cp.setLayout(new FlowLayout());
cp.add(label1);
cp.add(txt1);
cp.setBackground(Color.BLUE);
txt1.setColumns(10);
b.addMouseListener(this);
cp.add(b);
cp.add(label);
frame.setVisible(true);
frame.setSize(500, 500);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
} public static void main(String args[]) {
new getHtmlForm();
} public void mouseClicked(MouseEvent e) {
System.out.println(txt1.getText());
label.setText(txt1.getText());
}
}