我现在想画一个9*9的棋盘,棋盘用JPanel,gridLayout布局。
如果我调整frame大小,怎样让这个棋盘成比例缩放?1:1
或者应该用什么容器?怎样布局?多谢各位~~!!
如果我调整frame大小,怎样让这个棋盘成比例缩放?1:1
或者应该用什么容器?怎样布局?多谢各位~~!!
解决方案 »
- 一个很简单问题(如何把\转为/)
- apache时间日志的正常转化
- 手机 从 Servlet 下载文件 问题!!急
- this和instanceof 的用法?
- add方法
- 初学者; javamail编写的smtp发送邮件小程序,向163发送邮件失败 求救
- 如何读取文本文件里头的内容并显示出来? 有中文的.
- 如果想掌握JAVA编程的思想,也就是说学好这门语言,JBuider不怎么好,还是用命令行好
- 如何用JAVA实现自动TELENT 到UNIX主机,并调用SHELL程序
- 请问用java写的程序,如一个java写的frame如何用jni技术编译成dll.而在windows下运行.
- 提取文本文件中的文件名称,如何弄比较好
- 请问如何进行图片格式转换bmp,jpg等
public class Frame2 extends JFrame {
JPanel jPanel1 = new JPanel();
BorderLayout borderLayout1 = new BorderLayout();
GridLayout gridLayout1 = new GridLayout(3,3);
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
JButton jButton3 = new JButton();
JButton jButton4 = new JButton();
JButton jButton5 = new JButton();
JButton jButton6 = new JButton();
JButton jButton7 = new JButton();
JButton jButton8 = new JButton();
JButton jButton9 = new JButton(); public Frame2() {
try {
jbInit();
}
catch(Exception ex) {
ex.printStackTrace();
}
} void jbInit() throws Exception {
this.getContentPane().setLayout(borderLayout1);
jPanel1.setLayout(gridLayout1);
jButton1.setText("jButton1");
jButton2.setText("jButton2");
jButton3.setText("jButton3");
jButton4.setText("jButton4");
jButton5.setText("jButton5");
jButton6.setText("jButton6");
jButton7.setText("jButton7");
jButton8.setText("jButton8");
jButton9.setText("jButton9");
this.getContentPane().add(jPanel1, BorderLayout.CENTER);
jPanel1.add(jButton1, null);
jPanel1.add(jButton9, null);
jPanel1.add(jButton8, null);
jPanel1.add(jButton7, null);
jPanel1.add(jButton6, null);
jPanel1.add(jButton5, null);
jPanel1.add(jButton4, null);
jPanel1.add(jButton3, null);
jPanel1.add(jButton2, null);
} public static void main(String[] args) {
Frame2 frame2 = new Frame2();
frame2.setSize(400,300);
frame2.setVisible(true);
}
}