Some refactoring
This commit is contained in:
parent
ae0f89df39
commit
55a04fad89
@ -262,7 +262,6 @@
|
|||||||
</NonVisualComponents>
|
</NonVisualComponents>
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name="defaultCloseOperation" type="int" value="3"/>
|
<Property name="defaultCloseOperation" type="int" value="3"/>
|
||||||
<Property name="title" type="java.lang.String" value="SeSim - Stock Exchange Simmulator"/>
|
|
||||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||||
<Dimension value="[640, 480]"/>
|
<Dimension value="[640, 480]"/>
|
||||||
</Property>
|
</Property>
|
||||||
|
@ -30,6 +30,7 @@ import java.awt.Dialog;
|
|||||||
import java.awt.Frame;
|
import java.awt.Frame;
|
||||||
import java.awt.GraphicsDevice;
|
import java.awt.GraphicsDevice;
|
||||||
import java.awt.GraphicsEnvironment;
|
import java.awt.GraphicsEnvironment;
|
||||||
|
import java.awt.Window;
|
||||||
import java.awt.event.WindowAdapter;
|
import java.awt.event.WindowAdapter;
|
||||||
import java.awt.event.WindowEvent;
|
import java.awt.event.WindowEvent;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -40,6 +41,7 @@ import java.util.Scanner;
|
|||||||
import java.util.prefs.Preferences;
|
import java.util.prefs.Preferences;
|
||||||
import javax.swing.JDialog;
|
import javax.swing.JDialog;
|
||||||
import javax.swing.JFileChooser;
|
import javax.swing.JFileChooser;
|
||||||
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import static javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER;
|
import static javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER;
|
||||||
|
|
||||||
@ -65,34 +67,28 @@ public class SeSimApplication extends javax.swing.JFrame {
|
|||||||
|
|
||||||
initComponents();
|
initComponents();
|
||||||
|
|
||||||
|
// Get default screen and place our window
|
||||||
|
// to the center of this screen
|
||||||
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||||
GraphicsDevice[] screens = ge.getScreenDevices();
|
GraphicsDevice d = ge.getDefaultScreenDevice();
|
||||||
|
Window w = d.getFullScreenWindow();
|
||||||
//Window w = screens[1].getFullScreenWindow();
|
setLocationRelativeTo(w);
|
||||||
|
|
||||||
// JFrame dummy = new JFrame(screens[1].getDefaultConfiguration());
|
|
||||||
|
|
||||||
// setLocationRelativeTo(dummy);
|
|
||||||
// dummy.dispose();
|
|
||||||
|
|
||||||
for (GraphicsDevice gd:screens){
|
|
||||||
//Window w = gd.getFullScreenWindow();
|
|
||||||
|
|
||||||
|
|
||||||
|
// Set Application title (no file is currently opened)
|
||||||
|
setTitleWithFileName("");
|
||||||
|
|
||||||
}
|
// check if are runing the very first time,
|
||||||
|
// and if: Load a default configuration from our resources
|
||||||
|
|
||||||
|
|
||||||
setTitle("");
|
|
||||||
boolean init = Globals.prefs.getBoolean("initilized", false);
|
boolean init = Globals.prefs.getBoolean("initilized", false);
|
||||||
if (!init){
|
if (!init){
|
||||||
resetToDefaults();
|
resetToDefaults();
|
||||||
Globals.prefs.putBoolean("initilized", true);
|
Globals.prefs.putBoolean("initilized", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.chartSrollPane.setVerticalScrollBarPolicy(VERTICAL_SCROLLBAR_NEVER);
|
this.chartSrollPane.setVerticalScrollBarPolicy(VERTICAL_SCROLLBAR_NEVER);
|
||||||
|
|
||||||
//this.setLocationRelativeTo(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AutoTraderInterface createTrader(Exchange se, long id, String name, double money, double shares, JSONObject cfg) {
|
AutoTraderInterface createTrader(Exchange se, long id, String name, double money, double shares, JSONObject cfg) {
|
||||||
@ -235,7 +231,6 @@ public class SeSimApplication extends javax.swing.JFrame {
|
|||||||
jSplitPane1.setTopComponent(jSplitPane2);
|
jSplitPane1.setTopComponent(jSplitPane2);
|
||||||
|
|
||||||
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
||||||
setTitle("SeSim - Stock Exchange Simmulator");
|
|
||||||
setMinimumSize(new java.awt.Dimension(640, 480));
|
setMinimumSize(new java.awt.Dimension(640, 480));
|
||||||
|
|
||||||
stopButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/icons/stop.gif"))); // NOI18N
|
stopButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/icons/stop.gif"))); // NOI18N
|
||||||
@ -668,7 +663,7 @@ public class SeSimApplication extends javax.swing.JFrame {
|
|||||||
String workdir = fc.getCurrentDirectory().getAbsolutePath();
|
String workdir = fc.getCurrentDirectory().getAbsolutePath();
|
||||||
Globals.prefs.put(Globals.PrefKeys.WORKDIR, workdir);
|
Globals.prefs.put(Globals.PrefKeys.WORKDIR, workdir);
|
||||||
Globals.prefs.put(Globals.PrefKeys.CURRENTFILE, f.getAbsolutePath());
|
Globals.prefs.put(Globals.PrefKeys.CURRENTFILE, f.getAbsolutePath());
|
||||||
setTitle(f.getName());
|
setTitleWithFileName(f.getName());
|
||||||
return;
|
return;
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
@ -690,14 +685,14 @@ public class SeSimApplication extends javax.swing.JFrame {
|
|||||||
return fc;
|
return fc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public final void setTitle(String filename) {
|
public final void setTitleWithFileName(String filename) {
|
||||||
String name;
|
String name;
|
||||||
name = Globals.SESIM_APPTITLE;
|
name = Globals.SESIM_APPTITLE;
|
||||||
if (!"".equals(filename)) {
|
if (!"".equals(filename)) {
|
||||||
name += " (" + filename + ")";
|
name += " (" + filename + ")";
|
||||||
}
|
}
|
||||||
super.setTitle(name);
|
setTitle(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveFile(boolean saveAs) {
|
private void saveFile(boolean saveAs) {
|
||||||
@ -751,7 +746,7 @@ public class SeSimApplication extends javax.swing.JFrame {
|
|||||||
try {
|
try {
|
||||||
Globals.saveFile(f);
|
Globals.saveFile(f);
|
||||||
Globals.prefs.put(Globals.PrefKeys.CURRENTFILE, fn);
|
Globals.prefs.put(Globals.PrefKeys.CURRENTFILE, fn);
|
||||||
setTitle(f.getName());
|
setTitleWithFileName(f.getName());
|
||||||
return;
|
return;
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
@ -784,7 +779,8 @@ public class SeSimApplication extends javax.swing.JFrame {
|
|||||||
try {
|
try {
|
||||||
Globals.loadString(df);
|
Globals.loadString(df);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
JOptionPane.showMessageDialog(this, "Can't load file: " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(this,
|
||||||
|
"Can't load file: " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -875,7 +871,7 @@ public class SeSimApplication extends javax.swing.JFrame {
|
|||||||
|
|
||||||
private void closeMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeMenuItemActionPerformed
|
private void closeMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeMenuItemActionPerformed
|
||||||
Globals.prefs.put(Globals.PrefKeys.CURRENTFILE, "");
|
Globals.prefs.put(Globals.PrefKeys.CURRENTFILE, "");
|
||||||
setTitle("");
|
setTitleWithFileName("");
|
||||||
}//GEN-LAST:event_closeMenuItemActionPerformed
|
}//GEN-LAST:event_closeMenuItemActionPerformed
|
||||||
|
|
||||||
private void clearMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clearMenuItemActionPerformed
|
private void clearMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clearMenuItemActionPerformed
|
||||||
@ -926,14 +922,14 @@ public class SeSimApplication extends javax.swing.JFrame {
|
|||||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
System.out.printf("In run method now\n");
|
|
||||||
|
|
||||||
String x = new java.io.File(SeSimApplication.class.getProtectionDomain()
|
|
||||||
|
/* String x = new java.io.File(SeSimApplication.class.getProtectionDomain()
|
||||||
.getCodeSource()
|
.getCodeSource()
|
||||||
.getLocation()
|
.getLocation()
|
||||||
.getPath()).toString(); //.getName();
|
.getPath()).toString(); //.getName();
|
||||||
|
*/
|
||||||
System.out.printf("Creating Application\n");
|
// System.out.printf("Creating Application\n");
|
||||||
|
|
||||||
new SeSimApplication().setVisible(true);
|
new SeSimApplication().setVisible(true);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user