【发布时间】:2014-03-25 04:21:14
【问题描述】:
下面的示例将显示一个带有 jframe 窗口的按钮。我只想要按钮可见,怎么实现?
public final void initUI() {
JPanel panel = new JPanel();
getContentPane().add(panel);
panel.setLayout(null);
JButton quitButton = new JButton("Quit");
quitButton.setBounds(50, 60, 80, 30);
quitButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
System.exit(0);
}
});
panel.add(quitButton);
setTitle("Quit button");
setSize(300, 200);
setLocationRelativeTo(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
【问题讨论】:
-
无框 -> 无按钮
-
+1 哦..那么人们在图像(启动画面、.jpg 等)上显示按钮的常见做法是什么?