该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
package soft1331;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
class GridLayoutDemo extends JFrame
{
GridLayoutDemo()
{
JPanel jp=new JPanel();
jp.setLayout(new GridLayout(4,4));
for(int i=9;i>=0;i--)
{
String s=(new Integer(i)).toString();
JButton jb=new JButton(s);
jp.add(jb);
}
jp.add(new JButton("+"));
jp.add(new JButton("-"));
jp.add(new JButton("*"));
jp.add(new JButton("/"));
jp.add(new JButton("."));
jp.add(new JButton("="));
add(jp);
add(new JTextField(10),BorderLayout.NORTH);
}
}
public class hello {
public static void main(String[]args)
{GridLayoutDemo f=new GridLayoutDemo();
f.setTitle("你猜猜");
f.setSize(250,180);
f.setLocation(400,300);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
}
}