Example usage for java.text DecimalFormat setMaximumFractionDigits

List of usage examples for java.text DecimalFormat setMaximumFractionDigits

Introduction

In this page you can find the example usage for java.text DecimalFormat setMaximumFractionDigits.

Prototype

@Override
public void setMaximumFractionDigits(int newValue) 

Source Link

Document

Sets the maximum number of digits allowed in the fraction portion of a number.

Usage

From source file:kobytest.KobyTest.java

public static void conectar() {
    final int clientId = 1;
    final int port = 4001;
    final String host = "127.0.0.1";

    //EReader ereader = new EReader();
    final EWrapper anyWrapper = new EWrapper() {

        @Override/*  www.j av  a  2  s. com*/
        public void error(Exception e) {
            System.out.println("error(exception):" + e.toString());
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void error(String str) {
            System.out.println("error(string):" + str);
            //throw new UnsupportedOperationException("Not error yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void error(int id, int errorCode, String errorMsg) {
            //  System.out.println("id:" + id + ". errorcode:" + errorCode + ". msg: " + errorMsg);

            // throw new UnsupportedOperationException(errorMsg); //To change body of generated methods, choose Tools | Templates.
            wrapper_error(id, errorCode, errorMsg);
        }

        @Override
        public void connectionClosed() {
            //JOptionPane.showMessageDialog(null,"Tws cerro flujo de datos", "DATA NULL", JOptionPane.ERROR_MESSAGE);
            System.out.println("Connection closed");
            //   throw new UnsupportedOperationException("Not connectionClosed yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void tickPrice(int tickerId, int field, double price, int canAutoExecute) {
            if (isDebugConsoleMode)
                System.out.println("Entra tickPrice");
            wrapper_valor(tickerId, field, price);

            if (isDebugConsoleMode)
                System.out.println(
                        "Returned tickPrice for :" + tickerId + ". field:" + field + ". Price" + price);
            //  throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void tickSize(int tickerId, int field, int size) {
            if (isDebugConsoleMode)
                System.out.println("Returned tickSize for :" + tickerId + ". field:" + field + ". size" + size);
            //   throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void tickOptionComputation(int tickerId, int field, double impliedVol, double delta,
                double optPrice, double pvDividend, double gamma, double vega, double theta, double undPrice) {
            if (isDebugConsoleMode)
                System.out.println("Returned tickOptionComputation for :" + tickerId + ". " + "field:" + field
                        + ". " + "impliedVol" + impliedVol + ". " + "delta " + delta + ".  " + "optPrice"
                        + optPrice + ".  " + "pvDividend" + pvDividend + ".  " + "gamma" + gamma + ".  "
                        + "vega" + vega + ".  " + "theta" + theta + ".  " + "undPrice" + undPrice + ".  ");

            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void tickGeneric(int tickerId, int tickType, double value) {
            System.out.println(
                    "Returned tickGeneric for :" + tickerId + ". tickType:" + tickType + ". value" + value);
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void tickString(int tickerId, int tickType, String value) {
            System.out.println(
                    "Returned tickString for :" + tickerId + ". tickType:" + tickType + ". value" + value);
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void tickEFP(int tickerId, int tickType, double basisPoints, String formattedBasisPoints,
                double impliedFuture, int holdDays, String futureExpiry, double dividendImpact,
                double dividendsToExpiry) {
            if (isDebugConsoleMode)
                System.out.println("Returned tickGeneric for :" + tickerId + ". " + "basisPoints:" + basisPoints
                        + ". " + "formattedBasisPoints:" + formattedBasisPoints + ". " + "impliedFuture:"
                        + impliedFuture + ". " + "holdDays:" + holdDays + ". " + "futureExpiry:" + futureExpiry
                        + ". " + "dividendImpact:" + dividendImpact + ". " + "dividendsToExpiry:"
                        + dividendsToExpiry + ". ");
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void orderStatus(int orderId, String status, int filled, int remaining, double avgFillPrice,
                int permId, int parentId, double lastFillPrice, int clientId, String whyHeld) {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void openOrder(int orderId, Contract contract, Order order, OrderState orderState) {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void openOrderEnd() {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }
        // ==================================================  
        // ==================================================  
        // ==================================================      
        // ==================================================    

        Double netLiquidation = 0.0;
        Double excessLiquidation = 0.0;

        @Override
        public void updateAccountValue(String key, String value, String currency, String accountName) {
            if (semaforo.Semaforo.isDebugMode)
                System.out.println("TWSClientInterface:updateAccountValue: Key: " + key + " value:" + value
                        + " currency:" + currency + " accountName:" + accountName);

            switch (key) {
            case "NetLiquidation":
                netLiquidation = Double.parseDouble(value);
                break;
            case "ExcessLiquidity":
                excessLiquidation = Double.parseDouble(value);
                break;
            }

            //                if (netLiquidation <> 0 && excessLiquidation <> 0 ) {
            Double temp = ((netLiquidation - excessLiquidation) / netLiquidation) * 100;
            Controller.getSettings().setPorcentCapital(temp);
            //                    
            //                } 

            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }
        // ==================================================  
        // ==================================================  
        // ==================================================      
        // ==================================================    

        // ==================================================  
        // ==================================================  
        // ==================================================      
        // ==================================================    
        @Override
        public void updateAccountTime(String timeStamp) {
            if (semaforo.Semaforo.isDebugMode)
                System.out.println("TWSClientInterface:updateAccountTime: " + timeStamp);
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void accountDownloadEnd(String accountName) {
            if (semaforo.Semaforo.isDebugMode)
                System.out.println("TWSClientInterface:accountDownloadEnd: " + accountName);
            //listener.guardaNumPos(78);
        }

        @Override
        public void nextValidId(int orderId) {
            System.out.println("Ya estamos coenctados con el orderId: " + orderId);

            try {
                conexion_aceptada_wrapper();
            } catch (SQLException ex) {
                Logger.getLogger(KobyTest.class.getName()).log(Level.SEVERE, null, ex);
            } catch (ParseException ex) {
                Logger.getLogger(KobyTest.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

        @Override
        public void contractDetails(int reqId, ContractDetails contractDetails) {
            System.out.println(
                    ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" + contractDetails.m_summary.m_secType); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void bondContractDetails(int reqId, ContractDetails contractDetails) {
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void contractDetailsEnd(int reqId) {
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void execDetails(int reqId, Contract contract, Execution execution) {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void execDetailsEnd(int reqId) {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void updateMktDepth(int tickerId, int position, int operation, int side, double price,
                int size) {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void updateMktDepthL2(int tickerId, int position, String marketMaker, int operation, int side,
                double price, int size) {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void updateNewsBulletin(int msgId, int msgType, String message, String origExchange) {
            System.out.println("Bulletin news");
            //  throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void managedAccounts(String accountsList) {
            System.out.println("Cuentas: " + accountsList);

            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void receiveFA(int faDataType, String xml) {
            System.out.println("Received FA");
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void historicalData(int reqId, String date, double open, double high, double low, double close,
                int volume, int count, double WAP, boolean hasGaps) {
            if (count >= 0) {
                if (!date.equals(strWeek)) {
                    Calendar cal = Calendar.getInstance();
                    int current_day = cal.get(Calendar.DAY_OF_MONTH);
                    int current_month = cal.get(Calendar.MONTH) + 1;
                    int current_year = cal.get(Calendar.YEAR);
                    String fecha = current_year + "-" + current_month + "-" + current_day;
                    DDBB.deleteLowHighFecha(fecha);
                    DDBB.insertLowHigh(symbol_current, fecha, "" + low, "" + high);
                    System.out.println("-------------------------------------" + strWeek);
                    System.out.println("HISTORICAL DATA for order_id: " + reqId);
                    System.out.println("Historical Date: " + date);
                    System.out.println("Historical Open: " + open);
                    System.out.println("Historical high: " + high);
                    System.out.println("Historical low: " + low);
                    System.out.println("Historical close: " + close);
                    System.out.println("Historical volume: " + volume);
                    System.out.println("Historical count: " + count);
                    System.out.println("Historical WAP: " + WAP);
                    System.out.println("Historical hasGaps: " + hasGaps);
                    System.out.println("-------------------------------------");
                } else {
                    ResultSet ticks = DDBB.Tickers();
                    try {
                        while (ticks.next()) {
                            if (reqId == Settings.getTickerID(ticks.getString("name"))) {
                                DDBB.updateHighHighTicker(ticks.getString("name"), high + "");
                                DDBB.updateLowLowTicker(ticks.getString("name"), low + "");
                                System.out.println(ticks.getString("name")
                                        + "-------------------------------------" + strWeek);
                                System.out.println("HISTORICAL DATA for order_id: " + reqId);
                                System.out.println("Historical Date: " + date);
                                System.out.println("Historical Open: " + open);
                                System.out.println("Historical high: " + high);
                                System.out.println("Historical low: " + low);
                                System.out.println("Historical close: " + close);
                                System.out.println("Historical volume: " + volume);
                                System.out.println("Historical count: " + count);
                                System.out.println("Historical WAP: " + WAP);
                                System.out.println("Historical hasGaps: " + hasGaps);
                                System.out.println("-------------------------------------");
                            }
                        }
                    } catch (SQLException ex) {
                        Logger.getLogger(KobyTest.class.getName()).log(Level.SEVERE, null, ex);
                    }

                }
            }
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
            //wrapper_historico(reqId, date, high, low, open, close);
        }

        @Override
        public void scannerParameters(String xml) {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void scannerData(int reqId, int rank, ContractDetails contractDetails, String distance,
                String benchmark, String projection, String legsStr) {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void scannerDataEnd(int reqId) {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void realtimeBar(int reqId, long time, double open, double high, double low, double close,
                long volume, double wap, int count) {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void currentTime(long time) {
            System.out.println("Current time is: " + time);
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void fundamentalData(int reqId, String data) {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void deltaNeutralValidation(int reqId, UnderComp underComp) {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void tickSnapshotEnd(int reqId) {
            System.out.println("tickSnapshotEnd: " + reqId);
            wrapper_snapshot_ended(reqId);
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void marketDataType(int reqId, int marketDataType) {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void commissionReport(CommissionReport commissionReport) {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        //######################################     
        //######################################        
        //######################################    
        //######################################         
        //######################################    
        //######################################     
        //######################################  
        //######################################      
        //######################################   
        //######################################  
        //######################################  
        //######################################
        //######################################     
        //######################################     

        //############ POSITION ################           

        int numPosiciones = 0;
        public int numPosicionesTotal = 0;
        public Map valorPosiciones = new HashMap();

        @Override
        public void updatePortfolio(Contract contract, int position, double marketPrice, double marketValue,
                double averageCost, double unrealizedPNL, double realizedPNL, String accountName) {
            if (contract.m_secType.equals("CFD")) {
                Semaforo.countCfd++;
            }

            if (ticP.isEmpty()) {
                ticP = contract.m_symbol;
                positionP = position;
                strikeP = contract.m_strike;
            } else {
                if (ticP.equals(contract.m_symbol)) {
                    if (strikeP > contract.m_strike) {
                        if (positionP > 0) {
                            //el mayor es positivo Bear  
                            Semaforo.countBear++;
                            System.out.println(">>>>>countBear>>>>>" + Semaforo.countBear);
                        } else {
                            //ll mayor es negativo Bull
                            Semaforo.countBull++;
                            System.out.println(">>>>>countBull>>>>>" + Semaforo.countBull);
                        }
                    } else {
                        if (position > 0) {
                            //el mayor es positivo Bear  
                            Semaforo.countBear++;
                            System.out.println(">>>>>countBear>>>>>" + Semaforo.countBear);
                        } else {
                            //ll mayor es negativo Bull
                            Semaforo.countBull++;
                            System.out.println(">>>>>countBull>>>>>" + Semaforo.countBull);
                        }
                    }
                } else {
                    ticP = contract.m_symbol;
                    positionP = position;
                    strikeP = contract.m_strike;
                }
            }

            System.out.println("TWSClientInterface:updatePortfolio: " + accountName + " " + contract.m_secType
                    + " " + contract.m_symbol + " " + position + " " + marketPrice + " " + marketValue + " "
                    + averageCost + " " + unrealizedPNL + " " + realizedPNL);
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.

        }

        @Override
        public void position(String account, Contract contract, int pos, double avgCost) {

            semaforo.LogFile.logFile("#### INVOCANDO position: " + contract.m_symbol + " y posicion: " + pos);
            double avg = (avgCost * pos) + 0.2;
            ResultSet resGruposOld = DDBB.GruposTickersTicker(contract.m_symbol);
            try {
                if (resGruposOld.next()) {

                    DDBB.updateGroupTickerInvertido(contract.m_symbol, (int) avg);

                } else {
                    DDBB.insertGroupsTickers("", contract.m_symbol, (int) avg);
                }
            } catch (SQLException ex) {
                Logger.getLogger(Groups.class.getName()).log(Level.SEVERE, null, ex);
            }

            //                System.out.println("ESTE ES EL POS TRAIDO POR TWS: ACCION: " + contract.m_symbol + " y posicion: " + pos);

            String msg = " ---- Position begin ----\n" + "account = " + account + "\n" + "conid = "
                    + contract.m_conId + "\n" + "symbol = " + contract.m_symbol + "\n" + "secType = "
                    + contract.m_secType + "\n" + "expiry = " + contract.m_expiry + "\n" + "strike = "
                    + contract.m_strike + "\n" + "right = " + contract.m_right + "\n" + "multiplier = "
                    + contract.m_multiplier + "\n" + "exchange = " + contract.m_exchange + "\n"
                    + "primaryExch = " + contract.m_primaryExch + "\n" + "currency = " + contract.m_currency
                    + "\n" + "localSymbol = " + contract.m_localSymbol + "\n" + "tradingClass = "
                    + contract.m_tradingClass + "\n" + "position = " + Util.IntMaxString(pos) + "\n"
                    + "averageCost = " + Util.DoubleMaxString(avgCost) + "\n" + " ---- Position end ----\n";

            System.out.println(msg);

            if (pos > 0) {
                numPosiciones++;
                if (contract.m_secType.compareTo("CFD") == 0)
                    valorPosiciones.put(contract.m_symbol, pos);
            }

            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void positionEnd() {

            semaforo.LogFile.logFile("#### INVOCANDO positionEnd");
            segundaPasada++;
            //                    
            connection.reqAccountUpdates(false, "U1523016");

            numPosicionesTotal = numPosiciones;
            if (segundaPasada > 1 && !graficopaint) {
                Semaforo.cfd = false;
                Semaforo.bull = false;
                Semaforo.bear = false;

                DecimalFormat df = new DecimalFormat();
                df.setMaximumFractionDigits(2);
                double cfd = 0.0;
                double bull = 0.0;
                double bear = 0.0;
                if (countCfd != 0)
                    cfd = (countCfd * 100) / (countBear + countBull + countCfd);
                if (countBull != 0)
                    bull = ((countBull * 100) / (countBear + countBull + countCfd));
                if (countBear != 0)
                    bear = ((countBear * 100) / (countBear + countBull + countCfd));
                Semaforo.l1.setText("CFD (" + String.format("%.2f", cfd) + "%)");
                Semaforo.l2.setText("BULL (" + String.format("%.2f", bull) + "%)");
                Semaforo.l3.setText("BEAR (" + String.format("%.2f", bear) + "%)");
                DefaultPieDataset pieDataset = new DefaultPieDataset();
                pieDataset.setValue("CFD (" + cfd + "%)", new Integer((int) countCfd));
                pieDataset.setValue("BULL (" + bull + "%)", new Integer((int) countBull));
                pieDataset.setValue("BEAR (" + bear + "%)", new Integer((int) countBear));
                JFreeChart chart = null;
                chart = ChartFactory.createPieChart("", // chart title
                        pieDataset, // data
                        false, // no legend
                        false, // tooltips
                        false // no URL generation
                );
                Semaforo.SemaforoGrafico(chart);

                graficopaint = true;
                Semaforo.countBear = 0.0;
                Semaforo.countBull = 0.0;
                Semaforo.countCfd = 0.0;
                System.out.println(":::::::::::::::::::::::::::::::::::::::::::::::::::::::" + segundaPasada
                        + Semaforo.countBear + Semaforo.countBull + Semaforo.countCfd);
            } else if (segundaPasada >= 2) {
                Semaforo.cfd = false;
                Semaforo.bull = false;
                Semaforo.bear = false;

                Semaforo.editGrafico();
                Semaforo.countBear = 0.0;
                Semaforo.countBull = 0.0;
                Semaforo.countCfd = 0.0;
                //                    Semaforo.countBear=Semaforo.countBear+5;
            }

            System.out.println("+++++" + posiciones);
            if (semaforo.Semaforo.edit == 0) {

                Semaforo.finalcountBear = Semaforo.countBear;
                Semaforo.finalcountBull = Semaforo.countBull;
                Semaforo.finalcountCfd = Semaforo.countCfd;

            }
            semaforo.Semaforo.edit = 1;
            listener.guardaNumPos(numPosicionesTotal);
            listener.guardaPosiciones(valorPosiciones);
            valorPosiciones = new HashMap(); // %30
            numPosiciones = 0;

            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void accountSummary(int reqId, String account, String tag, String value, String currency) {
            System.out.println("account summary");
            //  throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void accountSummaryEnd(int reqId) {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void verifyMessageAPI(String apiData) {
            System.out.println("verifyMessageAPI: " + apiData);
            // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void verifyCompleted(boolean isSuccessful, String errorText) {
            System.out.println("verifyCompleted: " + errorText);
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void displayGroupList(int reqId, String groups) {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void displayGroupUpdated(int reqId, String contractInfo) {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }
    };

    // System.out.println("Enter something here : ");

    new Thread() {

        @Override
        public void run() {
            // super.run(); //To change body of generated methods, choose Tools | Templates.

            connection = new EClientSocket(anyWrapper);
            //connection.eConnect(host, port, clientId);
            connection.eConnect(host, port, clientId);
            //esperar conexion
            while (true) {
                System.out.println("Testing if there's connection");
                boolean connected = connection.isConnected();
                if (connected) {
                    System.out.println("Conectados ! :");
                    conexion_iniciada_wrapper();
                    break;
                }

                try {
                    Thread.sleep(50);
                } catch (InterruptedException ex) {
                    Logger.getLogger(KobyTest.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }

    }.start();

}

From source file:com.redsqirl.workflow.server.connect.HDFSInterface.java

protected Map<String, String> getProperties(String path, FileStatus stat) throws RemoteException {
    Map<String, String> prop = new LinkedHashMap<String, String>();
    try {/*from  ww w.j a v  a 2  s .  co m*/
        if (stat == null) {
            logger.debug("File status not available for " + path);
            return null;
        } else {
            if (stat.isDir()) {
                prop.put(key_type, "directory");
                prop.put(key_children, "true");
            } else {
                prop.put(key_type, "file");
                prop.put(key_children, "false");
                double res = stat.getBlockSize();
                boolean end = res < 1024;
                int pow = 0;
                while (!end) {
                    res /= 1024;
                    ++pow;
                    end = res < 1024;
                }
                DecimalFormat df = new DecimalFormat();
                df.setMaximumFractionDigits(1);
                String size = df.format(res);
                if (pow == 1) {
                    size += "K";
                } else if (pow == 2) {
                    size += "M";
                } else if (pow == 3) {
                    size += "G";
                } else if (pow == 4) {
                    size += "T";
                } else if (pow == 5) {
                    size += "P";
                } else if (pow == 6) {
                    size += "E";
                } else if (pow == 7) {
                    size += "Z";
                } else if (pow == 8) {
                    size += "Y";
                }

                prop.put(key_size, size);
            }
        }
        prop.put(key_owner, stat.getOwner());
        prop.put(key_group, stat.getGroup());
        prop.put(key_permission, stat.getPermission().toString());

        // fs.close();
    } catch (Exception e) {
        logger.error("Not expected exception: " + e);
        logger.error(e.getMessage());
    }
    logger.debug("Properties of " + path + ": " + prop.toString());
    return prop;
}

From source file:editeurpanovisu.EquiCubeDialogController.java

/**
 *
 * @param strTypeTransf/*w  w  w . ja  v  a 2 s  . c om*/
 * @throws Exception Exceptions
 */
public void afficheFenetre(String strTypeTransf) throws Exception {
    lvListeFichier.getItems().clear();
    stTransformations = new Stage(StageStyle.UTILITY);
    apTransformations = new AnchorPane();
    stTransformations.initModality(Modality.APPLICATION_MODAL);
    stTransformations.setResizable(true);
    apTransformations.setStyle("-fx-background-color : #ff0000;");

    VBox vbFenetre = new VBox();
    HBox hbChoix = new HBox();
    Pane paneChoixFichier = new Pane();
    btnAjouteFichiers = new Button("Ajouter des Fichiers");
    paneChoixTypeFichier = new Pane();
    Label lblType = new Label("Type des Fichiers de sortie");
    rbJpeg = new RadioButton("JPEG (.jpg)");
    rbBmp = new RadioButton("BMP (.bmp)");
    rbTiff = new RadioButton("TIFF (.tif)");
    cbSharpen = new CheckBox("Masque de nettet");
    cbSharpen.setSelected(EditeurPanovisu.isbNetteteTransf());
    slSharpen = new Slider(0, 2, EditeurPanovisu.getNiveauNetteteTransf());
    lblSharpen = new Label();
    double lbl = (Math.round(EditeurPanovisu.getNiveauNetteteTransf() * 20.d) / 20.d);
    lblSharpen.setText(lbl + "");
    slSharpen.setDisable(!EditeurPanovisu.isbNetteteTransf());
    lblSharpen.setDisable(!EditeurPanovisu.isbNetteteTransf());
    Pane paneboutons = new Pane();
    btnAnnuler = new Button("Fermer la fentre");
    btnValider = new Button("Lancer le traitement");

    strTypeTransformation = strTypeTransf;
    Image imgTransf;
    if (strTypeTransf.equals(EquiCubeDialogController.EQUI2CUBE)) {
        stTransformations.setTitle("Transformation d'quirectangulaire en faces de cube");
        imgTransf = new Image(
                "file:" + EditeurPanovisu.getStrRepertAppli() + File.separator + "images/equi2cube.png");
    } else {
        stTransformations.setTitle("Transformation de faces de cube en quirectangulaire");
        imgTransf = new Image(
                "file:" + EditeurPanovisu.getStrRepertAppli() + File.separator + "images/cube2equi.png");
    }
    ImageView ivTypeTransfert = new ImageView(imgTransf);
    ivTypeTransfert.setLayoutX(35);
    ivTypeTransfert.setLayoutY(280);
    paneChoixTypeFichier.getChildren().add(ivTypeTransfert);
    apTransformations.setPrefHeight(EditeurPanovisu.getHauteurE2C());
    apTransformations.setPrefWidth(EditeurPanovisu.getLargeurE2C());

    paneChoixFichier.setPrefHeight(350);
    paneChoixFichier.setPrefWidth(410);
    paneChoixFichier.setStyle("-fx-background-color: #d0d0d0; -fx-border-color: #bbb;");
    paneChoixTypeFichier.setPrefHeight(350);
    paneChoixTypeFichier.setPrefWidth(180);
    paneChoixTypeFichier.setStyle("-fx-background-color: #d0d0d0; -fx-border-color: #bbb;");
    hbChoix.getChildren().addAll(paneChoixFichier, paneChoixTypeFichier);
    vbFenetre.setPrefHeight(400);
    vbFenetre.setPrefWidth(600);
    apTransformations.getChildren().add(vbFenetre);
    hbChoix.setPrefHeight(350);
    hbChoix.setPrefWidth(600);
    hbChoix.setStyle("-fx-background-color: #d0d0d0;");
    paneboutons.setPrefHeight(50);
    paneboutons.setPrefWidth(600);
    paneboutons.setStyle("-fx-background-color: #d0d0d0;");
    vbFenetre.setStyle("-fx-background-color: #d0d0d0;");
    btnAnnuler.setLayoutX(296);
    btnAnnuler.setLayoutY(10);
    btnValider.setLayoutX(433);
    btnValider.setLayoutY(10);
    lvListeFichier.setPrefHeight(290);
    lvListeFichier.setPrefWidth(380);
    lvListeFichier.setEditable(true);
    lvListeFichier.setLayoutX(14);
    lvListeFichier.setLayoutY(14);
    btnAjouteFichiers.setLayoutX(259);
    btnAjouteFichiers.setLayoutY(319);
    paneChoixFichier.getChildren().addAll(lvListeFichier, btnAjouteFichiers);
    if (strTypeTransf.equals(EquiCubeDialogController.EQUI2CUBE)) {
        lblDragDropE2C = new Label(rbLocalisation.getString("transformation.dragDropE2C"));
    } else {
        lblDragDropE2C = new Label(rbLocalisation.getString("transformation.dragDropC2E"));
    }
    lblDragDropE2C.setMinHeight(lvListeFichier.getPrefHeight());
    lblDragDropE2C.setMaxHeight(lvListeFichier.getPrefHeight());
    lblDragDropE2C.setMinWidth(lvListeFichier.getPrefWidth());
    lblDragDropE2C.setMaxWidth(lvListeFichier.getPrefWidth());
    lblDragDropE2C.setLayoutX(14);
    lblDragDropE2C.setLayoutY(14);
    lblDragDropE2C.setAlignment(Pos.CENTER);
    lblDragDropE2C.setTextFill(Color.web("#c9c7c7"));
    lblDragDropE2C.setTextAlignment(TextAlignment.CENTER);
    lblDragDropE2C.setWrapText(true);
    lblDragDropE2C.setStyle("-fx-font-size : 24px");
    lblDragDropE2C.setStyle("-fx-background-color : rgba(128,128,128,0.1)");
    paneChoixFichier.getChildren().add(lblDragDropE2C);

    lblType.setLayoutX(14);
    lblType.setLayoutY(14);
    rbBmp.setLayoutX(43);
    rbBmp.setLayoutY(43);
    rbBmp.setUserData("bmp");
    if (EditeurPanovisu.getStrTypeFichierTransf().equals("bmp")) {
        rbBmp.setSelected(true);
    }
    rbBmp.setToggleGroup(tgTypeFichier);
    rbJpeg.setLayoutX(43);
    rbJpeg.setLayoutY(71);
    rbJpeg.setUserData("jpg");
    if (EditeurPanovisu.getStrTypeFichierTransf().equals("jpg")) {
        rbJpeg.setSelected(true);
    }
    rbJpeg.setToggleGroup(tgTypeFichier);
    if (EditeurPanovisu.getStrTypeFichierTransf().equals("tif")) {
        rbTiff.setSelected(true);
    }
    rbTiff.setLayoutX(43);
    rbTiff.setLayoutY(99);
    rbTiff.setToggleGroup(tgTypeFichier);
    rbTiff.setUserData("tif");
    tgTypeFichier.selectedToggleProperty().addListener((ov, old_toggle, new_toggle) -> {
        EditeurPanovisu.setStrTypeFichierTransf(tgTypeFichier.getSelectedToggle().getUserData().toString());
    });
    cbSharpen.setLayoutX(43);
    cbSharpen.setLayoutY(127);
    cbSharpen.selectedProperty().addListener((ov, old_val, new_val) -> {
        slSharpen.setDisable(!new_val);
        lblSharpen.setDisable(!new_val);
        EditeurPanovisu.setbNetteteTransf(new_val);
    });

    slSharpen.setShowTickMarks(true);
    slSharpen.setShowTickLabels(true);
    slSharpen.setMajorTickUnit(0.5f);
    slSharpen.setMinorTickCount(4);
    slSharpen.setBlockIncrement(0.05f);
    slSharpen.setSnapToTicks(true);
    slSharpen.setLayoutX(23);
    slSharpen.setLayoutY(157);
    slSharpen.setTooltip(new Tooltip("Choisissez le niveau d'accentuation de l'image"));
    slSharpen.valueProperty().addListener((observableValue, oldValue, newValue) -> {
        if (newValue == null) {
            lblSharpen.setText("");
            return;
        }
        DecimalFormat dfArrondi = new DecimalFormat();
        dfArrondi.setMaximumFractionDigits(2); //arrondi  2 chiffres apres la virgules
        dfArrondi.setMinimumFractionDigits(2);
        dfArrondi.setDecimalSeparatorAlwaysShown(true);

        lblSharpen.setText(dfArrondi.format(Math.round(newValue.floatValue() * 20.f) / 20.f) + "");
        EditeurPanovisu.setNiveauNetteteTransf(newValue.doubleValue());
    });

    slSharpen.setPrefWidth(120);
    lblSharpen.setLayoutX(150);
    lblSharpen.setLayoutY(150);
    lblSharpen.setMinWidth(30);
    lblSharpen.setMaxWidth(30);
    lblSharpen.setTextAlignment(TextAlignment.RIGHT);

    paneChoixTypeFichier.getChildren().addAll(lblType, rbBmp, rbJpeg, rbTiff, cbSharpen, slSharpen, lblSharpen);
    pbBarreImage.setLayoutX(40);
    pbBarreImage.setLayoutY(190);
    pbBarreImage.setStyle("-fx-accent : #0000bb");
    pbBarreImage.setVisible(false);
    paneChoixTypeFichier.getChildren().add(pbBarreImage);
    pbBarreAvancement = new ProgressBar();
    pbBarreAvancement.setLayoutX(40);
    pbBarreAvancement.setLayoutY(220);
    pbBarreImage.setStyle("-fx-accent : #00bb00");
    paneChoixTypeFichier.getChildren().add(pbBarreAvancement);
    pbBarreAvancement.setVisible(false);

    paneboutons.getChildren().addAll(btnAnnuler, btnValider);
    vbFenetre.getChildren().addAll(hbChoix, paneboutons);
    Scene scnTransformations = new Scene(apTransformations);
    stTransformations.setScene(scnTransformations);
    stTransformations.show();

    btnAnnuler.setOnAction((e) -> {
        annulerE2C();
    });
    btnValider.setOnAction((e) -> {
        if (!bTraitementEffectue) {
            validerE2C();
        }
    });
    btnAjouteFichiers.setOnAction((e) -> {
        lblTermine.setText("");
        fileLstFichier = choixFichiers();
        if (fileLstFichier != null) {
            if (bTraitementEffectue) {
                lvListeFichier.getItems().clear();
                bTraitementEffectue = false;
            }
            for (File fileLstFichier1 : fileLstFichier) {
                String strNomFich = fileLstFichier1.getAbsolutePath();
                lvListeFichier.getItems().add(strNomFich);
            }
        }
    });
    lvListeFichier.setCellFactory(new Callback<ListView<String>, ListCell<String>>() {
        @Override
        public ListCell<String> call(ListView<String> list) {
            return new ListeTransformationCouleur();
        }
    });
    apTransformations.setOnDragOver((event) -> {
        Dragboard dbFichiersTransformation = event.getDragboard();
        if (dbFichiersTransformation.hasFiles()) {
            event.acceptTransferModes(TransferMode.ANY);
        } else {
            event.consume();
        }
    });
    stTransformations.widthProperty().addListener((arg0, arg1, arg2) -> {
        EditeurPanovisu.setLargeurE2C(stTransformations.getWidth());
        apTransformations.setPrefWidth(stTransformations.getWidth());
        vbFenetre.setPrefWidth(stTransformations.getWidth());
        btnAnnuler.setLayoutX(stTransformations.getWidth() - 314);
        btnValider.setLayoutX(stTransformations.getWidth() - 157);
        paneChoixFichier.setPrefWidth(stTransformations.getWidth() - 200);
        lvListeFichier.setPrefWidth(stTransformations.getWidth() - 240);
        lblDragDropE2C.setMinWidth(lvListeFichier.getPrefWidth());
        lblDragDropE2C.setMaxWidth(lvListeFichier.getPrefWidth());

        btnAjouteFichiers.setLayoutX(stTransformations.getWidth() - 341);
    });

    stTransformations.heightProperty().addListener((arg0, arg1, arg2) -> {
        EditeurPanovisu.setHauteurE2C(stTransformations.getHeight());
        apTransformations.setPrefHeight(stTransformations.getHeight());
        vbFenetre.setPrefHeight(stTransformations.getHeight());
        paneChoixFichier.setPrefHeight(stTransformations.getHeight() - 80);
        hbChoix.setPrefHeight(stTransformations.getHeight() - 80);
        lvListeFichier.setPrefHeight(stTransformations.getHeight() - 140);
        lblDragDropE2C.setMinHeight(lvListeFichier.getPrefHeight());
        lblDragDropE2C.setMaxHeight(lvListeFichier.getPrefHeight());
        btnAjouteFichiers.setLayoutY(stTransformations.getHeight() - 121);
    });
    stTransformations.setWidth(EditeurPanovisu.getLargeurE2C());
    stTransformations.setHeight(EditeurPanovisu.getHauteurE2C());
    apTransformations.setOnDragDropped((event) -> {
        Dragboard dbFichiersTransformation = event.getDragboard();
        boolean bSucces = false;
        File[] fileLstFich;
        fileLstFich = null;
        if (dbFichiersTransformation.hasFiles()) {
            lblTermine.setText("");
            bSucces = true;
            String[] stringFichiersPath = new String[200];
            int i = 0;
            for (File file1 : dbFichiersTransformation.getFiles()) {
                stringFichiersPath[i] = file1.getAbsolutePath();
                i++;
            }
            int iNb = i;
            i = 0;
            boolean bAttention = false;
            File[] fileLstFich1 = new File[stringFichiersPath.length];
            for (int j = 0; j < iNb; j++) {

                String strNomfich = stringFichiersPath[j];
                File fileTransf = new File(strNomfich);
                String strExtension = strNomfich.substring(strNomfich.lastIndexOf(".") + 1, strNomfich.length())
                        .toLowerCase();
                if (strExtension.equals("bmp") || strExtension.equals("jpg") || strExtension.equals("tif")) {
                    if (i == 0) {
                        strRepertFichier = fileTransf.getParent();
                    }
                    Image img = null;
                    if (strExtension != "tif") {
                        img = new Image("file:" + fileTransf.getAbsolutePath());
                    } else {
                        try {
                            img = ReadWriteImage.readTiff(strNomfich);
                        } catch (ImageReadException ex) {
                            Logger.getLogger(EquiCubeDialogController.class.getName()).log(Level.SEVERE, null,
                                    ex);
                        } catch (IOException ex) {
                            Logger.getLogger(EquiCubeDialogController.class.getName()).log(Level.SEVERE, null,
                                    ex);
                        }
                    }
                    if (strTypeTransformation.equals(EquiCubeDialogController.EQUI2CUBE)) {
                        if (img.getWidth() == 2 * img.getHeight()) {
                            fileLstFich1[i] = fileTransf;
                            i++;
                        } else {
                            bAttention = true;
                        }
                    } else {
                        if (img.getWidth() == img.getHeight()) {
                            String strNom = fileTransf.getAbsolutePath().substring(0,
                                    fileTransf.getAbsolutePath().length() - 6);
                            boolean bTrouve = false;
                            for (int ik = 0; ik < i; ik++) {
                                String strNom1 = fileLstFich1[ik].getAbsolutePath().substring(0,
                                        fileTransf.getAbsolutePath().length() - 6);
                                if (strNom.equals(strNom1)) {
                                    bTrouve = true;
                                }
                            }
                            if (!bTrouve) {
                                fileLstFich1[i] = fileTransf;
                                i++;
                            }
                        } else {
                            bAttention = true;
                        }

                    }
                }
            }
            if (bAttention) {
                Alert alert = new Alert(AlertType.ERROR);
                alert.setTitle(rbLocalisation.getString("transformation.traiteImages"));
                alert.setHeaderText(null);
                alert.setContentText(rbLocalisation.getString("transformation.traiteImagesType"));
                alert.showAndWait();
            }
            fileLstFichier = new File[i];
            System.arraycopy(fileLstFich1, 0, fileLstFichier, 0, i);
        }
        if (fileLstFichier != null) {
            if (bTraitementEffectue) {
                lvListeFichier.getItems().clear();
                bTraitementEffectue = false;
            }
            for (File lstFichier1 : fileLstFichier) {
                String nomFich = lstFichier1.getAbsolutePath();
                lvListeFichier.getItems().add(nomFich);
            }
        }
        lblDragDropE2C.setVisible(false);
        event.setDropCompleted(bSucces);
        event.consume();
    });

}

From source file:org.geomajas.layer.wms.WmsLayer.java

/**
 * Build the base part of the url (doesn't change for getMap or getFeatureInfo requests).
 * //from   w ww  .  ja  va  2  s. c om
 * @param targetUrl
 *            base url
 * @param width
 *            image width
 * @param height
 *            image height
 * @param box
 *            bounding box
 * @return base WMS url
 * @throws GeomajasException
 *             missing parameter
 */
private StringBuilder formatBaseUrl(String targetUrl, int width, int height, Bbox box)
        throws GeomajasException {
    try {
        StringBuilder url = new StringBuilder(targetUrl);
        int pos = url.lastIndexOf("?");
        if (pos > 0) {
            url.append("&SERVICE=WMS");
        } else {
            url.append("?SERVICE=WMS");
        }
        String layers = getId();
        if (layerInfo.getDataSourceName() != null) {
            layers = layerInfo.getDataSourceName();
        }
        url.append("&layers=");
        url.append(URLEncoder.encode(layers, "UTF8"));
        url.append("&WIDTH=");
        url.append(Integer.toString(width));
        url.append("&HEIGHT=");
        url.append(Integer.toString(height));
        DecimalFormat decimalFormat = new DecimalFormat(); // create new as this is not thread safe
        decimalFormat.setDecimalSeparatorAlwaysShown(false);
        decimalFormat.setGroupingUsed(false);
        decimalFormat.setMinimumFractionDigits(0);
        decimalFormat.setMaximumFractionDigits(100);
        DecimalFormatSymbols symbols = new DecimalFormatSymbols();
        symbols.setDecimalSeparator('.');
        decimalFormat.setDecimalFormatSymbols(symbols);

        url.append("&bbox=");
        url.append(decimalFormat.format(box.getX()));
        url.append(",");
        url.append(decimalFormat.format(box.getY()));
        url.append(",");
        url.append(decimalFormat.format(box.getMaxX()));
        url.append(",");
        url.append(decimalFormat.format(box.getMaxY()));
        url.append("&format=");
        url.append(format);
        url.append("&version=");
        url.append(version);
        if ("1.3.0".equals(version)) {
            url.append("&crs=");
        } else {
            url.append("&srs=");
        }
        url.append(URLEncoder.encode(layerInfo.getCrs(), "UTF8"));
        url.append("&styles=");
        url.append(styles);
        if (null != parameters) {
            for (Parameter p : parameters) {
                url.append("&");
                url.append(URLEncoder.encode(p.getName(), "UTF8"));
                url.append("=");
                url.append(URLEncoder.encode(p.getValue(), "UTF8"));
            }
        }
        if (useProxy && null != securityContext.getToken()) {
            url.append("&userToken=");
            url.append(securityContext.getToken());
        }
        return url;
    } catch (UnsupportedEncodingException uee) {
        throw new IllegalStateException("Cannot find UTF8 encoding?", uee);
    }
}

From source file:org.yccheok.jstock.gui.NewBuyTransactionJDialog.java

private void initComponentsWithFeeCalculationDisabled() {
    jComboBox1 = new AutoCompleteJComboBox();
    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();
    jFormattedTextField2 = getCurrencyJFormattedTextField();
    jLabel10 = new javax.swing.JLabel();
    jFormattedTextField6 = getCurrencyJFormattedTextField();

    jFormattedTextField3 = getCurrencyJFormattedTextField();
    jFormattedTextField4 = getCurrencyJFormattedTextField();
    jFormattedTextField5 = getCurrencyJFormattedTextField();

    jFormattedTextField3.setValue(new Double(0.0));
    jFormattedTextField4.setValue(new Double(0.0));
    jFormattedTextField5.setValue(new Double(0.0));

    jLabel1 = new javax.swing.JLabel();
    jLabel3 = new javax.swing.JLabel();
    jLabel5 = new javax.swing.JLabel();
    jLabel11 = new javax.swing.JLabel();
    jTextField2 = new javax.swing.JTextField();
    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();

    jComboBox1.setEditable(true);/*from   w w  w  .  jav  a2 s  . c o  m*/
    jComboBox1.setPreferredSize(new java.awt.Dimension(110, 24));
    ((AutoCompleteJComboBox) jComboBox1).attachStockInfoObserver(this.getStockInfoObserver());
    ((AutoCompleteJComboBox) jComboBox1).attachDispObserver(this.getDispObserver());

    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/gui"); // NOI18N
    setTitle(bundle.getString("NewBuyTransactionJDialog_Buy")); // NOI18N
    setResizable(false);
    addWindowListener(new java.awt.event.WindowAdapter() {
        public void windowClosed(java.awt.event.WindowEvent evt) {
            formWindowClosed(evt);
        }
    });

    jPanel2.setBorder(javax.swing.BorderFactory
            .createTitledBorder(bundle.getString("NewBuyTransactionJDialog_Transaction"))); // NOI18N

    jLabel2.setText(bundle.getString("NewSellTransactionJDialog_Symbol")); // NOI18N

    jSpinner1.setModel(new javax.swing.SpinnerNumberModel(100.0d, 0.001d, null, 100.0d));
    JSpinner.NumberEditor numberEditor = (JSpinner.NumberEditor) jSpinner1.getEditor();
    final DecimalFormat decimalFormat = numberEditor.getFormat();
    decimalFormat.setMaximumFractionDigits(4);
    numberEditor.getTextField().addMouseListener(getJFormattedTextFieldMouseListener());
    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(bundle.getString("NewBuyTransactionJDialog_Date")); // NOI18N

    jFormattedTextField1.setValue(new Double(0.0));
    jFormattedTextField1.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyTyped(java.awt.event.KeyEvent evt) {
            jFormattedTextField1KeyTyped(evt);
        }
    });

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

    jLabel10.setFont(jLabel10.getFont().deriveFont(jLabel10.getFont().getStyle() | java.awt.Font.BOLD));
    jLabel10.setText(bundle.getString("NewBuyTransactionJDialog_NetValue")); // NOI18N

    jFormattedTextField6.setEditable(false);
    jFormattedTextField6.setFont(jFormattedTextField6.getFont()
            .deriveFont(jFormattedTextField6.getFont().getStyle() | java.awt.Font.BOLD));
    jFormattedTextField6.setValue(new Double(0.0));

    jLabel1.setText(bundle.getString("NewBuyTransactionJDialog_Unit")); // NOI18N

    jLabel3.setText(bundle.getString("NewBuyTransactionJDialog_Price")); // NOI18N

    jLabel5.setText(bundle.getString("NewBuyTransactionJDialog_Value")); // NOI18N

    jLabel11.setText(bundle.getString("NewBuyTransactionJDialog_Code")); // NOI18N

    jTextField2.setEditable(false);

    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)
                            .addGroup(jPanel2Layout.createSequentialGroup().addGroup(
                                    jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel11).addComponent(jLabel2).addComponent(jLabel4)
                                            .addComponent(jLabel1).addComponent(jLabel3))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addGroup(jPanel2Layout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                    109, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                    109, Short.MAX_VALUE)
                                            .addComponent(jFormattedTextField1,
                                                    javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE)
                                            .addComponent(jSpinner1, javax.swing.GroupLayout.DEFAULT_SIZE, 109,
                                                    Short.MAX_VALUE)
                                            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, 109,
                                                    Short.MAX_VALUE)))
                            .addGroup(jPanel2Layout.createSequentialGroup().addComponent(jLabel5)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(jFormattedTextField2, javax.swing.GroupLayout.DEFAULT_SIZE,
                                            109, Short.MAX_VALUE))
                            .addGroup(jPanel2Layout.createSequentialGroup().addComponent(jLabel10)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(jFormattedTextField6, javax.swing.GroupLayout.DEFAULT_SIZE,
                                            109, Short.MAX_VALUE)))
                    .addContainerGap()));

    jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
            new java.awt.Component[] { jFormattedTextField1, jFormattedTextField2, jFormattedTextField6,
                    jPanel3, jSpinner1, jTextField1 });

    jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
            new java.awt.Component[] { jLabel1, jLabel10, jLabel11, jLabel2, jLabel3, jLabel4, jLabel5 });

    jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap()
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel11).addComponent(jTextField2,
                                    javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel2))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel1))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jFormattedTextField1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel3))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jFormattedTextField2, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel5))
                    .addGap(18, 18, 18)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jFormattedTextField6, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel10))
                    .addContainerGap()));

    jPanel2Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] { jFormattedTextField1,
            jFormattedTextField2, jFormattedTextField6, jPanel3, jSpinner1, jTextField1 });

    getContentPane().add(jPanel2, java.awt.BorderLayout.CENTER);

    jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/16x16/apply.png"))); // NOI18N
    jButton1.setText(bundle.getString("NewBuyTransactionJDialog_OK")); // NOI18N
    jButton1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton1ActionPerformed(evt);
        }
    });
    jPanel4.add(jButton1);

    jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/16x16/button_cancel.png"))); // NOI18N
    jButton2.setText(bundle.getString("NewBuyTransactionJDialog_Cancel")); // NOI18N
    jButton2.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton2ActionPerformed(evt);
        }
    });
    jPanel4.add(jButton2);

    getContentPane().add(jPanel4, java.awt.BorderLayout.SOUTH);

    jPanel1.setBorder(
            javax.swing.BorderFactory.createTitledBorder(bundle.getString("NewBuyTransactionJDialog_Stock"))); // NOI18N
    jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 15, 5));

    jLabel6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/16x16/inbox.png"))); // NOI18N
    jPanel1.add(jLabel6);

    getContentPane().add(jPanel1, java.awt.BorderLayout.NORTH);

    pack();

}

From source file:org.yccheok.jstock.gui.NewBuyTransactionJDialog.java

private void initComponentsWithoutBrokerageFirm() {

    jComboBox1 = new AutoCompleteJComboBox();
    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();
    jFormattedTextField2 = getCurrencyJFormattedTextField();
    jFormattedTextField3 = getCurrencyJFormattedTextField();
    jFormattedTextField4 = getCurrencyJFormattedTextField();
    jFormattedTextField5 = getCurrencyJFormattedTextField();
    jLabel10 = new javax.swing.JLabel();
    jFormattedTextField6 = getCurrencyJFormattedTextField();
    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();
    jLabel11 = new javax.swing.JLabel();
    jTextField2 = new javax.swing.JTextField();
    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();

    jComboBox1.setEditable(true);/*from  w  w w.  jav  a 2s .  co m*/
    jComboBox1.setPreferredSize(new java.awt.Dimension(110, 24));
    ((AutoCompleteJComboBox) jComboBox1).attachStockInfoObserver(this.getStockInfoObserver());
    ((AutoCompleteJComboBox) jComboBox1).attachDispObserver(this.getDispObserver());

    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/gui"); // NOI18N
    setTitle(bundle.getString("NewBuyTransactionJDialog_Buy")); // NOI18N
    setResizable(false);
    addWindowListener(new java.awt.event.WindowAdapter() {
        public void windowClosed(java.awt.event.WindowEvent evt) {
            formWindowClosed(evt);
        }
    });

    jPanel2.setBorder(javax.swing.BorderFactory
            .createTitledBorder(bundle.getString("NewBuyTransactionJDialog_Transaction"))); // NOI18N

    jLabel2.setText(bundle.getString("NewSellTransactionJDialog_Symbol")); // NOI18N

    jSpinner1.setModel(new javax.swing.SpinnerNumberModel(100.0d, 0.001d, null, 100.0d));
    JSpinner.NumberEditor numberEditor = (JSpinner.NumberEditor) jSpinner1.getEditor();
    final DecimalFormat decimalFormat = numberEditor.getFormat();
    decimalFormat.setMaximumFractionDigits(4);
    numberEditor.getTextField().addMouseListener(getJFormattedTextFieldMouseListener());
    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(bundle.getString("NewBuyTransactionJDialog_Date")); // NOI18N

    jFormattedTextField1.setValue(new Double(0.0));
    jFormattedTextField1.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyTyped(java.awt.event.KeyEvent evt) {
            jFormattedTextField1KeyTyped(evt);
        }
    });

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

    jFormattedTextField3.setValue(new Double(0.0));
    jFormattedTextField3.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyTyped(java.awt.event.KeyEvent evt) {
            jFormattedTextField3KeyTyped(evt);
        }
    });

    jFormattedTextField4.setValue(new Double(0.0));
    jFormattedTextField4.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyTyped(java.awt.event.KeyEvent evt) {
            jFormattedTextField4KeyTyped(evt);
        }
    });

    jFormattedTextField5.setValue(new Double(0.0));
    jFormattedTextField5.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyTyped(java.awt.event.KeyEvent evt) {
            jFormattedTextField5KeyTyped(evt);
        }
    });

    jLabel10.setFont(jLabel10.getFont().deriveFont(jLabel10.getFont().getStyle() | java.awt.Font.BOLD));
    jLabel10.setText(bundle.getString("NewBuyTransactionJDialog_NetValue")); // NOI18N

    jFormattedTextField6.setEditable(false);
    jFormattedTextField6.setFont(jFormattedTextField6.getFont()
            .deriveFont(jFormattedTextField6.getFont().getStyle() | java.awt.Font.BOLD));
    jFormattedTextField6.setValue(new Double(0.0));

    jLabel1.setText(bundle.getString("NewBuyTransactionJDialog_Unit")); // NOI18N

    jLabel3.setText(bundle.getString("NewBuyTransactionJDialog_Price")); // NOI18N

    jLabel5.setText(bundle.getString("NewBuyTransactionJDialog_Value")); // NOI18N

    jLabel7.setText(bundle.getString("NewBuyTransactionJDialog_Broker")); // NOI18N

    jLabel8.setText(bundle.getString("NewBuyTransactionJDialog_Clearing")); // NOI18N

    jLabel9.setText(bundle.getString("NewBuyTransactionJDialog_StampDuty")); // NOI18N

    jLabel11.setText(bundle.getString("NewBuyTransactionJDialog_Code")); // NOI18N

    jTextField2.setEditable(false);

    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)
                            .addGroup(jPanel2Layout.createSequentialGroup().addGroup(
                                    jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel11).addComponent(jLabel2).addComponent(jLabel4)
                                            .addComponent(jLabel1).addComponent(jLabel3))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addGroup(jPanel2Layout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                    109, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                    109, Short.MAX_VALUE)
                                            .addComponent(jFormattedTextField1,
                                                    javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE)
                                            .addComponent(jSpinner1, javax.swing.GroupLayout.DEFAULT_SIZE, 109,
                                                    Short.MAX_VALUE)
                                            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, 109,
                                                    Short.MAX_VALUE)))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                    .addGroup(jPanel2Layout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel9).addComponent(jLabel7).addComponent(jLabel8)
                                            .addComponent(jLabel5))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addGroup(jPanel2Layout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jFormattedTextField2,
                                                    javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE)
                                            .addComponent(jFormattedTextField3,
                                                    javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE)
                                            .addComponent(jFormattedTextField4,
                                                    javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE)
                                            .addComponent(jFormattedTextField5,
                                                    javax.swing.GroupLayout.DEFAULT_SIZE, 109,
                                                    Short.MAX_VALUE)))
                            .addGroup(jPanel2Layout.createSequentialGroup().addComponent(jLabel10)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(jFormattedTextField6, javax.swing.GroupLayout.DEFAULT_SIZE,
                                            109, Short.MAX_VALUE)))
                    .addContainerGap()));

    jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
            new java.awt.Component[] { jFormattedTextField1, jFormattedTextField2, jFormattedTextField3,
                    jFormattedTextField4, jFormattedTextField5, jFormattedTextField6, jPanel3, jSpinner1,
                    jTextField1 });

    jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] { jLabel1, jLabel10,
            jLabel11, jLabel2, jLabel3, jLabel4, jLabel5, jLabel7, jLabel8, jLabel9 });

    jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap()
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel11).addComponent(jTextField2,
                                    javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel2))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel1))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jFormattedTextField1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel3))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jFormattedTextField2, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel5))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jFormattedTextField3, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel7))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jFormattedTextField4, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel8))
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createSequentialGroup().addGap(14, 14, 14)
                                    .addComponent(jLabel9))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(jFormattedTextField5, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGap(18, 18, 18)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jFormattedTextField6, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel10))
                    .addContainerGap()));

    jPanel2Layout.linkSize(javax.swing.SwingConstants.VERTICAL,
            new java.awt.Component[] { jFormattedTextField1, jFormattedTextField2, jFormattedTextField3,
                    jFormattedTextField4, jFormattedTextField5, jFormattedTextField6, jPanel3, jSpinner1,
                    jTextField1 });

    getContentPane().add(jPanel2, java.awt.BorderLayout.CENTER);

    jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/16x16/apply.png"))); // NOI18N
    jButton1.setText(bundle.getString("NewBuyTransactionJDialog_OK")); // NOI18N
    jButton1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton1ActionPerformed(evt);
        }
    });
    jPanel4.add(jButton1);

    jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/16x16/button_cancel.png"))); // NOI18N
    jButton2.setText(bundle.getString("NewBuyTransactionJDialog_Cancel")); // NOI18N
    jButton2.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton2ActionPerformed(evt);
        }
    });
    jPanel4.add(jButton2);

    getContentPane().add(jPanel4, java.awt.BorderLayout.SOUTH);

    jPanel1.setBorder(
            javax.swing.BorderFactory.createTitledBorder(bundle.getString("NewBuyTransactionJDialog_Stock"))); // NOI18N
    jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 15, 5));

    jLabel6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/16x16/inbox.png"))); // NOI18N
    jPanel1.add(jLabel6);

    getContentPane().add(jPanel1, java.awt.BorderLayout.NORTH);

    pack();

}

