⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 newselltransactionjdialog.java

📁 JStock是一个免费股市软件
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/*
 * NewSellTransactionJDialog.java
 *
 * Created on March 30, 2008, 6:31 AM
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or (at
 * your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * Copyright (C) 2008 Cheok YanCheng <yccheok@yahoo.com>
 */

package org.yccheok.jstock.gui;

import java.text.NumberFormat;
import java.text.ParseException;
import java.util.Date;
import javax.swing.JFormattedTextField;
import javax.swing.SpinnerNumberModel;
import javax.swing.text.NumberFormatter;
import javax.swing.SwingUtilities;
import net.sf.nachocalendar.CalendarFactory;
import net.sf.nachocalendar.components.DateField;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.yccheok.jstock.engine.Code;
import org.yccheok.jstock.engine.SimpleDate;
import org.yccheok.jstock.engine.Stock;
import org.yccheok.jstock.engine.StockCodeAndSymbolDatabase;
import org.yccheok.jstock.engine.Symbol;
import org.yccheok.jstock.portfolio.Broker;
import org.yccheok.jstock.portfolio.BrokingFirm;
import org.yccheok.jstock.portfolio.ClearingFee;
import org.yccheok.jstock.portfolio.Contract;
import org.yccheok.jstock.portfolio.SimpleBroker;
import org.yccheok.jstock.portfolio.SimpleClearingFee;
import org.yccheok.jstock.portfolio.SimpleStampDuty;
import org.yccheok.jstock.portfolio.StampDuty;
import org.yccheok.jstock.portfolio.Transaction;

/**
 *
 * @author  yccheok
 */
public class NewSellTransactionJDialog extends javax.swing.JDialog {
    /** Creates new form NewSellTransactionJDialog */
    public NewSellTransactionJDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        
        if(shouldAutoCalculateBrokerFee())
        {
            this.jFormattedTextField4.setEditable(false);
            this.jFormattedTextField5.setEditable(false);
            this.jFormattedTextField7.setEditable(false);
        }
    }

    public void setBuyCost(double buyCost) {
        this.buyCost = buyCost;
        update();
    }

    public void setMaxSellQuantity(int maxSellQuantity) {
        SpinnerNumberModel spinnerNumberModel = (SpinnerNumberModel)jSpinner1.getModel();
        spinnerNumberModel.setMaximum(maxSellQuantity);
    }

    public void setSellQuantity(int sellQuantity) {
        jSpinner1.getModel().setValue(sellQuantity);
        update();
    }
    
    private boolean shouldAutoCalculateBrokerFee() {
        final JStockOptions jStockOptions = MainFrame.getJStockOptions();
        
        return 
                (jStockOptions.isAutoBrokerFeeCalculationEnabled()) && 
                (jStockOptions.getSelectedBrokingFirm() != null);
    }
    
    /** 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.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel2 = new javax.swing.JPanel();
        jTextField1 = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jSpinner1 = new javax.swing.JSpinner();
        jPanel3 = CalendarFactory.createDateField();
        jLabel4 = new javax.swing.JLabel();
        jFormattedTextField1 = getCurrencyJFormattedTextField(false);
        jFormattedTextField2 = getCurrencyJFormattedTextField(false);
        jFormattedTextField3 = getCurrencyJFormattedTextField(false);
        jFormattedTextField4 = getCurrencyJFormattedTextField(false);
        jFormattedTextField5 = getCurrencyJFormattedTextField(false);
        jLabel10 = new javax.swing.JLabel();
        jFormattedTextField6 = getCurrencyJFormattedTextField(true);
        jLabel1 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jFormattedTextField7 = getCurrencyJFormattedTextField(false);
        jLabel11 = new javax.swing.JLabel();
        jFormattedTextField8 = getCurrencyJFormattedTextField(true);
        jLabel12 = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        jButton3 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Sell");
        setResizable(false);

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Transaction"));

        jTextField1.setEditable(false);

        jLabel2.setText("Symbol");

        jSpinner1.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(100), Integer.valueOf(1), null, Integer.valueOf(100)));
        jSpinner1.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jSpinner1StateChanged(evt);
            }
        });

        jPanel3.setBackground(new java.awt.Color(204, 255, 255));
        jPanel3.setMaximumSize(new java.awt.Dimension(32767, 20));
        jPanel3.setPreferredSize(new java.awt.Dimension(100, 20));

        jLabel4.setText("Date");

        jFormattedTextField1.setValue(new Double(0.0));
        jFormattedTextField1.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jFormattedTextField1FocusLost(evt);
            }
        });

        jFormattedTextField2.setEditable(false);
        jFormattedTextField2.setValue(new Double(0.0));

        jFormattedTextField3.setEditable(false);
        jFormattedTextField3.setValue(new Double(0.0));

        jFormattedTextField4.setValue(new Double(0.0));
        jFormattedTextField4.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jFormattedTextField4FocusLost(evt);
            }
        });

        jFormattedTextField5.setValue(new Double(0.0));
        jFormattedTextField5.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jFormattedTextField5FocusLost(evt);
            }
        });

        jLabel10.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel10.setText("Profit (%)");

        jFormattedTextField6.setEditable(false);
        jFormattedTextField6.setFont(new java.awt.Font("Tahoma", 1, 11));
        jFormattedTextField6.setValue(new Double(0.0));

        jLabel1.setText("Unit");

        jLabel3.setText("Price");

        jLabel5.setText("Value");

        jLabel7.setText("Buy Cost");

        jLabel8.setText("Broker");

        jLabel9.setText("Clearing");

        jFormattedTextField7.setValue(new Double(0.0));
        jFormattedTextField7.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jFormattedTextField7FocusLost(evt);
            }
        });

        jLabel11.setText("Stamp Duty");

        jFormattedTextField8.setEditable(false);
        jFormattedTextField8.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jFormattedTextField8.setValue(new Double(0.0));

        jLabel12.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel12.setText("Profit ($)");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel9)
                    .addComponent(jLabel2)
                    .addComponent(jLabel3)
                    .addComponent(jLabel5)
                    .addComponent(jLabel7)
                    .addComponent(jLabel8)
                    .addComponent(jLabel1)
                    .addComponent(jLabel4)
                    .addComponent(jLabel11)
                    .addComponent(jLabel12)
                    .addComponent(jLabel10))

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -