那位高手能告诉我,我的 Frame 为什么非要在边框上鼠标拉动一下才能看到TextField
和 Button啊?import java.awt.*;
import java.awt.event.*;
public class TestFrame extends Frame
{
TextField txt;
Button but;
public static void main(String[] args)
{
TestFrame TF = new TestFrame();
}
TestFrame()
{
super("我的Frame");
setLayout(new FlowLayout());
setSize(300,400);
setVisible(true);
txt = new TextField(20);
add(txt);
but = new Button("好好学习");
add(but);
addWindowListener(new cls());
}
class cls extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
}
}
和 Button啊?import java.awt.*;
import java.awt.event.*;
public class TestFrame extends Frame
{
TextField txt;
Button but;
public static void main(String[] args)
{
TestFrame TF = new TestFrame();
}
TestFrame()
{
super("我的Frame");
setLayout(new FlowLayout());
setSize(300,400);
setVisible(true);
txt = new TextField(20);
add(txt);
but = new Button("好好学习");
add(but);
addWindowListener(new cls());
}
class cls extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
}
}
解决方案 »
- 新手请教,我重写了Comparable类中的compareTo()这个方法,为什么不能用。
- 小弟想用java做一个文字从下往上滚动的效果,不知道滚动区域用什么文本框,希望大家帮下忙,先谢了
- 2个类如何相互使用对方的方法,急!
- 请问JNA中‘结构体’初始化的问题
- 我在src下的结构一个包是com.cpic.datamove.Path类,还有一个包是abs.Move.xml文件,我在path类里读取Move.xml文件,在elclipse下能够读取,可是打成jar包后用java -jar jarName运行就报系统找
- 请教,关于Graphics2D
- 有用google map的高手来指导下的么?
- 新手算法问题请教!
- 如何获取一个文件的相对路径?(急,在线等待……)
- 我想买一本关于Java类库的书,那本好???
- Frame的使用出现"未初始化小程序"?
- 关于java版ISO8583打包和解包的问题
import java.awt.event.*;
public class TestFrame extends Frame {
TextField txt;
Button but;
public static void main(String[] args) {
TestFrame TF = new TestFrame();
}
TestFrame() {
super( "我的Frame ");
setLayout(new FlowLayout());
setSize(300,400);
txt = new TextField(20);
add(txt);
but = new Button( "好好学习 ");
add(but);
addWindowListener(new cls());
setVisible(true);//组件填加最后才可以设置可见.
}
class cls extends WindowAdapter {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
}
}
frame.pack();//调整窗口大小从而适应组件。
frame.setVisible(true);//显示组件。