From source file:org.yccheok.jstock.gui.NewBuyTransactionJDialog.java

/** This method is called from within the constructor to
 * initialize the form./*from ww w .ja va  2s  . 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() {

    jComboBox1 = new AutoCompleteJComboBox();
    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();
    jFormattedTextField2 = getCurrencyJFormattedTextField();
    jFormattedTextField3 = getCurrencyJFormattedTextField();
    jFormattedTextField4 = getCurrencyJFormattedTextField();
    jFormattedTextField5 = getCurrencyJFormattedTextField();
    jLabel10 = new javax.swing.JLabel();
    jFormattedTextField6 = getCurrencyJFormattedTextField();
    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();
    jLabel11 = new javax.swing.JLabel();
    jTextField2 = new javax.swing.JTextField();
    jComboBox2 = new javax.swing.JComboBox<>();
    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();

    jComboBox1.setEditable(true);
    jComboBox1.setPreferredSize(new java.awt.Dimension(110, 24));
    ((AutoCompleteJComboBox) jComboBox1).attachStockInfoObserver(this.getStockInfoObserver());
    ((AutoCompleteJComboBox) jComboBox1).attachDispObserver(this.getDispObserver());

    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/gui"); // NOI18N
    setTitle(bundle.getString("NewBuyTransactionJDialog_Buy")); // NOI18N
    setResizable(false);
    addWindowListener(new java.awt.event.WindowAdapter() {
        public void windowClosed(java.awt.event.WindowEvent evt) {
            formWindowClosed(evt);
        }
    });

    jPanel2.setBorder(javax.swing.BorderFactory
            .createTitledBorder(bundle.getString("NewBuyTransactionJDialog_Transaction"))); // NOI18N

    jLabel2.setText(bundle.getString("NewSellTransactionJDialog_Symbol")); // NOI18N

    jSpinner1.setModel(new javax.swing.SpinnerNumberModel(100.0d, 0.001d, null, 100.0d));
    JSpinner.NumberEditor numberEditor = (JSpinner.NumberEditor) jSpinner1.getEditor();
    final DecimalFormat decimalFormat = numberEditor.getFormat();
    decimalFormat.setMaximumFractionDigits(4);
    numberEditor.getTextField().addMouseListener(getJFormattedTextFieldMouseListener());
    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(bundle.getString("NewBuyTransactionJDialog_Date")); // NOI18N

    jFormattedTextField1.setValue(new Double(0.0));
    jFormattedTextField1.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyTyped(java.awt.event.KeyEvent evt) {
            jFormattedTextField1KeyTyped(evt);
        }
    });

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

    jFormattedTextField3.setValue(new Double(0.0));
    jFormattedTextField3.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyTyped(java.awt.event.KeyEvent evt) {
            jFormattedTextField3KeyTyped(evt);
        }
    });

    jFormattedTextField4.setValue(new Double(0.0));
    jFormattedTextField4.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyTyped(java.awt.event.KeyEvent evt) {
            jFormattedTextField4KeyTyped(evt);
        }
    });

    jFormattedTextField5.setValue(new Double(0.0));
    jFormattedTextField5.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyTyped(java.awt.event.KeyEvent evt) {
            jFormattedTextField5KeyTyped(evt);
        }
    });

    jLabel10.setFont(jLabel10.getFont().deriveFont(jLabel10.getFont().getStyle() | java.awt.Font.BOLD));
    jLabel10.setText(bundle.getString("NewBuyTransactionJDialog_NetValue")); // NOI18N

    jFormattedTextField6.setEditable(false);
    jFormattedTextField6.setFont(jFormattedTextField6.getFont()
            .deriveFont(jFormattedTextField6.getFont().getStyle() | java.awt.Font.BOLD));
    jFormattedTextField6.setValue(new Double(0.0));

    jLabel1.setText(bundle.getString("NewBuyTransactionJDialog_Unit")); // NOI18N

    jLabel3.setText(bundle.getString("NewBuyTransactionJDialog_Price")); // NOI18N

    jLabel5.setText(bundle.getString("NewBuyTransactionJDialog_Value")); // NOI18N

    jLabel7.setText(bundle.getString("NewBuyTransactionJDialog_Broker")); // NOI18N

    jLabel8.setText(bundle.getString("NewBuyTransactionJDialog_Clearing")); // NOI18N

    jLabel9.setText(bundle.getString("NewBuyTransactionJDialog_StampDuty")); // NOI18N

    jLabel11.setText(bundle.getString("NewBuyTransactionJDialog_Code")); // NOI18N

    jTextField2.setEditable(false);

    jComboBox2.setModel(
            new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

    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)
                            .addGroup(jPanel2Layout.createSequentialGroup().addGroup(
                                    jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel11).addComponent(jLabel2).addComponent(jLabel4)
                                            .addComponent(jLabel1).addComponent(jLabel3))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addGroup(jPanel2Layout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                    109, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                    109, Short.MAX_VALUE)
                                            .addComponent(jFormattedTextField1,
                                                    javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE)
                                            .addComponent(jSpinner1, javax.swing.GroupLayout.DEFAULT_SIZE, 109,
                                                    Short.MAX_VALUE)
                                            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, 109,
                                                    Short.MAX_VALUE)))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                    .addGroup(jPanel2Layout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel9).addComponent(jLabel7).addComponent(jLabel8)
                                            .addComponent(jLabel5))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addGroup(jPanel2Layout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jFormattedTextField2,
                                                    javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE)
                                            .addComponent(jFormattedTextField3,
                                                    javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE)
                                            .addComponent(jFormattedTextField4,
                                                    javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE)
                                            .addComponent(jFormattedTextField5,
                                                    javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE)
                                            .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                    109, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(jPanel2Layout.createSequentialGroup().addComponent(jLabel10)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(jFormattedTextField6, javax.swing.GroupLayout.DEFAULT_SIZE,
                                            109, Short.MAX_VALUE)))
                    .addContainerGap()));

    jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
            new java.awt.Component[] { jFormattedTextField1, jFormattedTextField2, jFormattedTextField3,
                    jFormattedTextField4, jFormattedTextField5, jFormattedTextField6, jPanel3, jSpinner1,
                    jTextField1 });

    jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] { jLabel1, jLabel10,
            jLabel11, jLabel2, jLabel3, jLabel4, jLabel5, jLabel7, jLabel8, jLabel9 });

    jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap()
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel11).addComponent(jTextField2,
                                    javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel2))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel1))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jFormattedTextField1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel3))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jFormattedTextField2, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel5))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jFormattedTextField3, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel7))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jFormattedTextField4, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel8))
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createSequentialGroup().addGap(14, 14, 14)
                                    .addComponent(jLabel9))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(jFormattedTextField5, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGap(18, 18, 18)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jFormattedTextField6, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel10))
                    .addContainerGap()));

    jPanel2Layout.linkSize(javax.swing.SwingConstants.VERTICAL,
            new java.awt.Component[] { jFormattedTextField1, jFormattedTextField2, jFormattedTextField3,
                    jFormattedTextField4, jFormattedTextField5, jFormattedTextField6, jPanel3, jSpinner1,
                    jTextField1 });

    getContentPane().add(jPanel2, java.awt.BorderLayout.CENTER);

    jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/16x16/apply.png"))); // NOI18N
    jButton1.setText(bundle.getString("NewBuyTransactionJDialog_OK")); // NOI18N
    jButton1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton1ActionPerformed(evt);
        }
    });
    jPanel4.add(jButton1);

    jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/16x16/button_cancel.png"))); // NOI18N
    jButton2.setText(bundle.getString("NewBuyTransactionJDialog_Cancel")); // NOI18N
    jButton2.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton2ActionPerformed(evt);
        }
    });
    jPanel4.add(jButton2);

    getContentPane().add(jPanel4, java.awt.BorderLayout.SOUTH);

    jPanel1.setBorder(
            javax.swing.BorderFactory.createTitledBorder(bundle.getString("NewBuyTransactionJDialog_Stock"))); // NOI18N
    jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 15, 5));

    jLabel6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/16x16/inbox.png"))); // NOI18N
    jPanel1.add(jLabel6);

    getContentPane().add(jPanel1, java.awt.BorderLayout.NORTH);

    pack();
}

From source file:Matrix.java

/**
 * Print the matrix to the output stream. Line the elements up in columns
 * with a Fortran-like 'Fw.d' style format.
 * /*from w  w w .  j  a  va 2s.  c o m*/
 * @param output
 *            Output stream.
 * @param w
 *            Column width.
 * @param d
 *            Number of digits after the decimal.
 */

