import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.image.BufferedImage;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class Main {
public static void main(String[] args) {
JPanel gui = new JPanel(new BorderLayout(2, 2));
BufferedImage bi = new BufferedImage(600, 200, BufferedImage.TYPE_INT_RGB);
gui.add(new JLabel(new ImageIcon(bi)));
JFrame myframe = new JFrame();
JPanel myPanel = new JPanel();
gui.add(myPanel, BorderLayout.PAGE_END);
myPanel.setLayout(new GridLayout(2, 0, 0, 0));
int x = 0;
int y = 5;
for (char alphabet = ‘A’; alphabet <= ‘Z’; alphabet++) {
myPanel.add(new JButton(alphabet + “”));
x++;
if (x > 15) {
y = 6;
x = 0;
}
}
myframe.add(gui);
myframe.pack();
myframe.setVisible(true);
myframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/195812.html原文链接:https://javaforall.cn