package com.itheima;
import javax.swing.*;
public class JFrame07 {
public static void main(String[] args) {
JFrame jf=new JFrame();
jf.setTitle("聊天室");
jf.setSize(400,300);
jf.setDefaultCloseOperation(3);
jf.setLocationRelativeTo(null);
jf.setAlwaysOnTop(true);
jf.setLayout(null); //取消窗体的默认布局
//提示信息
JLabel messagelabel =new JLabel("系统产生了一个1-100之间的数据,请猜一猜");
messagelabel.setBounds(70,50,350,20);
jf.add(messagelabel);
//输入要猜的数字
JTextField numberField = new JTextField();
numberField.setBounds(120,100,150,20);
jf.add(numberField);
//猜数字的按钮
JButton GuessButton = new JButton("我猜");
GuessButton.setBounds(150,150,100,20);
jf.add(GuessButton);
//添加按钮到窗体中
jf.setVisible(true);
}
}
标签:150,JAVA,游戏,GUI,20,add,new,jf,100
From: https://www.cnblogs.com/cy-xt/p/16840096.html