带有setUndergrated true的java JFrame
使用setUndercorated = true
,如何使用退出按钮退出窗口
public static void main(String[] args) {
JLabel label = new JLabel("My label");
label.setText("Wello!");
JFrame f = new JFrame();
f.setUndecorated(true);
f.setAlwaysOnTop(true);
f.setResizable(false);
try {
f.setContentPane(new JLabel(new ImageIcon(ImageIO.read(new File("file")))));
} catch (IOException e) {
e.printStackTrace();**strong text**
}
f.pack();
f.setVisible(true);
}
}
# 1 楼答案
您需要将自己的退出按钮添加到面板:
这将导致JFrame看起来像:
当您单击该按钮时,它将关闭JFrame