大神看看为啥输入框,也就是jftext,没有显示?
public class Text_1 {
static JFrame jf=new JFrame("题目1演示");
static GridBagLayout gridbag = new GridBagLayout();
static GridBagConstraints c = new GridBagConstraints();
static JTextArea jftext=new JTextArea("请输入一个整数");
static JPanel jp=new JPanel(gridbag);
public static void main(String[] args) {
jf.add(jp);
jf.setSize(400, 400);
jf.setVisible(true);
jftext.setVisible(true);
jp.setVisible(true);
gridbag.setConstraints(jftext, c);
}
}
------解决方案--------------------楼主没把这个jftext添加到pannel中
少了jp.add(jftext);