我需要制作一个程序,将我的图像保存在特定位置,而不会在我更改屏幕分辨率时四处移动。
public KinderDrum(){
setSize(1000,500);
setTitle("Drum");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setExtendedState(Frame.MAXIMIZED_BOTH);
setUndecorated(true);
setLayout(new BorderLayout());
JButton button = new JButton("Exit");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
getContentPane().add(button, BorderLayout.NORTH);
p1 = new JPanel();
p1.setLayout(new FlowLayout());
ImageIcon img = new ImageIcon("C:\\Drum\\Word.png");
jlblImage = new JLabel(img);
p1.add(jlblImage);
add(jlblImage);
jlblImage.setSize(jlblImage.getPreferredSize());
jlblImage.setLocation(300, 550);