如何在我的應用程序中使用java.util.Properties文件記住它上一次的狀態。我想我的應用程序在相同的位置和大小相同打開,因爲它有它什麼時候被closed.This是我的代碼部分:當打開窗口時,是否可以使用java.util.Properties-files來設置窗口大小?
private static void createAndShowGUI() {
JFrame.setDefaultLookAndFeelDecorated(true);
JFrame frame = new JFrame("Infinity");
v demo = new v();
frame.setContentPane(demo.createContentPane());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setSize(new Dimension(740, 480));
frame.setVisible(true);
}
public static void main(String[] args) {
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
SwingUtilities.invokeLater(new Runnable() {
public void run() {
Properties prop = new Properties();
// add some properties
prop.setProperty("Height", "200");
prop.put("Width", "1500");
// print the list
try {
// store the properties list in an output stream
prop.store(System.out, "PropertiesDemo");
} catch (IOException ex) {
ex.printStackTrace();
}
createAndShowGUI();
}
});
}}
你試過了嗎? – Sinkingpoint
是的,我上傳我的代碼 – user3061922