List of usage examples for java.util Locale TRADITIONAL_CHINESE
Locale TRADITIONAL_CHINESE
To view the source code for java.util Locale TRADITIONAL_CHINESE.
Click Source Link
From source file:org.yccheok.jstock.gui.PortfolioManagementJPanel.java
public boolean openAsStatements(Statements statements, File file) { assert (statements != null); if (statements.getType() == Statement.Type.PortfolioManagementBuy || statements.getType() == Statement.Type.PortfolioManagementSell || statements.getType() == Statement.Type.PortfolioManagementDeposit || statements.getType() == Statement.Type.PortfolioManagementDividend) { final GUIBundleWrapper guiBundleWrapper = statements.getGUIBundleWrapper(); // We will use a fixed date format (Locale.English), so that it will be // easier for Android to process. ///*from www. j av a 2 s. c o m*/ // "Sep 5, 2011" - Locale.ENGLISH // "2011-9-5" - Locale.SIMPLIFIED_CHINESE // "2011/9/5" - Locale.TRADITIONAL_CHINESE // 05.09.2011 - Locale.GERMAN // // However, for backward compatible purpose (Able to read old CSV), // we perform a for loop to determine the best date format. DateFormat dateFormat = null; final int size = statements.size(); switch (statements.getType()) { case PortfolioManagementBuy: { final List<Transaction> transactions = new ArrayList<Transaction>(); for (int i = 0; i < size; i++) { final Statement statement = statements.get(i); final String _code = statement.getValueAsString(guiBundleWrapper.getString("MainFrame_Code")); final String _symbol = statement .getValueAsString(guiBundleWrapper.getString("MainFrame_Symbol")); final String _date = statement .getValueAsString(guiBundleWrapper.getString("PortfolioManagementJPanel_Date")); final Double units = statement .getValueAsDouble(guiBundleWrapper.getString("PortfolioManagementJPanel_Units")); final Double purchasePrice = statement.getValueAsDouble( guiBundleWrapper.getString("PortfolioManagementJPanel_PurchasePrice")); final Double broker = statement .getValueAsDouble(guiBundleWrapper.getString("PortfolioManagementJPanel_Broker")); final Double clearingFee = statement .getValueAsDouble(guiBundleWrapper.getString("PortfolioManagementJPanel_ClearingFee")); final Double stampDuty = statement .getValueAsDouble(guiBundleWrapper.getString("PortfolioManagementJPanel_StampDuty")); final String _comment = statement .getValueAsString(guiBundleWrapper.getString("PortfolioManagementJPanel_Comment")); Stock stock = null; if (_code.length() > 0 && _symbol.length() > 0) { stock = org.yccheok.jstock.engine.Utils.getEmptyStock(Code.newInstance(_code), Symbol.newInstance(_symbol)); } else { log.error("Unexpected empty stock. Ignore"); // stock is null. continue; } Date date = null; if (dateFormat == null) { // However, for backward compatible purpose (Able to read old CSV), // we perform a for loop to determine the best date format. // For the latest CSV, it should be Locale.ENGLISH. Locale[] locales = { Locale.ENGLISH, Locale.SIMPLIFIED_CHINESE, Locale.GERMAN, Locale.TRADITIONAL_CHINESE, Locale.ITALIAN }; for (Locale locale : locales) { dateFormat = DateFormat.getDateInstance(DateFormat.DEFAULT, locale); try { date = dateFormat.parse((String) _date); } catch (ParseException exp) { log.error(null, exp); date = null; dateFormat = null; continue; } // We had found our best dateFormat. Early break. break; } } else { // We already determine our best dateFormat. try { date = dateFormat.parse((String) _date); } catch (ParseException exp) { log.error(null, exp); } } if (date == null) { log.error("Unexpected wrong date. Ignore"); continue; } // Shall we continue to ignore, or shall we just return false to // flag an error? if (units == null) { log.error("Unexpected wrong units. Ignore"); continue; } if (purchasePrice == null || broker == null || clearingFee == null || stampDuty == null) { log.error("Unexpected wrong purchasePrice/broker/clearingFee/stampDuty. Ignore"); continue; } final SimpleDate simpleDate = new SimpleDate(date); final Contract.Type type = Contract.Type.Buy; final Contract.ContractBuilder builder = new Contract.ContractBuilder(stock, simpleDate); final Contract contract = builder.type(type).quantity(units).price(purchasePrice).build(); final Transaction t = new Transaction(contract, broker, stampDuty, clearingFee); t.setComment(org.yccheok.jstock.portfolio.Utils.replaceCSVLineFeedToSystemLineFeed(_comment)); transactions.add(t); } // We allow empty portfolio. //if (transactions.size() <= 0) { // return false; //} // Is there any exsiting displayed data? if (this.getBuyTransactionSize() > 0) { final String output = MessageFormat.format( MessagesBundle.getString("question_message_load_file_for_buy_portfolio_template"), file.getName()); final int result = javax.swing.JOptionPane.showConfirmDialog(JStock.instance(), output, MessagesBundle.getString("question_title_load_file_for_buy_portfolio"), javax.swing.JOptionPane.YES_NO_OPTION, javax.swing.JOptionPane.QUESTION_MESSAGE); if (result != javax.swing.JOptionPane.YES_OPTION) { // Assume success. return true; } } this.buyTreeTable.setTreeTableModel(new BuyPortfolioTreeTableModelEx()); final BuyPortfolioTreeTableModelEx buyPortfolioTreeTableModel = (BuyPortfolioTreeTableModelEx) buyTreeTable .getTreeTableModel(); buyPortfolioTreeTableModel.bind(this.portfolioRealTimeInfo); buyPortfolioTreeTableModel.bind(this); Map<String, String> metadatas = statements.getMetadatas(); for (Transaction transaction : transactions) { final Code code = transaction.getStock().code; TransactionSummary transactionSummary = this.addBuyTransaction(transaction); if (transactionSummary != null) { String comment = metadatas.get(code.toString()); if (comment != null) { transactionSummary.setComment( org.yccheok.jstock.portfolio.Utils.replaceCSVLineFeedToSystemLineFeed(comment)); } } } // Only shows necessary columns. initGUIOptions(); expandTreeTable(buyTreeTable); updateRealTimeStockMonitorAccordingToPortfolioTreeTableModels(); updateExchangeRateMonitorAccordingToPortfolioTreeTableModels(); // updateWealthHeader will be called at end of switch. refreshStatusBarExchangeRateVisibility(); } break; case PortfolioManagementSell: { final List<Transaction> transactions = new ArrayList<Transaction>(); for (int i = 0; i < size; i++) { final Statement statement = statements.get(i); final String _code = statement.getValueAsString(guiBundleWrapper.getString("MainFrame_Code")); final String _symbol = statement .getValueAsString(guiBundleWrapper.getString("MainFrame_Symbol")); final String _referenceDate = statement.getValueAsString( guiBundleWrapper.getString("PortfolioManagementJPanel_ReferenceDate")); // Legacy file handling. PortfolioManagementJPanel_PurchaseBroker, PortfolioManagementJPanel_PurchaseClearingFee, // and PortfolioManagementJPanel_PurchaseStampDuty are introduced starting from 1.0.6x Double purchaseBroker = statement.getValueAsDouble( guiBundleWrapper.getString("PortfolioManagementJPanel_PurchaseBroker")); if (purchaseBroker == null) { // Legacy file handling. PortfolioManagementJPanel_PurchaseFee is introduced starting from 1.0.6s purchaseBroker = statement.getValueAsDouble( guiBundleWrapper.getString("PortfolioManagementJPanel_PurchaseFee")); if (purchaseBroker == null) { purchaseBroker = new Double(0.0); } } Double purchaseClearingFee = statement.getValueAsDouble( guiBundleWrapper.getString("PortfolioManagementJPanel_PurchaseClearingFee")); if (purchaseClearingFee == null) { purchaseClearingFee = new Double(0.0); } Double purchaseStampDuty = statement.getValueAsDouble( guiBundleWrapper.getString("PortfolioManagementJPanel_PurchaseStampDuty")); if (purchaseStampDuty == null) { purchaseStampDuty = new Double(0.0); } final String _date = statement .getValueAsString(guiBundleWrapper.getString("PortfolioManagementJPanel_Date")); final Double units = statement .getValueAsDouble(guiBundleWrapper.getString("PortfolioManagementJPanel_Units")); final Double sellingPrice = statement .getValueAsDouble(guiBundleWrapper.getString("PortfolioManagementJPanel_SellingPrice")); final Double purchasePrice = statement.getValueAsDouble( guiBundleWrapper.getString("PortfolioManagementJPanel_PurchasePrice")); final Double broker = statement .getValueAsDouble(guiBundleWrapper.getString("PortfolioManagementJPanel_Broker")); final Double clearingFee = statement .getValueAsDouble(guiBundleWrapper.getString("PortfolioManagementJPanel_ClearingFee")); final Double stampDuty = statement .getValueAsDouble(guiBundleWrapper.getString("PortfolioManagementJPanel_StampDuty")); final String _comment = statement .getValueAsString(guiBundleWrapper.getString("PortfolioManagementJPanel_Comment")); Stock stock = null; if (_code.length() > 0 && _symbol.length() > 0) { stock = org.yccheok.jstock.engine.Utils.getEmptyStock(Code.newInstance(_code), Symbol.newInstance(_symbol)); } else { log.error("Unexpected empty stock. Ignore"); // stock is null. continue; } Date date = null; Date referenceDate = null; if (dateFormat == null) { // However, for backward compatible purpose (Able to read old CSV), // we perform a for loop to determine the best date format. // For the latest CSV, it should be Locale.ENGLISH. Locale[] locales = { Locale.ENGLISH, Locale.SIMPLIFIED_CHINESE, Locale.GERMAN, Locale.TRADITIONAL_CHINESE, Locale.ITALIAN }; for (Locale locale : locales) { dateFormat = DateFormat.getDateInstance(DateFormat.DEFAULT, locale); try { date = dateFormat.parse((String) _date); referenceDate = dateFormat.parse((String) _referenceDate); } catch (ParseException exp) { log.error(null, exp); date = null; referenceDate = null; dateFormat = null; continue; } // We had found our best dateFormat. Early break. break; } } else { // We already determine our best dateFormat. try { date = dateFormat.parse((String) _date); referenceDate = dateFormat.parse((String) _referenceDate); } catch (ParseException exp) { log.error(null, exp); } } if (date == null || referenceDate == null) { log.error("Unexpected wrong date/referenceDate. Ignore"); continue; } // Shall we continue to ignore, or shall we just return false to // flag an error? if (units == null) { log.error("Unexpected wrong units. Ignore"); continue; } if (purchasePrice == null || broker == null || clearingFee == null || stampDuty == null || sellingPrice == null) { log.error( "Unexpected wrong purchasePrice/broker/clearingFee/stampDuty/sellingPrice. Ignore"); continue; } final SimpleDate simpleDate = new SimpleDate(date); final SimpleDate simpleReferenceDate = new SimpleDate(referenceDate); final Contract.Type type = Contract.Type.Sell; final Contract.ContractBuilder builder = new Contract.ContractBuilder(stock, simpleDate); final Contract contract = builder.type(type).quantity(units).price(sellingPrice) .referencePrice(purchasePrice).referenceDate(simpleReferenceDate) .referenceBroker(purchaseBroker).referenceClearingFee(purchaseClearingFee) .referenceStampDuty(purchaseStampDuty).build(); final Transaction t = new Transaction(contract, broker, stampDuty, clearingFee); t.setComment(org.yccheok.jstock.portfolio.Utils.replaceCSVLineFeedToSystemLineFeed(_comment)); transactions.add(t); } // for // We allow empty portfolio. //if (transactions.size() <= 0) { // return false; //} // Is there any exsiting displayed data? if (this.getSellTransactionSize() > 0) { final String output = MessageFormat.format( MessagesBundle.getString("question_message_load_file_for_sell_portfolio_template"), file.getName()); final int result = javax.swing.JOptionPane.showConfirmDialog(JStock.instance(), output, MessagesBundle.getString("question_title_load_file_for_sell_portfolio"), javax.swing.JOptionPane.YES_NO_OPTION, javax.swing.JOptionPane.QUESTION_MESSAGE); if (result != javax.swing.JOptionPane.YES_OPTION) { // Assume success. return true; } } this.sellTreeTable.setTreeTableModel(new SellPortfolioTreeTableModelEx()); final SellPortfolioTreeTableModelEx sellPortfolioTreeTableModel = (SellPortfolioTreeTableModelEx) sellTreeTable .getTreeTableModel(); sellPortfolioTreeTableModel.bind(this.portfolioRealTimeInfo); sellPortfolioTreeTableModel.bind(this); Map<String, String> metadatas = statements.getMetadatas(); for (Transaction transaction : transactions) { final Code code = transaction.getStock().code; TransactionSummary transactionSummary = this.addSellTransaction(transaction); if (transactionSummary != null) { String comment = metadatas.get(code.toString()); if (comment != null) { transactionSummary.setComment( org.yccheok.jstock.portfolio.Utils.replaceCSVLineFeedToSystemLineFeed(comment)); } } } // Only shows necessary columns. initGUIOptions(); expandTreeTable(this.sellTreeTable); updateExchangeRateMonitorAccordingToPortfolioTreeTableModels(); // updateWealthHeader will be called at end of switch. refreshStatusBarExchangeRateVisibility(); } break; case PortfolioManagementDeposit: { final List<Deposit> deposits = new ArrayList<Deposit>(); for (int i = 0; i < size; i++) { Date date = null; final Statement statement = statements.get(i); final String object0 = statement .getValueAsString(guiBundleWrapper.getString("PortfolioManagementJPanel_Date")); assert (object0 != null); if (dateFormat == null) { // However, for backward compatible purpose (Able to read old CSV), // we will perform a for loop to determine the best date format. // For the latest CSV, it should be Locale.ENGLISH. Locale[] locales = { Locale.ENGLISH, Locale.SIMPLIFIED_CHINESE, Locale.GERMAN, Locale.TRADITIONAL_CHINESE, Locale.ITALIAN }; for (Locale locale : locales) { dateFormat = DateFormat.getDateInstance(DateFormat.DEFAULT, locale); try { date = dateFormat.parse(object0); } catch (ParseException exp) { log.error(null, exp); date = null; dateFormat = null; continue; } // We had found our best dateFormat. Early break. break; } } else { // We already determine our best dateFormat. try { date = dateFormat.parse(object0); } catch (ParseException exp) { log.error(null, exp); } } // Shall we continue to ignore, or shall we just return false to // flag an error? if (date == null) { log.error("Unexpected wrong date. Ignore"); continue; } final Double cash = statement .getValueAsDouble(guiBundleWrapper.getString("PortfolioManagementJPanel_Cash")); // Shall we continue to ignore, or shall we just return false to // flag an error? if (cash == null) { log.error("Unexpected wrong cash. Ignore"); continue; } final Deposit deposit = new Deposit(cash, new SimpleDate(date)); final String comment = statement .getValueAsString(guiBundleWrapper.getString("PortfolioManagementJPanel_Comment")); if (comment != null) { // Possible to be null. As in version <=1.0.6p, comment // is not being saved to CSV. deposit.setComment( org.yccheok.jstock.portfolio.Utils.replaceCSVLineFeedToSystemLineFeed(comment)); } deposits.add(deposit); } // We allow empty portfolio. //if (deposits.size() <= 0) { // return false; //} // Is there any exsiting displayed data? if (this.depositSummary.size() > 0) { final String output = MessageFormat.format( MessagesBundle.getString("question_message_load_file_for_cash_deposit_template"), file.getName()); final int result = javax.swing.JOptionPane.showConfirmDialog(JStock.instance(), output, MessagesBundle.getString("question_title_load_file_for_cash_deposit"), javax.swing.JOptionPane.YES_NO_OPTION, javax.swing.JOptionPane.QUESTION_MESSAGE); if (result != javax.swing.JOptionPane.YES_OPTION) { // Assume success. return true; } } this.depositSummary = new DepositSummary(); for (Deposit deposit : deposits) { depositSummary.add(deposit); } } break; case PortfolioManagementDividend: { final List<Dividend> dividends = new ArrayList<Dividend>(); for (int i = 0; i < size; i++) { Date date = null; StockInfo stockInfo = null; final Statement statement = statements.get(i); final String object0 = statement .getValueAsString(guiBundleWrapper.getString("PortfolioManagementJPanel_Date")); assert (object0 != null); if (dateFormat == null) { // However, for backward compatible purpose (Able to read old CSV), // we will perform a for loop to determine the best date format. // For the latest CSV, it should be Locale.ENGLISH. Locale[] locales = { Locale.ENGLISH, Locale.SIMPLIFIED_CHINESE, Locale.GERMAN, Locale.TRADITIONAL_CHINESE, Locale.ITALIAN }; for (Locale locale : locales) { dateFormat = DateFormat.getDateInstance(DateFormat.DEFAULT, locale); try { date = dateFormat.parse(object0); } catch (ParseException exp) { log.error(null, exp); date = null; dateFormat = null; continue; } // We had found our best dateFormat. Early break. break; } } else { // We already determine our best dateFormat. try { date = dateFormat.parse(object0); } catch (ParseException exp) { log.error(null, exp); } } // Shall we continue to ignore, or shall we just return false to // flag an error? if (date == null) { log.error("Unexpected wrong date. Ignore"); continue; } final Double dividend = statement .getValueAsDouble(guiBundleWrapper.getString("PortfolioManagementJPanel_Dividend")); // Shall we continue to ignore, or shall we just return false to // flag an error? if (dividend == null) { log.error("Unexpected wrong dividend. Ignore"); continue; } final String codeStr = statement.getValueAsString(guiBundleWrapper.getString("MainFrame_Code")); final String symbolStr = statement .getValueAsString(guiBundleWrapper.getString("MainFrame_Symbol")); if (codeStr.isEmpty() == false && symbolStr.isEmpty() == false) { stockInfo = StockInfo.newInstance(Code.newInstance(codeStr), Symbol.newInstance(symbolStr)); } else { log.error("Unexpected wrong stock. Ignore"); // stock is null. continue; } assert (stockInfo != null); assert (dividend != null); assert (date != null); final Dividend d = new Dividend(stockInfo, dividend, new SimpleDate(date)); final String comment = statement .getValueAsString(guiBundleWrapper.getString("PortfolioManagementJPanel_Comment")); if (comment != null) { // Possible to be null. As in version <=1.0.6p, comment // is not being saved to CSV. d.setComment( org.yccheok.jstock.portfolio.Utils.replaceCSVLineFeedToSystemLineFeed(comment)); } dividends.add(d); } // We allow empty portfolio. //if (dividends.size() <= 0) { // return false; //} if (this.dividendSummary.size() > 0) { final String output = MessageFormat.format( MessagesBundle.getString("question_message_load_file_for_dividend_template"), file.getName()); final int result = javax.swing.JOptionPane.showConfirmDialog(JStock.instance(), output, MessagesBundle.getString("question_title_load_file_for_dividend"), javax.swing.JOptionPane.YES_NO_OPTION, javax.swing.JOptionPane.QUESTION_MESSAGE); if (result != javax.swing.JOptionPane.YES_OPTION) { // Assume success. return true; } } this.dividendSummary = new DividendSummary(); for (Dividend dividend : dividends) { dividendSummary.add(dividend); } } break; default: assert (false); } // End of switch this.updateWealthHeader(); } else if (statements.getType() == Statement.Type.RealtimeInfo) { /* Open using other tabs. */ return JStock.instance().openAsStatements(statements, file); } else { return false; } return true; }
From source file:org.yccheok.jstock.gui.MainFrame.java
/** This method is called from within the constructor to * initialize the form.//from w ww . ja va 2s .c o m * 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() { buttonGroup1 = new javax.swing.ButtonGroup(); buttonGroup2 = new javax.swing.ButtonGroup(); buttonGroup3 = new javax.swing.ButtonGroup(); jComboBox1 = new AutoCompleteJComboBox(); jPanel6 = new javax.swing.JPanel(); jTabbedPane1 = new javax.swing.JTabbedPane(); jPanel8 = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); jTable1 = new javax.swing.JTable(); jPanel1 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jPanel10 = new javax.swing.JPanel(); jPanel3 = new javax.swing.JPanel(); jPanel2 = new javax.swing.JPanel(); jMenuBar2 = new javax.swing.JMenuBar(); jMenu3 = new javax.swing.JMenu(); jMenuItem2 = new javax.swing.JMenuItem(); jMenuItem9 = new javax.swing.JMenuItem(); jSeparator7 = new javax.swing.JPopupMenu.Separator(); jMenuItem11 = new javax.swing.JMenuItem(); jMenuItem10 = new javax.swing.JMenuItem(); jSeparator8 = new javax.swing.JPopupMenu.Separator(); jMenuItem1 = new javax.swing.JMenuItem(); jMenu5 = new javax.swing.JMenu(); jMenuItem4 = new javax.swing.JMenuItem(); jMenuItem7 = new javax.swing.JMenuItem(); jSeparator4 = new javax.swing.JPopupMenu.Separator(); jMenuItem15 = new javax.swing.JMenuItem(); jMenu6 = new javax.swing.JMenu(); jMenu10 = new javax.swing.JMenu(); jRadioButtonMenuItem1 = new javax.swing.JRadioButtonMenuItem(); jRadioButtonMenuItem2 = new javax.swing.JRadioButtonMenuItem(); jRadioButtonMenuItem4 = new javax.swing.JRadioButtonMenuItem(); jRadioButtonMenuItem6 = new javax.swing.JRadioButtonMenuItem(); jRadioButtonMenuItem3 = new javax.swing.JRadioButtonMenuItem(); jRadioButtonMenuItem5 = new javax.swing.JRadioButtonMenuItem(); jMenu7 = new javax.swing.JMenu(); jMenuItem8 = new javax.swing.JMenuItem(); jMenu9 = new javax.swing.JMenu(); jMenu8 = new javax.swing.JMenu(); jMenu1 = new javax.swing.JMenu(); jMenuItem6 = new javax.swing.JMenuItem(); jMenu4 = new javax.swing.JMenu(); jMenu2 = new javax.swing.JMenu(); jMenuItem3 = new javax.swing.JMenuItem(); jMenuItem16 = new javax.swing.JMenuItem(); jMenuItem12 = new javax.swing.JMenuItem(); jSeparator6 = new javax.swing.JPopupMenu.Separator(); jMenuItem13 = new javax.swing.JMenuItem(); jMenuItem14 = new javax.swing.JMenuItem(); jSeparator5 = new javax.swing.JPopupMenu.Separator(); jMenuItem5 = new javax.swing.JMenuItem(); jMenu11 = new javax.swing.JMenu(); jMenuItem17 = new javax.swing.JMenuItem(); jComboBox1.setEditable(true); jComboBox1.setPreferredSize(new java.awt.Dimension(150, 24)); ((AutoCompleteJComboBox) this.jComboBox1).attachStockInfoObserver(getStockInfoObserver()); ((AutoCompleteJComboBox) this.jComboBox1).attachResultObserver(getResultObserver()); ((AutoCompleteJComboBox) this.jComboBox1).attachMatchObserver(getMatchObserver()); setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/gui"); // NOI18N setTitle(bundle.getString("MainFrame_Application_Title")); // NOI18N setIconImage(getMyIconImage()); addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { formMouseClicked(evt); } }); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosed(java.awt.event.WindowEvent evt) { formWindowClosed(evt); } public void windowClosing(java.awt.event.WindowEvent evt) { formWindowClosing(evt); } public void windowDeiconified(java.awt.event.WindowEvent evt) { formWindowDeiconified(evt); } public void windowIconified(java.awt.event.WindowEvent evt) { formWindowIconified(evt); } }); getContentPane().setLayout(new java.awt.BorderLayout(5, 5)); jPanel6.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); jPanel6.setLayout(new java.awt.BorderLayout(5, 5)); this.jPanel6.add(statusBar, java.awt.BorderLayout.SOUTH); getContentPane().add(jPanel6, java.awt.BorderLayout.SOUTH); jTabbedPane1.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); jTabbedPane1.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { jTabbedPane1StateChanged(evt); } }); jPanel8.setLayout(new java.awt.BorderLayout(5, 5)); jTable1.setAutoCreateRowSorter(true); jTable1.setFont(jTable1.getFont().deriveFont(jTable1.getFont().getStyle() | java.awt.Font.BOLD, jTable1.getFont().getSize() + 1)); jTable1.setModel(new StockTableModel()); jTable1.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF); this.jTable1.setDefaultRenderer(Number.class, new StockTableCellRenderer(SwingConstants.RIGHT)); this.jTable1.setDefaultRenderer(Double.class, new StockTableCellRenderer(SwingConstants.RIGHT)); this.jTable1.setDefaultRenderer(Object.class, new StockTableCellRenderer(SwingConstants.LEFT)); this.jTable1.setDefaultEditor(Double.class, new NonNegativeDoubleEditor()); this.jTable1.getModel().addTableModelListener(this.getTableModelListener()); this.jTable1.getTableHeader().addMouseListener(new TableColumnSelectionPopupListener(1)); this.jTable1.addMouseListener(new TableRowPopupListener()); this.jTable1.addKeyListener(new TableKeyEventListener()); jTable1.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { jTable1KeyPressed(evt); } }); jScrollPane1.setViewportView(jTable1); jPanel8.add(jScrollPane1, java.awt.BorderLayout.CENTER); jLabel1.setText(bundle.getString("MainFrame_Stock")); // NOI18N jPanel1.add(jLabel1); jPanel8.add(jPanel1, java.awt.BorderLayout.NORTH); jPanel10.setPreferredSize(new java.awt.Dimension(328, 170)); jPanel10.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT, 10, 5)); jPanel3.setBackground(new java.awt.Color(255, 255, 255)); jPanel3.setPreferredSize(new java.awt.Dimension(170, 160)); jPanel3.setBorder(new org.jdesktop.swingx.border.DropShadowBorder(true)); jPanel3.setLayout(new java.awt.BorderLayout()); jPanel10.add(jPanel3); EMPTY_DYNAMIC_CHART.getChartPanel().addMouseListener(dynamicChartMouseAdapter); jPanel3.add(EMPTY_DYNAMIC_CHART.getChartPanel(), java.awt.BorderLayout.CENTER); jPanel8.add(jPanel10, java.awt.BorderLayout.SOUTH); jTabbedPane1.addTab(bundle.getString("MainFrame_Title"), jPanel8); // NOI18N getContentPane().add(jTabbedPane1, java.awt.BorderLayout.CENTER); jPanel2.setLayout(new java.awt.GridLayout(2, 1)); getContentPane().add(jPanel2, java.awt.BorderLayout.NORTH); jMenu3.setText(bundle.getString("MainFrame_File")); // NOI18N jMenuItem2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/16x16/project_open.png"))); // NOI18N jMenuItem2.setText(bundle.getString("MainFrame_Open...")); // NOI18N jMenuItem2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem2ActionPerformed(evt); } }); jMenu3.add(jMenuItem2); jMenuItem9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/16x16/filesave.png"))); // NOI18N jMenuItem9.setText(bundle.getString("MainFrame_SaveAs...")); // NOI18N jMenuItem9.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem9ActionPerformed(evt); } }); jMenu3.add(jMenuItem9); jMenu3.add(jSeparator7); jMenuItem11.setIcon( new javax.swing.ImageIcon(getClass().getResource("/images/16x16/download_from_cloud.png"))); // NOI18N jMenuItem11.setText(bundle.getString("MainFrame_OpenFromCloud...")); // NOI18N jMenuItem11.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem11ActionPerformed(evt); } }); jMenu3.add(jMenuItem11); jMenuItem10.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/16x16/upload_to_cloud.png"))); // NOI18N jMenuItem10.setText(bundle.getString("MainFrame_SaveToCloud...")); // NOI18N jMenuItem10.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem10ActionPerformed(evt); } }); jMenu3.add(jMenuItem10); jMenu3.add(jSeparator8); jMenuItem1.setText(bundle.getString("MainFrame_Exit")); // NOI18N jMenuItem1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem1ActionPerformed(evt); } }); jMenu3.add(jMenuItem1); jMenuBar2.add(jMenu3); jMenu5.setText(bundle.getString("MainFrame_Edit")); // NOI18N jMenuItem4.setText(bundle.getString("MainFrame_AddStocks...")); // NOI18N jMenuItem4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem4ActionPerformed(evt); } }); jMenu5.add(jMenuItem4); jMenuItem7.setText(bundle.getString("MainFrame_ClearAllStocks")); // NOI18N jMenuItem7.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem7ActionPerformed(evt); } }); jMenu5.add(jMenuItem7); jMenu5.add(jSeparator4); jMenuItem15.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_R, java.awt.event.InputEvent.CTRL_MASK)); jMenuItem15.setText(bundle.getString("MainFrame_RefreshStockPrices")); // NOI18N jMenuItem15.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem15ActionPerformed(evt); } }); jMenu5.add(jMenuItem15); jMenuBar2.add(jMenu5); jMenu6.setText(bundle.getString("MainFrame_Country")); // NOI18N jMenuBar2.add(jMenu6); jMenu10.setText(bundle.getString("MainFrame_Language")); // NOI18N buttonGroup3.add(jRadioButtonMenuItem1); jRadioButtonMenuItem1.setSelected(true); jRadioButtonMenuItem1.setText(Locale.ENGLISH.getDisplayLanguage(Locale.getDefault())); jRadioButtonMenuItem1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButtonMenuItem1ActionPerformed(evt); } }); jMenu10.add(jRadioButtonMenuItem1); buttonGroup3.add(jRadioButtonMenuItem2); jRadioButtonMenuItem2.setText(Locale.SIMPLIFIED_CHINESE.getDisplayName(Locale.getDefault())); jRadioButtonMenuItem2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButtonMenuItem2ActionPerformed(evt); } }); jMenu10.add(jRadioButtonMenuItem2); buttonGroup3.add(jRadioButtonMenuItem4); jRadioButtonMenuItem4.setText(Locale.TRADITIONAL_CHINESE.getDisplayName(Locale.getDefault())); jRadioButtonMenuItem4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButtonMenuItem4ActionPerformed(evt); } }); jMenu10.add(jRadioButtonMenuItem4); buttonGroup3.add(jRadioButtonMenuItem6); jRadioButtonMenuItem6.setText(Locale.FRENCH.getDisplayLanguage(Locale.getDefault())); jRadioButtonMenuItem6.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButtonMenuItem6ActionPerformed(evt); } }); jMenu10.add(jRadioButtonMenuItem6); buttonGroup3.add(jRadioButtonMenuItem3); jRadioButtonMenuItem3.setText(Locale.GERMAN.getDisplayLanguage(Locale.getDefault())); jRadioButtonMenuItem3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButtonMenuItem3ActionPerformed(evt); } }); jMenu10.add(jRadioButtonMenuItem3); buttonGroup3.add(jRadioButtonMenuItem5); jRadioButtonMenuItem5.setText(Locale.ITALIAN.getDisplayLanguage(Locale.getDefault())); jRadioButtonMenuItem5.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButtonMenuItem5ActionPerformed(evt); } }); jMenu10.add(jRadioButtonMenuItem5); jMenuBar2.add(jMenu10); jMenu7.setText(bundle.getString("MainFrame_Database")); // NOI18N jMenuItem8.setText(bundle.getString("MainFrame_StockDatabase...")); // NOI18N jMenuItem8.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem8ActionPerformed(evt); } }); jMenu7.add(jMenuItem8); jMenuBar2.add(jMenu7); jMenu9.setText(bundle.getString("MainFrame_Watchlist")); // NOI18N jMenu9.addMenuListener(new javax.swing.event.MenuListener() { public void menuCanceled(javax.swing.event.MenuEvent evt) { } public void menuDeselected(javax.swing.event.MenuEvent evt) { } public void menuSelected(javax.swing.event.MenuEvent evt) { jMenu9MenuSelected(evt); } }); jMenuBar2.add(jMenu9); jMenu8.setText(bundle.getString("MainFrame_Portfolio")); // NOI18N jMenu8.addMenuListener(new javax.swing.event.MenuListener() { public void menuCanceled(javax.swing.event.MenuEvent evt) { } public void menuDeselected(javax.swing.event.MenuEvent evt) { } public void menuSelected(javax.swing.event.MenuEvent evt) { jMenu8MenuSelected(evt); } }); jMenuBar2.add(jMenu8); jMenu1.setText(bundle.getString("MainFrame_Options")); // NOI18N jMenuItem6.setText(bundle.getString("MainFrame_Options...")); // NOI18N jMenuItem6.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem6ActionPerformed(evt); } }); jMenu1.add(jMenuItem6); jMenuBar2.add(jMenu1); jMenu4.setText(bundle.getString("MainFrame_LooknFeel")); // NOI18N jMenuBar2.add(jMenu4); jMenu2.setText(bundle.getString("MainFrame_Help")); // NOI18N jMenuItem3.setText(bundle.getString("MainFrame_OnlineHelp")); // NOI18N jMenuItem3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem3ActionPerformed(evt); } }); jMenu2.add(jMenuItem3); jMenuItem16.setText(bundle.getString("MainFrame_KeyboardShortcuts")); // NOI18N jMenuItem16.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem16ActionPerformed(evt); } }); jMenu2.add(jMenuItem16); jMenuItem12.setText(bundle.getString("MainFrame_Calculator")); // NOI18N jMenuItem12.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem12ActionPerformed(evt); } }); jMenu2.add(jMenuItem12); jMenu2.add(jSeparator6); jMenuItem13.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/16x16/smile2.png"))); // NOI18N jMenuItem13.setText(bundle.getString("MainFrame_DonateToJStock")); // NOI18N jMenuItem13.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem13ActionPerformed(evt); } }); jMenu2.add(jMenuItem13); jMenuItem14.setText(bundle.getString("MainFrame_ContributeToJStock")); // NOI18N jMenuItem14.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem14ActionPerformed(evt); } }); jMenu2.add(jMenuItem14); jMenu2.add(jSeparator5); jMenuItem5.setText(bundle.getString("MainFrame_About...")); // NOI18N jMenuItem5.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem5ActionPerformed(evt); } }); jMenu2.add(jMenuItem5); jMenuBar2.add(jMenu2); jMenu11.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/16x16/android-small.png"))); // NOI18N jMenu11.setText(bundle.getString("MainFrame_Android")); // NOI18N jMenu11.setFont(jMenu11.getFont().deriveFont(jMenu11.getFont().getStyle() | java.awt.Font.BOLD)); jMenuItem17.setText(bundle.getString("MainFrame_DownloadJStockAndroid")); // NOI18N jMenuItem17.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem17ActionPerformed(evt); } }); jMenu11.add(jMenuItem17); jMenuBar2.add(jMenu11); setJMenuBar(jMenuBar2); setSize(new java.awt.Dimension(952, 478)); setLocationRelativeTo(null); }
From source file:org.yccheok.jstock.gui.JStock.java
/** This method is called from within the constructor to * initialize the form./*from ww w . ja va 2 s . co m*/ * 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() { buttonGroup1 = new javax.swing.ButtonGroup(); buttonGroup2 = new javax.swing.ButtonGroup(); buttonGroup3 = new javax.swing.ButtonGroup(); buttonGroup4 = new javax.swing.ButtonGroup(); jComboBox1 = new AutoCompleteJComboBox(); jPanel6 = new javax.swing.JPanel(); jTabbedPane1 = new javax.swing.JTabbedPane(); jPanel8 = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); jTable1 = new javax.swing.JTable(); jPanel1 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jPanel10 = new javax.swing.JPanel(); jPanel3 = new javax.swing.JPanel(); jPanel2 = new javax.swing.JPanel(); jMenuBar2 = new javax.swing.JMenuBar(); jMenu3 = new javax.swing.JMenu(); jMenuItem2 = new javax.swing.JMenuItem(); jMenuItem9 = new javax.swing.JMenuItem(); jSeparator7 = new javax.swing.JPopupMenu.Separator(); jMenuItem11 = new javax.swing.JMenuItem(); jMenuItem10 = new javax.swing.JMenuItem(); jSeparator8 = new javax.swing.JPopupMenu.Separator(); jMenuItem1 = new javax.swing.JMenuItem(); jMenu5 = new javax.swing.JMenu(); jMenuItem4 = new javax.swing.JMenuItem(); jMenuItem7 = new javax.swing.JMenuItem(); jSeparator4 = new javax.swing.JPopupMenu.Separator(); jMenuItem15 = new javax.swing.JMenuItem(); jMenu6 = new javax.swing.JMenu(); jMenu10 = new javax.swing.JMenu(); jRadioButtonMenuItem1 = new javax.swing.JRadioButtonMenuItem(); jRadioButtonMenuItem2 = new javax.swing.JRadioButtonMenuItem(); jRadioButtonMenuItem4 = new javax.swing.JRadioButtonMenuItem(); jRadioButtonMenuItem6 = new javax.swing.JRadioButtonMenuItem(); jRadioButtonMenuItem3 = new javax.swing.JRadioButtonMenuItem(); jRadioButtonMenuItem5 = new javax.swing.JRadioButtonMenuItem(); jMenu7 = new javax.swing.JMenu(); jMenuItem8 = new javax.swing.JMenuItem(); jMenu9 = new javax.swing.JMenu(); jMenu8 = new javax.swing.JMenu(); jMenu1 = new javax.swing.JMenu(); jMenuItem6 = new javax.swing.JMenuItem(); jMenu4 = new javax.swing.JMenu(); jMenu2 = new javax.swing.JMenu(); jMenuItem3 = new javax.swing.JMenuItem(); jMenuItem16 = new javax.swing.JMenuItem(); jMenuItem12 = new javax.swing.JMenuItem(); jSeparator6 = new javax.swing.JPopupMenu.Separator(); jMenuItem13 = new javax.swing.JMenuItem(); jMenuItem14 = new javax.swing.JMenuItem(); jSeparator5 = new javax.swing.JPopupMenu.Separator(); jMenuItem5 = new javax.swing.JMenuItem(); jMenu11 = new javax.swing.JMenu(); jMenuItem17 = new javax.swing.JMenuItem(); jComboBox1.setEditable(true); jComboBox1.setPreferredSize(new java.awt.Dimension(150, 24)); ((AutoCompleteJComboBox) this.jComboBox1).attachStockInfoObserver(getStockInfoObserver()); ((AutoCompleteJComboBox) this.jComboBox1).attachDispObserver(getDispObserver()); setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/gui"); // NOI18N setTitle(bundle.getString("MainFrame_Application_Title")); // NOI18N setIconImage(getMyIconImage()); addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { formMouseClicked(evt); } }); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosed(java.awt.event.WindowEvent evt) { formWindowClosed(evt); } public void windowClosing(java.awt.event.WindowEvent evt) { formWindowClosing(evt); } public void windowDeiconified(java.awt.event.WindowEvent evt) { formWindowDeiconified(evt); } public void windowIconified(java.awt.event.WindowEvent evt) { formWindowIconified(evt); } }); getContentPane().setLayout(new java.awt.BorderLayout(5, 5)); jPanel6.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); jPanel6.setLayout(new java.awt.BorderLayout(5, 5)); this.jPanel6.add(statusBar, java.awt.BorderLayout.SOUTH); getContentPane().add(jPanel6, java.awt.BorderLayout.SOUTH); jTabbedPane1.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); jTabbedPane1.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { jTabbedPane1StateChanged(evt); } }); jPanel8.setLayout(new java.awt.BorderLayout(5, 5)); jTable1.setAutoCreateRowSorter(true); jTable1.setFont(jTable1.getFont().deriveFont(jTable1.getFont().getStyle() | java.awt.Font.BOLD, jTable1.getFont().getSize() + 1)); jTable1.setModel(new StockTableModel()); jTable1.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF); this.jTable1.setDefaultRenderer(Number.class, new StockTableCellRenderer(SwingConstants.RIGHT)); this.jTable1.setDefaultRenderer(Double.class, new StockTableCellRenderer(SwingConstants.RIGHT)); this.jTable1.setDefaultRenderer(Object.class, new StockTableCellRenderer(SwingConstants.LEFT)); this.jTable1.setDefaultEditor(Double.class, new NonNegativeDoubleEditor()); this.jTable1.getModel().addTableModelListener(this.getTableModelListener()); this.jTable1.getTableHeader().addMouseListener(new TableColumnSelectionPopupListener(1)); this.jTable1.addMouseListener(new TableMouseAdapter()); this.jTable1.addKeyListener(new TableKeyEventListener()); if (jStockOptions.useLargeFont()) { this.jTable1.setRowHeight((int) (this.jTable1.getRowHeight() * Constants.FONT_ENLARGE_FACTOR)); } jTable1.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { jTable1KeyPressed(evt); } }); jScrollPane1.setViewportView(jTable1); jPanel8.add(jScrollPane1, java.awt.BorderLayout.CENTER); jLabel1.setText(bundle.getString("MainFrame_Stock")); // NOI18N jPanel1.add(jLabel1); jPanel8.add(jPanel1, java.awt.BorderLayout.NORTH); jPanel10.setPreferredSize(new java.awt.Dimension(328, 170)); jPanel10.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT, 10, 5)); jPanel3.setBackground(new java.awt.Color(255, 255, 255)); jPanel3.setPreferredSize(new java.awt.Dimension(170, 160)); jPanel3.setBorder(new org.jdesktop.swingx.border.DropShadowBorder(true)); jPanel3.setLayout(new java.awt.BorderLayout()); jPanel10.add(jPanel3); EMPTY_DYNAMIC_CHART.getChartPanel().addMouseListener(dynamicChartMouseAdapter); jPanel3.add(EMPTY_DYNAMIC_CHART.getChartPanel(), java.awt.BorderLayout.CENTER); jPanel8.add(jPanel10, java.awt.BorderLayout.SOUTH); jTabbedPane1.addTab(bundle.getString("MainFrame_Title"), jPanel8); // NOI18N getContentPane().add(jTabbedPane1, java.awt.BorderLayout.CENTER); jPanel2.setLayout(new java.awt.GridLayout(2, 1)); getContentPane().add(jPanel2, java.awt.BorderLayout.NORTH); jMenu3.setText(bundle.getString("MainFrame_File")); // NOI18N jMenuItem2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/16x16/project_open.png"))); // NOI18N jMenuItem2.setText(bundle.getString("MainFrame_Open...")); // NOI18N jMenuItem2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem2ActionPerformed(evt); } }); jMenu3.add(jMenuItem2); jMenuItem9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/16x16/filesave.png"))); // NOI18N jMenuItem9.setText(bundle.getString("MainFrame_SaveAs...")); // NOI18N jMenuItem9.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem9ActionPerformed(evt); } }); jMenu3.add(jMenuItem9); jMenu3.add(jSeparator7); jMenuItem11.setIcon( new javax.swing.ImageIcon(getClass().getResource("/images/16x16/download_from_cloud.png"))); // NOI18N jMenuItem11.setText(bundle.getString("MainFrame_OpenFromCloud...")); // NOI18N jMenuItem11.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem11ActionPerformed(evt); } }); jMenu3.add(jMenuItem11); jMenuItem10.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/16x16/upload_to_cloud.png"))); // NOI18N jMenuItem10.setText(bundle.getString("MainFrame_SaveToCloud...")); // NOI18N jMenuItem10.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem10ActionPerformed(evt); } }); jMenu3.add(jMenuItem10); jMenu3.add(jSeparator8); jMenuItem1.setText(bundle.getString("MainFrame_Exit")); // NOI18N jMenuItem1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem1ActionPerformed(evt); } }); jMenu3.add(jMenuItem1); jMenuBar2.add(jMenu3); jMenu5.setText(bundle.getString("MainFrame_Edit")); // NOI18N jMenuItem4.setText(bundle.getString("MainFrame_AddStocks...")); // NOI18N jMenuItem4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem4ActionPerformed(evt); } }); jMenu5.add(jMenuItem4); jMenuItem7.setText(bundle.getString("MainFrame_ClearAllStocks")); // NOI18N jMenuItem7.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem7ActionPerformed(evt); } }); jMenu5.add(jMenuItem7); jMenu5.add(jSeparator4); jMenuItem15.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_R, java.awt.event.InputEvent.CTRL_MASK)); jMenuItem15.setText(bundle.getString("MainFrame_RefreshStockPrices")); // NOI18N jMenuItem15.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem15ActionPerformed(evt); } }); jMenu5.add(jMenuItem15); jMenuBar2.add(jMenu5); jMenu6.setText(bundle.getString("MainFrame_Country")); // NOI18N jMenu6.addMenuListener(new javax.swing.event.MenuListener() { public void menuCanceled(javax.swing.event.MenuEvent evt) { } public void menuDeselected(javax.swing.event.MenuEvent evt) { } public void menuSelected(javax.swing.event.MenuEvent evt) { jMenu6MenuSelected(evt); } }); jMenuBar2.add(jMenu6); jMenu10.setText(bundle.getString("MainFrame_Language")); // NOI18N buttonGroup3.add(jRadioButtonMenuItem1); jRadioButtonMenuItem1.setSelected(true); jRadioButtonMenuItem1.setText(Locale.ENGLISH.getDisplayLanguage(Locale.getDefault())); jRadioButtonMenuItem1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButtonMenuItem1ActionPerformed(evt); } }); jMenu10.add(jRadioButtonMenuItem1); buttonGroup3.add(jRadioButtonMenuItem2); jRadioButtonMenuItem2.setText(Locale.SIMPLIFIED_CHINESE.getDisplayName(Locale.getDefault())); jRadioButtonMenuItem2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButtonMenuItem2ActionPerformed(evt); } }); jMenu10.add(jRadioButtonMenuItem2); buttonGroup3.add(jRadioButtonMenuItem4); jRadioButtonMenuItem4.setText(Locale.TRADITIONAL_CHINESE.getDisplayName(Locale.getDefault())); jRadioButtonMenuItem4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButtonMenuItem4ActionPerformed(evt); } }); jMenu10.add(jRadioButtonMenuItem4); buttonGroup3.add(jRadioButtonMenuItem6); jRadioButtonMenuItem6.setText(Locale.FRENCH.getDisplayLanguage(Locale.getDefault())); jRadioButtonMenuItem6.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButtonMenuItem6ActionPerformed(evt); } }); jMenu10.add(jRadioButtonMenuItem6); buttonGroup3.add(jRadioButtonMenuItem3); jRadioButtonMenuItem3.setText(Locale.GERMAN.getDisplayLanguage(Locale.getDefault())); jRadioButtonMenuItem3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButtonMenuItem3ActionPerformed(evt); } }); jMenu10.add(jRadioButtonMenuItem3); buttonGroup3.add(jRadioButtonMenuItem5); jRadioButtonMenuItem5.setText(Locale.ITALIAN.getDisplayLanguage(Locale.getDefault())); jRadioButtonMenuItem5.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButtonMenuItem5ActionPerformed(evt); } }); jMenu10.add(jRadioButtonMenuItem5); jMenuBar2.add(jMenu10); jMenu7.setText(bundle.getString("MainFrame_Database")); // NOI18N jMenuItem8.setText(bundle.getString("MainFrame_StockDatabase...")); // NOI18N jMenuItem8.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem8ActionPerformed(evt); } }); jMenu7.add(jMenuItem8); jMenuBar2.add(jMenu7); jMenu9.setText(bundle.getString("MainFrame_Watchlist")); // NOI18N jMenu9.addMenuListener(new javax.swing.event.MenuListener() { public void menuCanceled(javax.swing.event.MenuEvent evt) { } public void menuDeselected(javax.swing.event.MenuEvent evt) { } public void menuSelected(javax.swing.event.MenuEvent evt) { jMenu9MenuSelected(evt); } }); jMenuBar2.add(jMenu9); jMenu8.setText(bundle.getString("MainFrame_Portfolio")); // NOI18N jMenu8.addMenuListener(new javax.swing.event.MenuListener() { public void menuCanceled(javax.swing.event.MenuEvent evt) { } public void menuDeselected(javax.swing.event.MenuEvent evt) { } public void menuSelected(javax.swing.event.MenuEvent evt) { jMenu8MenuSelected(evt); } }); jMenuBar2.add(jMenu8); jMenu1.setText(bundle.getString("MainFrame_Options")); // NOI18N jMenuItem6.setText(bundle.getString("MainFrame_Options...")); // NOI18N jMenuItem6.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem6ActionPerformed(evt); } }); jMenu1.add(jMenuItem6); jMenuBar2.add(jMenu1); jMenu4.setText(bundle.getString("MainFrame_LooknFeel")); // NOI18N jMenuBar2.add(jMenu4); jMenu2.setText(bundle.getString("MainFrame_Help")); // NOI18N jMenuItem3.setText(bundle.getString("MainFrame_OnlineHelp")); // NOI18N jMenuItem3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem3ActionPerformed(evt); } }); jMenu2.add(jMenuItem3); jMenuItem16.setText(bundle.getString("MainFrame_KeyboardShortcuts")); // NOI18N jMenuItem16.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem16ActionPerformed(evt); } }); jMenu2.add(jMenuItem16); jMenuItem12.setText(bundle.getString("MainFrame_Calculator")); // NOI18N jMenuItem12.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem12ActionPerformed(evt); } }); jMenu2.add(jMenuItem12); jMenu2.add(jSeparator6); jMenuItem13.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/16x16/smile2.png"))); // NOI18N jMenuItem13.setText(bundle.getString("MainFrame_DonateToJStock")); // NOI18N jMenuItem13.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem13ActionPerformed(evt); } }); jMenu2.add(jMenuItem13); jMenuItem14.setText(bundle.getString("MainFrame_ContributeToJStock")); // NOI18N jMenuItem14.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem14ActionPerformed(evt); } }); jMenu2.add(jMenuItem14); jMenu2.add(jSeparator5); jMenuItem5.setText(bundle.getString("MainFrame_About...")); // NOI18N jMenuItem5.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem5ActionPerformed(evt); } }); jMenu2.add(jMenuItem5); jMenuBar2.add(jMenu2); jMenu11.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/16x16/android-small.png"))); // NOI18N jMenu11.setText(bundle.getString("MainFrame_Android")); // NOI18N jMenu11.setFont(jMenu11.getFont().deriveFont(jMenu11.getFont().getStyle() | java.awt.Font.BOLD)); jMenuItem17.setText(bundle.getString("MainFrame_DownloadJStockAndroid")); // NOI18N jMenuItem17.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem17ActionPerformed(evt); } }); jMenu11.add(jMenuItem17); jMenuBar2.add(jMenu11); setJMenuBar(jMenuBar2); setSize(new java.awt.Dimension(952, 478)); setLocationRelativeTo(null); }
From source file:org.yccheok.jstock.gui.Utils.java
/** * Returns true if the given locale is simplified chinese. * * @param locale the locale/*from ww w.java 2 s. c om*/ * @return true if the given locale is simplified chinese */ public static boolean isSimplifiedChinese(Locale locale) { // I assume every country in this world is using simplified chinese, // except Taiwan (Locale.TRADITIONAL_CHINESE.getCountry). But, how // about Hong Kong? Note that, we cannot just simply compare by using // Locale.getLanguage, as both Locale.SIMPLIFIED_CHINESE.getLanguage // and Locale.TRADITIONAL_CHINESE.getLanguage are having same value. return locale.getLanguage().equals(Locale.SIMPLIFIED_CHINESE.getLanguage()) && !locale.getCountry().equals(Locale.TRADITIONAL_CHINESE.getCountry()); }
From source file:org.yccheok.jstock.gui.Utils.java
/** * Returns true if given locale is traditional chinese. * // w w w .j av a2 s. c o m * @param locale the locale * @return true if given locale is traditional chinese */ public static boolean isTraditionalChinese(Locale locale) { // I assume every country in this world is using simplified chinese, // except Taiwan (Locale.TRADITIONAL_CHINESE.getCountry). But, how // about Hong Kong? Note that, we cannot just simply compare by using // Locale.getLanguage, as both Locale.SIMPLIFIED_CHINESE.getLanguage // and Locale.TRADITIONAL_CHINESE.getLanguage are having same value. return locale.getLanguage().equals(Locale.TRADITIONAL_CHINESE.getLanguage()) && locale.getCountry().equals(Locale.TRADITIONAL_CHINESE.getCountry()); }
From source file:com.projity.contrib.calendar.JXXMonthView.java
public static boolean isChinese() { Locale locale = Locale.getDefault(); return locale.equals(Locale.SIMPLIFIED_CHINESE) || locale.equals(Locale.TRADITIONAL_CHINESE); }
From source file:org.yccheok.jstock.gui.JStock.java
private void jRadioButtonMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButtonMenuItem2ActionPerformed // Avoid from Confirm Dialog to pop up when user change to same language (i.e. simplified chinese) if (false == Utils.isSimplifiedChinese(this.jStockOptions.getLocale())) { // Do not suprise user with sudden restart. Ask for their permission to do so. final int result = JOptionPane.showConfirmDialog(this, MessagesBundle.getString("question_message_restart_now"), MessagesBundle.getString("question_title_restart_now"), JOptionPane.YES_NO_OPTION); if (result == JOptionPane.YES_OPTION) { String country = Locale.TRADITIONAL_CHINESE.getCountry().equals(Locale.getDefault().getCountry()) ? Locale.SIMPLIFIED_CHINESE.getCountry() : Locale.getDefault().getCountry(); final Locale locale = new Locale(Locale.SIMPLIFIED_CHINESE.getLanguage(), country, Locale.getDefault().getVariant()); this.jStockOptions.setLocale(locale); org.yccheok.jstock.gui.Utils.restartApplication(this); } // return to the previous selection if the user press "no" in the dialog else {/* w ww .ja v a2 s. c o m*/ if (this.jStockOptions.getLocale().getLanguage().compareTo(Locale.ENGLISH.getLanguage()) == 0) { this.jRadioButtonMenuItem1.setSelected(true); } else if (Utils.isTraditionalChinese(this.jStockOptions.getLocale())) { this.jRadioButtonMenuItem4.setSelected(true); } else if (this.jStockOptions.getLocale().getLanguage() .compareTo(Locale.GERMAN.getLanguage()) == 0) { this.jRadioButtonMenuItem3.setSelected(true); } else if (this.jStockOptions.getLocale().getLanguage() .compareTo(Locale.ITALIAN.getLanguage()) == 0) { this.jRadioButtonMenuItem5.setSelected(true); } else if (this.jStockOptions.getLocale().getLanguage() .compareTo(Locale.FRENCH.getLanguage()) == 0) { this.jRadioButtonMenuItem6.setSelected(true); } } } }
From source file:org.yccheok.jstock.gui.JStock.java
private void jRadioButtonMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButtonMenuItem4ActionPerformed // Avoid from Confirm Dialog to pop up when user change to same language (i.e. german) if (false == Utils.isTraditionalChinese(this.jStockOptions.getLocale())) { // Do not suprise user with sudden restart. Ask for their permission to do so. final int result = JOptionPane.showConfirmDialog(this, MessagesBundle.getString("question_message_restart_now"), MessagesBundle.getString("question_title_restart_now"), JOptionPane.YES_NO_OPTION); if (result == JOptionPane.YES_OPTION) { // Unline simplified chinese, we will not use Locale.getDefault().getCountry(). // Instead, we will be using Locale.TRADITIONAL_CHINESE.getCountry(). final Locale locale = new Locale(Locale.TRADITIONAL_CHINESE.getLanguage(), Locale.TRADITIONAL_CHINESE.getCountry(), Locale.getDefault().getVariant()); this.jStockOptions.setLocale(locale); org.yccheok.jstock.gui.Utils.restartApplication(this); } // return to the previous selection if the user press "no" in the dialog else {// w ww . j a v a 2s . c o m if (this.jStockOptions.getLocale().getLanguage().compareTo(Locale.ENGLISH.getLanguage()) == 0) { this.jRadioButtonMenuItem1.setSelected(true); } else if (Utils.isSimplifiedChinese(this.jStockOptions.getLocale())) { this.jRadioButtonMenuItem2.setSelected(true); } else if (this.jStockOptions.getLocale().getLanguage() .compareTo(Locale.GERMAN.getLanguage()) == 0) { this.jRadioButtonMenuItem3.setSelected(true); } else if (this.jStockOptions.getLocale().getLanguage() .compareTo(Locale.ITALIAN.getLanguage()) == 0) { this.jRadioButtonMenuItem5.setSelected(true); } else if (this.jStockOptions.getLocale().getLanguage() .compareTo(Locale.FRENCH.getLanguage()) == 0) { this.jRadioButtonMenuItem6.setSelected(true); } } } }