testgridlayout2.java
来自「Java the UML Way 书中所有源码」· Java 代码 · 共 26 行
JAVA
26 行
/*
* TestGridLayout2.java E.L. 2001-08-18
*
*/
import java.awt.*;
import javax.swing.*;
public class TestGridLayout2 extends JApplet {
public void init() {
Container guiContainer = getContentPane();
guiContainer.setLayout(new GridLayout(2, 5, 5, 5));
/*
* The images have to be in the directory Beans,
* and the files have the names T1.gif, T2.gif, etc.
*/
String nameOfImage = "Beans/T";
for (int imageNo = 1; imageNo <= 10; imageNo++) {
String imageFilname
= nameOfImage.concat(imageNo + ".gif");
ImageIcon icon = new ImageIcon(imageFilname);
JButton button = new JButton(imageFilname, icon);
guiContainer.add(button);
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?