一些有趣的图形界面
2015-11-20 16:29
169 查看
代码:
运行结果:
import java.awt.Color; import java.awt.GridLayout; import javax.swing.JButton; import javax.swing.JFrame; public class MyFrame extends JFrame { public MyFrame() { setLayout(new GridLayout(8,8,0,0)); setTitle("鬼谷子的局"); setSize(800,800); setVisible(true); setDefaultCloseOperation(EXIT_ON_CLOSE); JButton []Bu=new JButton [64]; for(int i=0;i<8;i++) { for(int j=0;j<8;j++) { Bu[i]=new JButton(); if((i+j)%2==0) { Bu[i].setBackground(Color.black); Bu[i].setForeground(Color.blue); Bu[i].setText((i+1)+"行"+(j+1)+"列"); } else { Bu[i].setBackground(Color.white); Bu[i].setForeground(Color.blue); Bu[i].setText((i+1)+"行"+(j+1)+"列"); } add(Bu[i]); } } setVisible(true); } public static void main(String[] args) { MyFrame F=new MyFrame(); } }
运行结果:
相关文章推荐
- ArrayList、Vector、LinkedList学习例子
- Java学习笔记——基础篇
- “wsimport -keep ”生成客户端报错“Use of SOAP Encoding is not supported.”
- Nohup命令
- QT.Debug设置断点无效
- mybatis调用oracle存储过程
- UITextView在光标处插入字符串
- codeforces 543C C. Remembering Strings
- WebRTC手记Channel概念
- Eclipse links方式安装插件
- iOS 表视图的分区头部文字设置
- sharesdk分享链接到qq空间平台出处显示错误
- HDFS HA与QJM[官网整理]
- Android SimpleCursorAdapter的使用
- C++快速排序
- 【样式的参数单位】
- Oracle (内连接)
- [AlwaysOn Availability Groups]排查:AG超过RTO
- Path Sum
- extern"c"总结