📄 dealcapture.java
字号:
gridBagConstraints3.gridy = 3;
currencySelection_.add (marketRate_, gridBagConstraints3);
marketRateLabel_.setText ("Market Rate");
gridBagConstraints3 = new GridBagConstraints ();
gridBagConstraints3.gridx = 2;
gridBagConstraints3.gridy = 2;
currencySelection_.add (marketRateLabel_, gridBagConstraints3);
products_.setBorder (new TitledBorder("Selected Product"));
products_.setToolTipText ("Select the currency product");
gridBagConstraints3 = new GridBagConstraints ();
gridBagConstraints3.gridx = 0;
gridBagConstraints3.gridy = 1;
currencySelection_.add (products_, gridBagConstraints3);
gridBagConstraints3 = new GridBagConstraints ();
gridBagConstraints3.gridx = 0;
gridBagConstraints3.gridy = 2;
gridBagConstraints3.ipady = 22;
currencySelection_.add (filler1_, gridBagConstraints3);
gridBagConstraints3 = new GridBagConstraints ();
gridBagConstraints3.gridx = 0;
gridBagConstraints3.gridy = 4;
gridBagConstraints3.fill = GridBagConstraints.VERTICAL;
gridBagConstraints3.ipady = 24;
gridBagConstraints3.anchor = GridBagConstraints.SOUTH;
currencySelection_.add (filller2_, gridBagConstraints3);
date_.setToolTipText("Enter date");
dateValidator_ = new DateValidator(date_);
currentDate_.setText(dateValidator_.getToday());
currentDate_.setToolTipText ("Todays Date");
gridBagConstraints3 = new GridBagConstraints ();
gridBagConstraints3.gridx = 2;
gridBagConstraints3.gridy = 0;
currencySelection_.add (currentDate_, gridBagConstraints3);
gridBagConstraints3 = new GridBagConstraints ();
gridBagConstraints3.gridx = 1;
gridBagConstraints3.gridy = 2;
gridBagConstraints3.insets = new Insets (0, 79, 0, 79);
currencySelection_.add (spacer5_, gridBagConstraints3);
gridBagConstraints1 = new GridBagConstraints ();
gridBagConstraints1.anchor = GridBagConstraints.WEST;
getContentPane().add(currencySelection_, gridBagConstraints1);
commit_.setEnabled(false);
setUpCallbacks();
}
/**
* Set up all required callbacks for components.
*
*/
private void setUpCallbacks()
{
addWindowListener (new WindowAdapter () {
public void windowClosing (WindowEvent evt) {
exitForm (evt);
}
}
);
products_.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt)
{
String prd = (String)products_.getSelectedItem();
if (!prd.equals("Spot "))
{
JOptionPane.showMessageDialog
(commands_, prd + " Not implemented yet",
"Product Not Implemented",
JOptionPane.ERROR_MESSAGE);
products_.setSelectedItem("Spot ");
}
}
}
);
currency2_.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt)
{
dealController_.setCurrencies
("USD", (String)currency2_.getSelectedItem());
}
}
);
cancel_.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt)
{
// Reset the currencies, will clear the screen to its
// default values.
dealController_.setCurrencies
((String)currency1_.getSelectedItem(),
(String)currency2_.getSelectedItem());
}
}
);
commit_.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt)
{
// Commit the deal.
if (dealController_.commit())
{
// Reset the currencies, will clear the screen to its
// default values.
dealController_.setCurrencies
((String)currency1_.getSelectedItem(),
(String)currency2_.getSelectedItem());
}
else
{
JOptionPane.showMessageDialog
(commands_, "Failed to publish deal",
"Publish Error",
JOptionPane.ERROR_MESSAGE);
}
}
}
);
currencySelector_ = new CurrencySelector
(currencySelect_, currency2Label_);
buySellSelector_ = new BuySellSelector
(buySellSelect_, buySellLabel_);
dealController_ = new DealController(this, factory_);
dealController_.setDateValidator(dateValidator_);
dealController_.setAmountValidator(amountValidator_);
dealController_.setRateValidator(new RateValidator(spotRateField_));
dealController_.setCurrencySelector(currencySelector_);
dealController_.setBuySellSelector(buySellSelector_);
dealController_.setCurrencies
("USD", (String)currency2_.getSelectedItem());
}
public void setAmount2(String st)
{
amount2_.setText(st);
}
public void setMarketrate(String st)
{
marketRate_.setText(st);
}
public void reset()
{
amount2_.setText("");
}
public void canCommit(boolean flag)
{
commit_.setEnabled(flag);
}
/**
* Exit the application.
*
*/
private void exitForm(WindowEvent evt)
{
System.exit (0);
}
/**
* Print out information on running this sevice
*/
static protected void usage()
{
java.io.PrintStream out = System.out;
out.println("\n\n");
out.println("====================================================================");
out.println("Usage information for openjms.examples.client.fx.dealcapture.DealCapture");
out.println("====================================================================");
out.println("openjms.examples.client.fx.dealcapture.DealCapture\n");
out.println(" [-help | -mode <rmi/ipc> \n");
out.println("\t-help displays this screen\n");
out.println("\t-mode connect in either ipc mode or rmi mode.\n");
}
/**
* @param args the command line arguments
*/
public static void main (String args[])
{
CommandLine cmdline = new CommandLine(args);
if (cmdline.exists("help")) {
// the help option has been speifie, print the usage information
usage();
}
String md = cmdline.value("mode");
String uri = "rmi://";
String mode = rmiMode_;
String host = "localhost";
String port = "1099";
String jndiServer = "JndiServer";
if (md != null && md.equals("ipc")) {
System.out.println("Using IPC mode");
mode = ipcMode_;
port = "3035";
uri = "tcp://";
jndiServer = "";
}
if (cmdline.exists("jndiport")) {
port = cmdline.value("jndiport");
}
if (cmdline.exists("jndihost")) {
host = cmdline.value("jndihost");
}
Hashtable props = new Hashtable();
props.put(Context.PROVIDER_URL,
uri + host + ":" + port + '/' + jndiServer);
props.put(Context.INITIAL_CONTEXT_FACTORY, mode);
try {
Context context = new InitialContext(props);
factory_ = (TopicConnectionFactory)
context.lookup("JmsTopicConnectionFactory");
} catch (Exception err) {
err.printStackTrace();
System.err.println("Exiting");
System.exit(-1);
}
new DealCapture ().show ();
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private JPanel commands_;
private JSeparator separator_;
private JPanel panel1_;
private JButton commit_;
private JButton cancel_;
private JPanel amounts_;
private JTextField date_;
private JButton currencySelect_;
private JButton buySellSelect_;
private JTextField amount1_;
private JTextField amount2_;
private JLabel currency2Label_;
private JLabel buySellLabel_;
private JLabel spacer3_;
private JLabel spacer4_;
private JTextField spotRateField_;
private JPanel currencySelection_;
private JComboBox currency1_;
private JComboBox currency2_;
private JLabel marketRate_;
private JLabel marketRateLabel_;
private JComboBox products_;
private JLabel filler1_;
private JLabel filller2_;
private JLabel currentDate_;
private JLabel spacer5_;
private CurrencySelector currencySelector_;
private BuySellSelector buySellSelector_;
private DateValidator dateValidator_;
private DealController dealController_;
private AmountValidator amountValidator_;
private static TopicConnectionFactory factory_ = null;
final static private String ipcMode_ = "org.exolab.jms.jndi.mipc.IpcJndiInitialContextFactory";
final static private String rmiMode_ = "org.exolab.jms.jndi.rmi.RmiJndiInitialContextFactory";
} // End DealCapture
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -