Java中,定义了JFrame和JTextField,将JTextField加到了JFrame的容器中,但是为什么在JFrame中不现实JTex
importjavax.swing.*;importjava.awt.*;publicclassMytest12040907extendsJFrame{publicMyt...
import javax.swing.*;
import java.awt.*;
public class Mytest12040907 extends JFrame {
public Mytest12040907 (){
setVisible(true);
setSize(320,200);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
setResizable(false);
setTitle("计算器");
Container container=getContentPane();
container.setLayout(new FlowLayout());
JTextField jt=new JTextField("00000",20);
jt.setEnabled(false);
jt.setEditable(false);
jt.setFont(new Font("Dialog",Font.PLAIN,18));
jt.setHorizontalAlignment(SwingConstants.CENTER);
container.add(jt);
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
new Mytest12040907();
}
} 展开
import java.awt.*;
public class Mytest12040907 extends JFrame {
public Mytest12040907 (){
setVisible(true);
setSize(320,200);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
setResizable(false);
setTitle("计算器");
Container container=getContentPane();
container.setLayout(new FlowLayout());
JTextField jt=new JTextField("00000",20);
jt.setEnabled(false);
jt.setEditable(false);
jt.setFont(new Font("Dialog",Font.PLAIN,18));
jt.setHorizontalAlignment(SwingConstants.CENTER);
container.add(jt);
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
new Mytest12040907();
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询