Added new MenuItem to save a decompiled file. Main window now will be

centered on startup


git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@1376 379699f6-c40d-0410-875b-85095c16579e
master
seeksthemoon 22 years ago
parent 0c1d7a4b7c
commit c53a8d1acf
  1. 5
      jode/ChangeLog
  2. 65
      jode/src/net/sf/jode/swingui/Main.java

@ -1,3 +1,8 @@
2003-06-11 Mark Morschhäuser <mark.morschhaeuser@firemail.de>
* net/sf/jode/decompiler/Main.java: New MenuItem to save a decompiled file.
* net/sf/jode/decompiler/Main.java: Main-window will be centered on startup
2002-06-11 Jochen Hoenicke <jochen@gnu.org> 2002-06-11 Jochen Hoenicke <jochen@gnu.org>
* net/sf/jode/decompiler/Main.java: New option keep-alive. With * net/sf/jode/decompiler/Main.java: New option keep-alive. With

@ -34,6 +34,7 @@ import java.awt.event.*;
import java.io.*; import java.io.*;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.ResourceBundle; import java.util.ResourceBundle;
import java.util.*;
public class Main public class Main
implements ActionListener, Runnable, TreeSelectionListener { implements ActionListener, Runnable, TreeSelectionListener {
@ -49,6 +50,7 @@ public class Main
ClassPathDialog classPathDialog; ClassPathDialog classPathDialog;
JProgressBar progressBar; JProgressBar progressBar;
private JMenuItem saveMenuItem;
boolean hierarchyTree; boolean hierarchyTree;
@ -84,10 +86,28 @@ public class Main
} }
}); });
frame.pack(); frame.pack();
this.center();
}
public void center() {
//center window
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = frame.getSize();
if (frameSize.height > screenSize.height) {
frameSize.height = screenSize.height;
}
if (frameSize.width > screenSize.width) {
frameSize.width = screenSize.width;
}
frame.setLocation((screenSize.width - frameSize.width) / 2,
(screenSize.height - frameSize.height) / 2);
} }
public void show() { public void show() {
frame.show(); frame.setVisible(true);
} }
public void fillContentPane(Container contentPane) { public void fillContentPane(Container contentPane) {
@ -163,6 +183,7 @@ public class Main
progressBar.setString(bundle.getString("main.decompiling")); progressBar.setString(bundle.getString("main.decompiling"));
progressBar.setStringPainted(true); progressBar.setStringPainted(true);
decompileThread.start(); decompileThread.start();
this.saveMenuItem.setEnabled(true);
} }
} }
@ -262,6 +283,48 @@ public class Main
JMenuItem item; JMenuItem item;
menu = new JMenu(bundle.getString("menu.file")); menu = new JMenu(bundle.getString("menu.file"));
menu.setMnemonic('f'); menu.setMnemonic('f');
this.saveMenuItem = new JMenuItem(bundle.getString("menu.save"));
this.saveMenuItem.setMnemonic('s');
this.saveMenuItem.setEnabled(false);
this.saveMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) {
JFileChooser chooser = new JFileChooser();
try {
if (JFileChooser.APPROVE_OPTION != chooser.showSaveDialog(
new Container())) {
return; //cancelled
}
} catch (Exception he) {
return;
}
//save file
File saveFile = new File(chooser.getSelectedFile()
.getAbsoluteFile().toString());
FileOutputStream out; // declare a file output object
PrintStream p; // declare a print stream object
try {
// Create a new file output stream
out = new FileOutputStream(saveFile);
// Connect print stream to the output stream
p = new PrintStream(out);
p.print(sourcecodeArea.getText());
p.close();
} catch (Exception e) {
errorArea.setText(bundle.getString("menu.save.ex"));
}
}
});
menu.add(this.saveMenuItem);
menu.add(new JSeparator());
item = new JMenuItem(bundle.getString("menu.file.gc")); item = new JMenuItem(bundle.getString("menu.file.gc"));
item.setMnemonic('c'); item.setMnemonic('c');
item.addActionListener(new ActionListener() { item.addActionListener(new ActionListener() {

Loading…
Cancel
Save