215 lines
7.5 KiB
Java
215 lines
7.5 KiB
Java
/*
|
|
* To change this license header, choose License Headers in Project Properties.
|
|
* To change this template file, choose Tools | Templates
|
|
* and open the template in the editor.
|
|
*/
|
|
package Gui;
|
|
|
|
import SeSim.Exchange;
|
|
import SeSim.BuyOrder;
|
|
import javax.swing.UIManager;
|
|
import javax.swing.*;
|
|
|
|
/**
|
|
*
|
|
* @author 7u83 <7u83@mail.ru>
|
|
*/
|
|
public class MainWin extends javax.swing.JFrame {
|
|
|
|
static SeSim.Exchange se;
|
|
|
|
/**
|
|
* Creates new form MainWin
|
|
*/
|
|
public MainWin() {
|
|
|
|
initComponents();
|
|
}
|
|
|
|
/**
|
|
* This method is called from within the constructor to initialize the form.
|
|
* WARNING: Do NOT modify this code. The content of this method is always
|
|
* regenerated by the Form Editor.
|
|
*/
|
|
@SuppressWarnings("unchecked")
|
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
|
private void initComponents() {
|
|
|
|
jButton1 = new javax.swing.JButton();
|
|
jMenuItem1 = new javax.swing.JMenuItem();
|
|
jLabel1 = new javax.swing.JLabel();
|
|
jLabel2 = new javax.swing.JLabel();
|
|
orderBook1 = new Gui.OrderBook();
|
|
controlPanel2 = new Gui.ControlPanel();
|
|
chart1 = new Gui.Chart();
|
|
MainMenu = new javax.swing.JMenuBar();
|
|
FileMenu = new javax.swing.JMenu();
|
|
FileNew = new javax.swing.JMenuItem();
|
|
FileRun = new javax.swing.JMenuItem();
|
|
jMenu2 = new javax.swing.JMenu();
|
|
|
|
jButton1.setText("jButton1");
|
|
jButton1.addActionListener(new java.awt.event.ActionListener() {
|
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
jButton1ActionPerformed(evt);
|
|
}
|
|
});
|
|
|
|
jMenuItem1.setText("jMenuItem1");
|
|
|
|
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
|
setMinimumSize(new java.awt.Dimension(640, 480));
|
|
|
|
jLabel1.setText("jLabel1");
|
|
getContentPane().add(jLabel1, java.awt.BorderLayout.LINE_START);
|
|
|
|
jLabel2.setText("jLabel2");
|
|
getContentPane().add(jLabel2, java.awt.BorderLayout.CENTER);
|
|
getContentPane().add(orderBook1, java.awt.BorderLayout.PAGE_END);
|
|
getContentPane().add(controlPanel2, java.awt.BorderLayout.LINE_END);
|
|
|
|
javax.swing.GroupLayout chart1Layout = new javax.swing.GroupLayout(chart1);
|
|
chart1.setLayout(chart1Layout);
|
|
chart1Layout.setHorizontalGroup(
|
|
chart1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
.addGap(0, 273, Short.MAX_VALUE)
|
|
);
|
|
chart1Layout.setVerticalGroup(
|
|
chart1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
.addGap(0, 151, Short.MAX_VALUE)
|
|
);
|
|
|
|
getContentPane().add(chart1, java.awt.BorderLayout.CENTER);
|
|
|
|
FileMenu.setBackground(new java.awt.Color(254, 203, 1));
|
|
FileMenu.setText("File");
|
|
|
|
FileNew.setText("New");
|
|
FileNew.setBorder(null);
|
|
FileNew.addActionListener(new java.awt.event.ActionListener() {
|
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
FileNewActionPerformed(evt);
|
|
}
|
|
});
|
|
FileMenu.add(FileNew);
|
|
|
|
FileRun.setText("Run");
|
|
FileRun.addActionListener(new java.awt.event.ActionListener() {
|
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
FileRunActionPerformed(evt);
|
|
}
|
|
});
|
|
FileMenu.add(FileRun);
|
|
|
|
MainMenu.add(FileMenu);
|
|
|
|
jMenu2.setText("Edit");
|
|
MainMenu.add(jMenu2);
|
|
|
|
setJMenuBar(MainMenu);
|
|
|
|
pack();
|
|
}// </editor-fold>//GEN-END:initComponents
|
|
|
|
private void FileNewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_FileNewActionPerformed
|
|
System.out.print("Menu 0 called\n");
|
|
|
|
}//GEN-LAST:event_FileNewActionPerformed
|
|
|
|
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
|
|
// TODO add your handling code here:
|
|
}//GEN-LAST:event_jButton1ActionPerformed
|
|
|
|
private void FileRunActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_FileRunActionPerformed
|
|
se.start();
|
|
}//GEN-LAST:event_FileRunActionPerformed
|
|
|
|
/**
|
|
* @param args the command line arguments
|
|
*/
|
|
public static void main(String args[]) {
|
|
|
|
se = new Exchange();
|
|
|
|
SeSim.BuyOrder bo = new SeSim.BuyOrder();
|
|
bo.limit = 20.0;
|
|
bo.volume = 12;
|
|
bo.timestamp = 12;
|
|
se.SendOrder(bo);
|
|
|
|
SeSim.BuyOrder bo1 = new SeSim.BuyOrder();
|
|
bo1.limit = 27.0;
|
|
bo1.volume = 123;
|
|
bo1.timestamp = 922;
|
|
se.SendOrder(bo1);
|
|
|
|
for (int i = 0; i < 130; i++) {
|
|
BuyOrder o = new BuyOrder();
|
|
o.volume = 90 + i;
|
|
o.limit = 80 + i;
|
|
se.SendOrder(o);
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
// Set cross-platform Java L&F (also called "Metal")
|
|
UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
|
|
}
|
|
catch (UnsupportedLookAndFeelException | ClassNotFoundException | InstantiationException | IllegalAccessException e) {
|
|
System.out.print("Alles muell\n");
|
|
}
|
|
// handle exception
|
|
// handle exception
|
|
// handle exception
|
|
|
|
|
|
/* Set the Nimbus look and feel */
|
|
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
|
|
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
|
|
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
|
|
*/
|
|
/* try {
|
|
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
|
|
if ("Motif".equals(info.getName())) {
|
|
javax.swing.UIManager.setLookAndFeel(info.getClassName());
|
|
break;
|
|
}
|
|
}
|
|
} catch (ClassNotFoundException ex) {
|
|
java.util.logging.Logger.getLogger(MainWin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
|
} catch (InstantiationException ex) {
|
|
java.util.logging.Logger.getLogger(MainWin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
|
} catch (IllegalAccessException ex) {
|
|
java.util.logging.Logger.getLogger(MainWin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
|
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
|
|
java.util.logging.Logger.getLogger(MainWin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
|
}
|
|
*/
|
|
//</editor-fold>
|
|
|
|
/* Create and display the form */
|
|
java.awt.EventQueue.invokeLater(new Runnable() {
|
|
public void run() {
|
|
new MainWin().setVisible(true);
|
|
}
|
|
});
|
|
}
|
|
|
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
|
private javax.swing.JMenu FileMenu;
|
|
private javax.swing.JMenuItem FileNew;
|
|
private javax.swing.JMenuItem FileRun;
|
|
private javax.swing.JMenuBar MainMenu;
|
|
private Gui.Chart chart1;
|
|
private Gui.ControlPanel controlPanel2;
|
|
private javax.swing.JButton jButton1;
|
|
private javax.swing.JLabel jLabel1;
|
|
private javax.swing.JLabel jLabel2;
|
|
private javax.swing.JMenu jMenu2;
|
|
private javax.swing.JMenuItem jMenuItem1;
|
|
private Gui.OrderBook orderBook1;
|
|
// End of variables declaration//GEN-END:variables
|
|
}
|