Jacky Kuo
November 25th, 2004, 10:29 PM
:(
Hi,
I wrote a program using JDesktopPane to open multiple documents,
it wiil new a class (chart.java) and open it(JInternalFrame), this is a charting window.
If I open multiple charting windows, the variables, functions... in the chart.java would be shared between the 2 charting windows, So my charting would got something wrong, such as I do something in A charting windows, then the same result I would get in both the 2 charting windows, This is not waht I want.
public class jWindowFrame extends JFrame {
JMenuBar menuBar;
JDesktopPane desktop;
static final Integer DOCLAYER = new Integer(5);
public void newDocument() {
JInternalFrame doc = new chart();
desktop.add(doc, DOCLAYER);
try {
doc.setVisible(true);
doc.setSelected(true);
} catch (Exception e2) {}
}
public void quit() {
try
{
System.exit(0);
}
catch (Exception ex) {}
}
protected JMenu buildFileMenu() {
JMenu file = new JMenu("file");
JMenuItem newWin = new JMenuItem("new doc");
newWin.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
newDocument();
}
});
file.add(newWin);
return file;
}
protected void buildMenus() {
menuBar = new JMenuBar();
menuBar.setOpaque(true);
JMenu file = buildFileMenu();
menuBar.add(file);
}
protected void buildContent() {
desktop = new JDesktopPane();
getContentPane().add(desktop);
}
public jWindowFrame() {
buildContent();
buildMenus();
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
quit();
}
});
}
}
Hi,
I wrote a program using JDesktopPane to open multiple documents,
it wiil new a class (chart.java) and open it(JInternalFrame), this is a charting window.
If I open multiple charting windows, the variables, functions... in the chart.java would be shared between the 2 charting windows, So my charting would got something wrong, such as I do something in A charting windows, then the same result I would get in both the 2 charting windows, This is not waht I want.
public class jWindowFrame extends JFrame {
JMenuBar menuBar;
JDesktopPane desktop;
static final Integer DOCLAYER = new Integer(5);
public void newDocument() {
JInternalFrame doc = new chart();
desktop.add(doc, DOCLAYER);
try {
doc.setVisible(true);
doc.setSelected(true);
} catch (Exception e2) {}
}
public void quit() {
try
{
System.exit(0);
}
catch (Exception ex) {}
}
protected JMenu buildFileMenu() {
JMenu file = new JMenu("file");
JMenuItem newWin = new JMenuItem("new doc");
newWin.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
newDocument();
}
});
file.add(newWin);
return file;
}
protected void buildMenus() {
menuBar = new JMenuBar();
menuBar.setOpaque(true);
JMenu file = buildFileMenu();
menuBar.add(file);
}
protected void buildContent() {
desktop = new JDesktopPane();
getContentPane().add(desktop);
}
public jWindowFrame() {
buildContent();
buildMenus();
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
quit();
}
});
}
}