public void print(PrintWriter output, int w, int d) {
    DecimalFormat format = new DecimalFormat();
    format.setDecimalFormatSymbols(new DecimalFormatSymbols(Locale.US));
    format.setMinimumIntegerDigits(1);
    format.setMaximumFractionDigits(d);
    format.setMinimumFractionDigits(d);
    format.setGroupingUsed(false);
    print(output, format, w + 2);
}

From source file:org.yccheok.jstock.gui.NewSellTransactionJDialog.java

private void initComponentsWithFeeCalculationDisabled() {
    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);
    jFormattedTextField7 = getCurrencyJFormattedTextField(false);
    jFormattedTextField4.setValue(new Double(0.0));
    jFormattedTextField5.setValue(new Double(0.0));
    jFormattedTextField7.setValue(new Double(0.0));

    jLabel10 = new javax.swing.JLabel();
    jFormattedTextField6 = getPercentageJFormattedTextField();
    jLabel1 = new javax.swing.JLabel();
    jLabel3 = new javax.swing.JLabel();
    jLabel5 = new javax.swing.JLabel();
    jLabel7 = 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);
    java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/gui"); // NOI18N
    setTitle(bundle.getString("NewSellTransactionJDialog_Sell")); // NOI18N
    setResizable(false);/*from   ww w .  jav a  2  s  . co  m*/

    jPanel2.setBorder(javax.swing.BorderFactory
            .createTitledBorder(bundle.getString("NewSellTransactionJDialog_Transaction"))); // NOI18N

    jTextField1.setEditable(false);

    jLabel2.setText(bundle.getString("NewBuyTransactionJDialog_Symbol")); // NOI18N

    jSpinner1.setModel(new javax.swing.SpinnerNumberModel(100.0d, 0.001d, null, 100.0d));
    JSpinner.NumberEditor numberEditor = (JSpinner.NumberEditor) jSpinner1.getEditor();
    final DecimalFormat decimalFormat = numberEditor.getFormat();
    decimalFormat.setMaximumFractionDigits(4);
    numberEditor.getTextField().addMouseListener(getJFormattedTextFieldMouseListener());
    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(bundle.getString("NewBuyTransactionJDialog_Date")); // NOI18N

    jFormattedTextField1.setValue(new Double(0.0));
    jFormattedTextField1.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyTyped(java.awt.event.KeyEvent evt) {
            jFormattedTextField1KeyTyped(evt);
        }
    });

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

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

    jLabel10.setFont(jLabel10.getFont().deriveFont(jLabel10.getFont().getStyle() | java.awt.Font.BOLD));
    jLabel10.setText(bundle.getString("NewSellTransactionJDialog_Profit%")); // NOI18N

    jFormattedTextField6.setEditable(false);
    jFormattedTextField6.setFont(jFormattedTextField6.getFont()
            .deriveFont(jFormattedTextField6.getFont().getStyle() | java.awt.Font.BOLD));
    jFormattedTextField6.setValue(new Double(0.0));

    jLabel1.setText(bundle.getString("NewSellTransactionJDialog_Unit")); // NOI18N

    jLabel3.setText(bundle.getString("NewSellTransactionJDialog_Price")); // NOI18N

    jLabel5.setText(bundle.getString("NewSellTransactionJDialog_Value")); // NOI18N

    jLabel7.setText(bundle.getString("NewSellTransactionJDialog_BuyCost")); // NOI18N

    jFormattedTextField8.setEditable(false);
    jFormattedTextField8.setFont(jFormattedTextField8.getFont()
            .deriveFont(jFormattedTextField8.getFont().getStyle() | java.awt.Font.BOLD));
    jFormattedTextField8.setValue(new Double(0.0));

    jLabel12.setFont(jLabel12.getFont().deriveFont(jLabel12.getFont().getStyle() | java.awt.Font.BOLD));
    jLabel12.setText(bundle.getString("NewSellTransactionJDialog_Profit$")); // NOI18N

    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(jLabel2)
                    .addComponent(jLabel3).addComponent(jLabel5).addComponent(jLabel7).addComponent(jLabel1)
                    .addComponent(jLabel4).addComponent(jLabel12).addComponent(jLabel10))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jFormattedTextField6, javax.swing.GroupLayout.DEFAULT_SIZE, 109,
                                    Short.MAX_VALUE)
                            .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 109,
                                    Short.MAX_VALUE)
                            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE)
                            .addComponent(jSpinner1, javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE)
                            .addComponent(jFormattedTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 109,
                                    Short.MAX_VALUE)
                            .addComponent(jFormattedTextField2, javax.swing.GroupLayout.DEFAULT_SIZE, 109,
                                    Short.MAX_VALUE)
                            .addComponent(jFormattedTextField3, javax.swing.GroupLayout.DEFAULT_SIZE, 109,
                                    Short.MAX_VALUE)
                            .addComponent(jFormattedTextField8, javax.swing.GroupLayout.DEFAULT_SIZE, 79,
                                    Short.MAX_VALUE))
                    .addContainerGap()));

    jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
            new java.awt.Component[] { jFormattedTextField1, jFormattedTextField2, jFormattedTextField3,
                    jFormattedTextField6, jFormattedTextField8, jPanel3, jSpinner1, jTextField1 });

    jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] { jLabel1, jLabel10,
            jLabel12, jLabel2, jLabel3, jLabel4, jLabel5, jLabel7 });

    jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap()
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2).addComponent(jTextField1,
                                    javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel1))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jFormattedTextField1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel3))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jFormattedTextField2, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel5))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jFormattedTextField3, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel7))
                    .addGap(18, 18, 18)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jFormattedTextField6, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel10))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel12).addComponent(jFormattedTextField8,
                                    javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addContainerGap()));

    jPanel2Layout.linkSize(javax.swing.SwingConstants.VERTICAL,
            new java.awt.Component[] { jFormattedTextField1, jFormattedTextField2, jFormattedTextField3,
                    jFormattedTextField6, jPanel3, jSpinner1, jTextField1 });

    getContentPane().add(jPanel2, java.awt.BorderLayout.CENTER);

    jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/16x16/apply.png"))); // NOI18N
    jButton1.setText(bundle.getString("NewSellTransactionJDialog_OK")); // NOI18N
    jButton1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton1ActionPerformed(evt);
        }
    });
    jPanel4.add(jButton1);

    jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/16x16/button_cancel.png"))); // NOI18N
    jButton2.setText(bundle.getString("NewSellTransactionJDialog_Cancel")); // NOI18N
    jButton2.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton2ActionPerformed(evt);
        }
    });
    jPanel4.add(jButton2);

    getContentPane().add(jPanel4, java.awt.BorderLayout.SOUTH);

    jPanel1.setBorder(
            javax.swing.BorderFactory.createTitledBorder(bundle.getString("NewSellTransactionJDialog_Stock"))); // NOI18N
    jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 15, 5));

    jLabel6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/16x16/outbox.png"))); // NOI18N
    jPanel1.add(jLabel6);

    jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/16x16/idea.png"))); // NOI18N
    jButton3.setText(bundle.getString("NewSellTransactionJDialog_BestPrice")); // NOI18N
    jButton3.setToolTipText("Suggest the best selling price to break even.");
    jButton3.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton3ActionPerformed(evt);
        }
    });
    jPanel1.add(jButton3);

    getContentPane().add(jPanel1, java.awt.BorderLayout.NORTH);

    pack();

}

From source file:fr.cls.atoll.motu.library.misc.netcdf.NetCdfReader.java

/**
 * Gets the standard z as string./*from w w w. j  a  v a2 s.c  o  m*/
 * 
 * @param value the value
 * @param roundingMode the rounding mode
 * @param desiredDecimalNumberDigits the desired decimal number of digits
 * 
 * @return the standard z as fmt string
 */
public static String getStandardZAsString(double value, RoundingMode roundingMode,
        int desiredDecimalNumberDigits) {

    int in = (int) (value);
    double frac = value - in;

    if (frac == 0d) {
        return NetCdfReader.getStandardZAsString(value);
    }

    DecimalFormat decimalFormat = new DecimalFormat();

    decimalFormat.setDecimalFormatSymbols(new DecimalFormatSymbols(Locale.US));
    decimalFormat.setGroupingUsed(false);
    decimalFormat.setMinimumFractionDigits(desiredDecimalNumberDigits);
    decimalFormat.setMaximumFractionDigits(desiredDecimalNumberDigits);

    decimalFormat.setRoundingMode(roundingMode);

    return decimalFormat.format(value);
}