Example usage for javax.swing JLabel setForeground

List of usage examples for javax.swing JLabel setForeground

Introduction

In this page you can find the example usage for javax.swing JLabel setForeground.

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The foreground color of the component.")
public void setForeground(Color fg) 

Source Link

Document

Sets the foreground color of this component.

Usage

From source file:com.nikonhacker.gui.EmulatorUI.java

private void openChipOptionsDialog(final int chip) {

    // ------------------------ Disassembly options

    JPanel disassemblyOptionsPanel = new JPanel(new MigLayout("", "[left,grow][left,grow]"));

    // Prepare sample code area
    final RSyntaxTextArea listingArea = new RSyntaxTextArea(20, 90);
    SourceCodeFrame.prepareAreaFormat(chip, listingArea);

    final List<JCheckBox> outputOptionsCheckBoxes = new ArrayList<JCheckBox>();
    ActionListener areaRefresherListener = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                Set<OutputOption> sampleOptions = EnumSet.noneOf(OutputOption.class);
                dumpOptionCheckboxes(outputOptionsCheckBoxes, sampleOptions);
                int baseAddress = framework.getPlatform(chip).getCpuState().getResetAddress();
                int lastAddress = baseAddress;
                Memory sampleMemory = new DebuggableMemory(false);
                sampleMemory.map(baseAddress, 0x100, true, true, true);
                StringWriter writer = new StringWriter();
                Disassembler disassembler;
                if (chip == Constants.CHIP_FR) {
                    sampleMemory.store16(lastAddress, 0x1781); // PUSH    RP
                    lastAddress += 2;//  w  w  w  .  jav a  2  s . com
                    sampleMemory.store16(lastAddress, 0x8FFE); // PUSH    (FP,AC,R12,R11,R10,R9,R8)
                    lastAddress += 2;
                    sampleMemory.store16(lastAddress, 0x83EF); // ANDCCR  #0xEF
                    lastAddress += 2;
                    sampleMemory.store16(lastAddress, 0x9F80); // LDI:32  #0x68000000,R0
                    lastAddress += 2;
                    sampleMemory.store16(lastAddress, 0x6800);
                    lastAddress += 2;
                    sampleMemory.store16(lastAddress, 0x0000);
                    lastAddress += 2;
                    sampleMemory.store16(lastAddress, 0x2031); // LD      @(FP,0x00C),R1
                    lastAddress += 2;
                    sampleMemory.store16(lastAddress, 0xB581); // LSL     #24,R1
                    lastAddress += 2;
                    sampleMemory.store16(lastAddress, 0x1A40); // DMOVB   R13,@0x40
                    lastAddress += 2;
                    sampleMemory.store16(lastAddress, 0x9310); // ORCCR   #0x10
                    lastAddress += 2;
                    sampleMemory.store16(lastAddress, 0x8D7F); // POP     (R8,R9,R10,R11,R12,AC,FP)
                    lastAddress += 2;
                    sampleMemory.store16(lastAddress, 0x0781); // POP    RP
                    lastAddress += 2;

                    disassembler = new Dfr();
                    disassembler.setDebugPrintWriter(new PrintWriter(new StringWriter())); // Ignore
                    disassembler.setOutputFileName(null);
                    disassembler.processOptions(new String[] { "-m", "0x" + Format.asHex(baseAddress, 8) + "-0x"
                            + Format.asHex(lastAddress, 8) + "=CODE" });
                } else {
                    sampleMemory.store32(lastAddress, 0x340B0001); // li      $t3, 0x0001
                    lastAddress += 4;
                    sampleMemory.store32(lastAddress, 0x17600006); // bnez    $k1, 0xBFC00020
                    lastAddress += 4;
                    sampleMemory.store32(lastAddress, 0x00000000); //  nop
                    lastAddress += 4;
                    sampleMemory.store32(lastAddress, 0x54400006); // bnezl   $t4, 0xBFC00028
                    lastAddress += 4;
                    sampleMemory.store32(lastAddress, 0x3C0C0000); //  ?lui   $t4, 0x0000
                    lastAddress += 4;

                    int baseAddress16 = lastAddress;
                    int lastAddress16 = baseAddress16;
                    sampleMemory.store32(lastAddress16, 0xF70064F6); // save    $ra,$s0,$s1,$s2-$s7,$fp, 0x30
                    lastAddress16 += 4;
                    sampleMemory.store16(lastAddress16, 0x6500); // nop
                    lastAddress16 += 2;
                    sampleMemory.store32(lastAddress16, 0xF7006476); // restore $ra,$s0,$s1,$s2-$s7,$fp, 0x30
                    lastAddress16 += 4;
                    sampleMemory.store16(lastAddress16, 0xE8A0); // ret
                    lastAddress16 += 2;

                    disassembler = new Dtx();
                    disassembler.setDebugPrintWriter(new PrintWriter(new StringWriter())); // Ignore
                    disassembler.setOutputFileName(null);
                    disassembler.processOptions(new String[] { "-m",
                            "0x" + Format.asHex(baseAddress, 8) + "-0x" + Format.asHex(lastAddress, 8)
                                    + "=CODE:32",
                            "-m", "0x" + Format.asHex(baseAddress16, 8) + "-0x" + Format.asHex(lastAddress16, 8)
                                    + "=CODE:16" });
                }
                disassembler.setOutputOptions(sampleOptions);
                disassembler.setMemory(sampleMemory);
                disassembler.initialize();
                disassembler.setOutWriter(writer);
                disassembler.disassembleMemRanges();
                disassembler.cleanup();
                listingArea.setText("");
                listingArea.append(writer.toString());
                listingArea.setCaretPosition(0);

            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    };

    int i = 1;
    for (OutputOption outputOption : OutputOption.allFormatOptions) {
        JCheckBox checkBox = makeOutputOptionCheckBox(chip, outputOption, prefs.getOutputOptions(chip), false);
        if (checkBox != null) {
            outputOptionsCheckBoxes.add(checkBox);
            disassemblyOptionsPanel.add(checkBox, (i % 2 == 0) ? "wrap" : "");
            checkBox.addActionListener(areaRefresherListener);
            i++;
        }
    }
    if (i % 2 == 0) {
        disassemblyOptionsPanel.add(new JLabel(), "wrap");
    }

    // Force a refresh
    areaRefresherListener.actionPerformed(new ActionEvent(outputOptionsCheckBoxes.get(0), 0, ""));

    //        disassemblyOptionsPanel.add(new JLabel("Sample output:", SwingConstants.LEADING), "gapbottom 1, span, split 2, aligny center");
    //        disassemblyOptionsPanel.add(new JSeparator(), "span 2,wrap");
    disassemblyOptionsPanel.add(new JSeparator(), "span 2, gapleft rel, growx, wrap");
    disassemblyOptionsPanel.add(new JLabel("Sample output:"), "span 2,wrap");
    disassemblyOptionsPanel.add(new JScrollPane(listingArea), "span 2,wrap");
    disassemblyOptionsPanel.add(new JLabel("Tip: hover over the option checkboxes for help"),
            "span 2, center, wrap");

    // ------------------------ Emulation options

    JPanel emulationOptionsPanel = new JPanel(new VerticalLayout(5, VerticalLayout.LEFT));
    emulationOptionsPanel.add(new JLabel());
    JLabel warningLabel = new JLabel(
            "NOTE: these options only take effect after reloading the firmware (or performing a 'Stop and reset')");
    warningLabel.setBackground(Color.RED);
    warningLabel.setOpaque(true);
    warningLabel.setForeground(Color.WHITE);
    warningLabel.setHorizontalAlignment(SwingConstants.CENTER);
    emulationOptionsPanel.add(warningLabel);
    emulationOptionsPanel.add(new JLabel());

    final JCheckBox writeProtectFirmwareCheckBox = new JCheckBox("Write-protect firmware");
    writeProtectFirmwareCheckBox.setSelected(prefs.isFirmwareWriteProtected(chip));
    emulationOptionsPanel.add(writeProtectFirmwareCheckBox);
    emulationOptionsPanel.add(new JLabel(
            "If checked, any attempt to write to the loaded firmware area will result in an Emulator error. This can help trap spurious writes"));

    final JCheckBox dmaSynchronousCheckBox = new JCheckBox("Make DMA synchronous");
    dmaSynchronousCheckBox.setSelected(prefs.isDmaSynchronous(chip));
    emulationOptionsPanel.add(dmaSynchronousCheckBox);
    emulationOptionsPanel.add(new JLabel(
            "If checked, DMA operations will be performed immediately, pausing the CPU. Otherwise they are performed in a separate thread."));

    final JCheckBox autoEnableTimersCheckBox = new JCheckBox("Auto enable timers");
    autoEnableTimersCheckBox.setSelected(prefs.isAutoEnableTimers(chip));
    emulationOptionsPanel.add(autoEnableTimersCheckBox);
    emulationOptionsPanel
            .add(new JLabel("If checked, timers will be automatically enabled upon reset or firmware load."));

    // Log memory messages
    final JCheckBox logMemoryMessagesCheckBox = new JCheckBox("Log memory messages");
    logMemoryMessagesCheckBox.setSelected(prefs.isLogMemoryMessages(chip));
    emulationOptionsPanel.add(logMemoryMessagesCheckBox);
    emulationOptionsPanel
            .add(new JLabel("If checked, messages related to memory will be logged to the console."));

    // Log serial messages
    final JCheckBox logSerialMessagesCheckBox = new JCheckBox("Log serial messages");
    logSerialMessagesCheckBox.setSelected(prefs.isLogSerialMessages(chip));
    emulationOptionsPanel.add(logSerialMessagesCheckBox);
    emulationOptionsPanel.add(
            new JLabel("If checked, messages related to serial interfaces will be logged to the console."));

    // Log register messages
    final JCheckBox logRegisterMessagesCheckBox = new JCheckBox("Log register messages");
    logRegisterMessagesCheckBox.setSelected(prefs.isLogRegisterMessages(chip));
    emulationOptionsPanel.add(logRegisterMessagesCheckBox);
    emulationOptionsPanel.add(new JLabel(
            "If checked, warnings related to unimplemented register addresses will be logged to the console."));

    // Log pin messages
    final JCheckBox logPinMessagesCheckBox = new JCheckBox("Log pin messages");
    logPinMessagesCheckBox.setSelected(prefs.isLogPinMessages(chip));
    emulationOptionsPanel.add(logPinMessagesCheckBox);
    emulationOptionsPanel.add(new JLabel(
            "If checked, warnings related to unimplemented I/O pins will be logged to the console."));

    emulationOptionsPanel.add(new JSeparator(JSeparator.HORIZONTAL));

    // Alt mode upon Debug
    JPanel altDebugPanel = new JPanel(new FlowLayout());
    Object[] altDebugMode = EnumSet.allOf(EmulationFramework.ExecutionMode.class).toArray();
    final JComboBox altModeForDebugCombo = new JComboBox(new DefaultComboBoxModel(altDebugMode));
    for (int j = 0; j < altDebugMode.length; j++) {
        if (altDebugMode[j].equals(prefs.getAltExecutionModeForSyncedCpuUponDebug(chip))) {
            altModeForDebugCombo.setSelectedIndex(j);
        }
    }
    altDebugPanel.add(new JLabel(Constants.CHIP_LABEL[1 - chip] + " mode when " + Constants.CHIP_LABEL[chip]
            + " runs in sync Debug: "));
    altDebugPanel.add(altModeForDebugCombo);
    emulationOptionsPanel.add(altDebugPanel);
    emulationOptionsPanel
            .add(new JLabel("If 'sync mode' is selected, this is the mode the " + Constants.CHIP_LABEL[1 - chip]
                    + " chip will run in when running the " + Constants.CHIP_LABEL[chip] + " in Debug mode"));

    // Alt mode upon Step
    JPanel altStepPanel = new JPanel(new FlowLayout());
    Object[] altStepMode = EnumSet.allOf(EmulationFramework.ExecutionMode.class).toArray();
    final JComboBox altModeForStepCombo = new JComboBox(new DefaultComboBoxModel(altStepMode));
    for (int j = 0; j < altStepMode.length; j++) {
        if (altStepMode[j].equals(prefs.getAltExecutionModeForSyncedCpuUponStep(chip))) {
            altModeForStepCombo.setSelectedIndex(j);
        }
    }
    altStepPanel.add(new JLabel(Constants.CHIP_LABEL[1 - chip] + " mode when " + Constants.CHIP_LABEL[chip]
            + " runs in sync Step: "));
    altStepPanel.add(altModeForStepCombo);
    emulationOptionsPanel.add(altStepPanel);
    emulationOptionsPanel
            .add(new JLabel("If 'sync mode' is selected, this is the mode the " + Constants.CHIP_LABEL[1 - chip]
                    + " chip will run in when running the " + Constants.CHIP_LABEL[chip] + " in Step mode"));

    // ------------------------ Prepare tabbed pane

    JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.addTab(Constants.CHIP_LABEL[chip] + " Disassembly Options", null, disassemblyOptionsPanel);
    tabbedPane.addTab(Constants.CHIP_LABEL[chip] + " Emulation Options", null, emulationOptionsPanel);

    if (chip == Constants.CHIP_TX) {
        JPanel chipSpecificOptionsPanel = new JPanel(new VerticalLayout(5, VerticalLayout.LEFT));

        chipSpecificOptionsPanel.add(new JLabel("Eeprom status upon startup:"));

        ActionListener eepromInitializationRadioActionListener = new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                prefs.setEepromInitMode(Prefs.EepromInitMode.valueOf(e.getActionCommand()));
            }
        };
        JRadioButton blank = new JRadioButton("Blank");
        blank.setActionCommand(Prefs.EepromInitMode.BLANK.name());
        blank.addActionListener(eepromInitializationRadioActionListener);
        if (Prefs.EepromInitMode.BLANK.equals(prefs.getEepromInitMode()))
            blank.setSelected(true);
        JRadioButton persistent = new JRadioButton("Persistent across sessions");
        persistent.setActionCommand(Prefs.EepromInitMode.PERSISTENT.name());
        persistent.addActionListener(eepromInitializationRadioActionListener);
        if (Prefs.EepromInitMode.PERSISTENT.equals(prefs.getEepromInitMode()))
            persistent.setSelected(true);
        JRadioButton lastLoaded = new JRadioButton("Last Loaded");
        lastLoaded.setActionCommand(Prefs.EepromInitMode.LAST_LOADED.name());
        lastLoaded.addActionListener(eepromInitializationRadioActionListener);
        if (Prefs.EepromInitMode.LAST_LOADED.equals(prefs.getEepromInitMode()))
            lastLoaded.setSelected(true);

        ButtonGroup group = new ButtonGroup();
        group.add(blank);
        group.add(persistent);
        group.add(lastLoaded);

        chipSpecificOptionsPanel.add(blank);
        chipSpecificOptionsPanel.add(persistent);
        chipSpecificOptionsPanel.add(lastLoaded);

        chipSpecificOptionsPanel.add(new JLabel("Front panel type:"));
        final JComboBox frontPanelNameCombo = new JComboBox(new String[] { "D5100_small", "D5100_large" });
        if (prefs.getFrontPanelName() != null) {
            frontPanelNameCombo.setSelectedItem(prefs.getFrontPanelName());
        }
        frontPanelNameCombo.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                prefs.setFrontPanelName((String) frontPanelNameCombo.getSelectedItem());
            }
        });
        chipSpecificOptionsPanel.add(frontPanelNameCombo);

        emulationOptionsPanel.add(new JSeparator(JSeparator.HORIZONTAL));

        tabbedPane.addTab(Constants.CHIP_LABEL[chip] + " specific options", null, chipSpecificOptionsPanel);
    }

    // ------------------------ Show it

    if (JOptionPane.OK_OPTION == JOptionPane.showOptionDialog(this, tabbedPane,
            Constants.CHIP_LABEL[chip] + " options", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE,
            null, null, JOptionPane.DEFAULT_OPTION)) {
        // save output options
        dumpOptionCheckboxes(outputOptionsCheckBoxes, prefs.getOutputOptions(chip));
        // apply
        TxCPUState.initRegisterLabels(prefs.getOutputOptions(chip));

        // save other prefs
        prefs.setFirmwareWriteProtected(chip, writeProtectFirmwareCheckBox.isSelected());
        prefs.setDmaSynchronous(chip, dmaSynchronousCheckBox.isSelected());
        prefs.setAutoEnableTimers(chip, autoEnableTimersCheckBox.isSelected());
        prefs.setLogRegisterMessages(chip, logRegisterMessagesCheckBox.isSelected());
        prefs.setLogSerialMessages(chip, logSerialMessagesCheckBox.isSelected());
        prefs.setLogPinMessages(chip, logPinMessagesCheckBox.isSelected());
        prefs.setLogMemoryMessages(chip, logMemoryMessagesCheckBox.isSelected());
        prefs.setAltExecutionModeForSyncedCpuUponDebug(chip,
                (EmulationFramework.ExecutionMode) altModeForDebugCombo.getSelectedItem());
        prefs.setAltExecutionModeForSyncedCpuUponStep(chip,
                (EmulationFramework.ExecutionMode) altModeForStepCombo.getSelectedItem());

    }
}

From source file:CSSDFarm.UserInterface.java

private void btnAddFieldStationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddFieldStationActionPerformed
    JTextField id = new JTextField();
    JTextField name = new JTextField();
    //Space is needed to expand dialog
    JLabel verified = new JLabel(" ");
    JButton okButton = new JButton("Ok");
    JButton cancelButton = new JButton("Cancel");
    okButton.setEnabled(false);/*from  www  .j  a v a 2 s .com*/
    okButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            String idText = id.getText();
            String nameText = name.getText();
            addFieldStation(id.getText(), name.getText());
            JOptionPane.getRootFrame().dispose();
            listUserStations.setSelectedValue(server.getFieldStation(idText), false);
        }
    });

    cancelButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            JOptionPane.getRootFrame().dispose();
        }
    });

    id.addKeyListener(new KeyAdapter() {
        public void keyReleased(KeyEvent key) {
            boolean theid = id.getText().equals("");
            boolean thename = name.getText().equals("");
            if (server.verifyFieldStation(id.getText()) && !theid && !thename) {
                verified.setText(" Verified");
                verified.setForeground(new Color(0, 102, 0));
                okButton.setEnabled(true);
            } else {
                verified.setText(" Not Verified");
                verified.setForeground(Color.RED);
                okButton.setEnabled(false);
            }
        }
    });
    name.addKeyListener(new KeyAdapter() {
        public void keyReleased(KeyEvent key) {
            boolean theid = id.getText().equals("");
            boolean thename = name.getText().equals("");
            if (server.verifyFieldStation(id.getText()) && !theid && !thename) {
                verified.setText(" Verified");
                verified.setForeground(new Color(0, 102, 0));
                okButton.setEnabled(true);
            } else {
                verified.setText(" Not Verified");
                verified.setForeground(Color.RED);
                okButton.setEnabled(false);
            }
        }
    });

    Object[] message = { "Field Station ID:", id, "Field Station Name:", name, verified };
    int inputFields = JOptionPane.showOptionDialog(null, message, "Add Field Station",
            JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null,
            new Object[] { okButton, cancelButton }, null);
    if (inputFields == JOptionPane.OK_OPTION) {
        System.out.print("Added Field Station!");
    }
}

From source file:Tcpbw100.java

public void testResults(String tmpstr) {
    StringTokenizer tokens;/*ww  w . j  ava2 s . c  o  m*/
    int i = 0;
    String sysvar, strval;
    int sysval, Zero = 0, bwdelay, minwin;
    double sysval2, j;
    String osName, osArch, osVer, javaVer, javaVendor, client;

    tokens = new StringTokenizer(tmpstr);
    sysvar = null;
    strval = null;
    while (tokens.hasMoreTokens()) {
        if (++i % 2 == 1) {
            sysvar = tokens.nextToken();
        } else {
            strval = tokens.nextToken();
            diagnosis.append(sysvar + " " + strval + "\n");
            //we load all the key value pairs to the report, too
            //may come in handy in the future
            //TODO: strip the trailing ':' from sysvar
            report.put("web100_" + sysvar.replaceAll(":$", ""), strval);
            emailText += sysvar + " " + strval + "\n%0A";
            if (strval.indexOf(".") == -1) {
                sysval = Integer.parseInt(strval);
                save_int_values(sysvar, sysval);
            } else {
                sysval2 = Double.valueOf(strval).doubleValue();
                save_dbl_values(sysvar, sysval2);
            }
        }
    }

    // Grab some client details from the applet environment
    osName = System.getProperty("os.name");
    pub_osName = osName;

    osArch = System.getProperty("os.arch");
    pub_osArch = osArch;

    osVer = System.getProperty("os.version");
    pub_osVer = osVer;

    javaVer = System.getProperty("java.version");
    pub_javaVer = javaVer;

    javaVendor = System.getProperty("java.vendor");

    if (osArch.startsWith("x86") == true) {
        client = messages.getString("pc");
    } else {
        client = messages.getString("workstation");
    }

    // Calculate some variables and determine path conditions
    // Note: calculations now done in server and the results are shipped
    //    back to the client for printing.

    if (CountRTT > 0) {
        // Now write some messages to the screen
        if (c2sData < 3) {
            if (c2sData < 0) {
                results.append(messages.getString("unableToDetectBottleneck") + "\n");
                emailText += "Server unable to determine bottleneck link type.\n%0A";
                pub_AccessTech = "Connection type unknown";

            } else {
                results.append(messages.getString("your") + " " + client + " "
                        + messages.getString("connectedTo") + " ");
                emailText += messages.getString("your") + " " + client + " " + messages.getString("connectedTo")
                        + " ";
                if (c2sData == 1) {
                    results.append(messages.getString("dialup") + "\n");
                    emailText += messages.getString("dialup") + "\n%0A";
                    mylink = .064;
                    pub_AccessTech = "Dial-up Modem";
                } else {
                    results.append(messages.getString("cabledsl") + "\n");
                    emailText += messages.getString("cabledsl") + "\n%0A";
                    mylink = 3;
                    pub_AccessTech = "Cable/DSL modem";
                }
            }
        } else {
            results.append(messages.getString("theSlowestLink") + " ");
            emailText += messages.getString("theSlowestLink") + " ";
            if (c2sData == 3) {
                results.append(messages.getString("10mbps") + "\n");
                emailText += messages.getString("10mbps") + "\n%0A";
                mylink = 10;
                pub_AccessTech = "10 Mbps Ethernet";
            } else if (c2sData == 4) {
                results.append(messages.getString("45mbps") + "\n");
                emailText += messages.getString("45mbps") + "\n%0A";
                mylink = 45;
                pub_AccessTech = "45 Mbps T3/DS3 subnet";
            } else if (c2sData == 5) {
                results.append("100 Mbps ");
                emailText += "100 Mbps ";
                mylink = 100;
                pub_AccessTech = "100 Mbps Ethernet";

                if (half_duplex == 0) {
                    results.append(messages.getString("fullDuplex") + "\n");
                    emailText += messages.getString("fullDuplex") + "\n%0A";
                } else {
                    results.append(messages.getString("halfDuplex") + "\n");
                    emailText += messages.getString("halfDuplex") + "\n%0A";
                }
            } else if (c2sData == 6) {
                results.append(messages.getString("622mbps") + "\n");
                emailText += messages.getString("622mbps") + "\n%0A";
                mylink = 622;
                pub_AccessTech = "622 Mbps OC-12";
            } else if (c2sData == 7) {
                results.append(messages.getString("1gbps") + "\n");
                emailText += messages.getString("1gbps") + "\n%0A";
                mylink = 1000;
                pub_AccessTech = "1.0 Gbps Gigabit Ethernet";
            } else if (c2sData == 8) {
                results.append(messages.getString("2.4gbps") + "\n");
                emailText += messages.getString("2.4gbps") + "\n%0A";
                mylink = 2400;
                pub_AccessTech = "2.4 Gbps OC-48";
            } else if (c2sData == 9) {
                results.append(messages.getString("10gbps") + "\n");
                emailText += messages.getString("10gbps") + "\n%0A";
                mylink = 10000;
                pub_AccessTech = "10 Gigabit Ethernet/OC-192";

            }
        }

        if (mismatch == 1) {
            results.append(messages.getString("oldDuplexMismatch") + "\n");
            emailText += messages.getString("oldDuplexMismatch") + "\n%0A";
        } else if (mismatch == 2) {
            results.append(messages.getString("duplexFullHalf") + "\n");
            emailText += messages.getString("duplexFullHalf") + "\n%0A";
        } else if (mismatch == 4) {
            results.append(messages.getString("possibleDuplexFullHalf") + "\n");
            emailText += messages.getString("possibleDuplexFullHalf") + "\n%0A";
        } else if (mismatch == 3) {
            results.append(messages.getString("duplexHalfFull") + "\n");
            emailText += messages.getString("duplexHalfFull") + "\n%0A";
        } else if (mismatch == 5) {
            results.append(messages.getString("possibleDuplexHalfFull") + "\n");
            emailText += messages.getString("possibleDuplexHalfFull") + "\n%0A";
        } else if (mismatch == 7) {
            results.append(messages.getString("possibleDuplexHalfFullWarning") + "\n");
            emailText += messages.getString("possibleDuplexHalfFullWarning") + "\n%0A";
        }

        if (mismatch == 0) {
            if (bad_cable == 1) {
                results.append(messages.getString("excessiveErrors ") + "\n");
                emailText += messages.getString("excessiveErrors") + "\n%0A";
            }
            if (congestion == 1) {
                results.append(messages.getString("otherTraffic") + "\n");
                emailText += messages.getString("otherTraffic") + "\n%0A";
            }
            if (((2 * rwin) / rttsec) < mylink) {
                j = (float) ((mylink * avgrtt) * 1000) / 8 / 1024;
                if (j > (float) MaxRwinRcvd) {
                    results.append(messages.getString("receiveBufferShouldBe") + " " + prtdbl(j)
                            + messages.getString("toMaximizeThroughput") + " \n");
                    emailText += messages.getString("receiveBufferShouldBe") + " " + prtdbl(j)
                            + messages.getString("toMaximizeThroughput") + "\n%0A";
                }
            }
        }

        if ((tests & TEST_C2S) == TEST_C2S) {
            if (sc2sspd < (c2sspd * (1.0 - VIEW_DIFF))) {
                // TODO:  distinguish the host buffering from the middleboxes buffering
                JLabel info = new JLabel(messages.getString("information"));
                info.addMouseListener(new MouseAdapter() {

                    public void mouseClicked(MouseEvent e) {
                        showBufferedBytesInfo();
                    }

                });
                info.setForeground(Color.BLUE);
                info.setCursor(new Cursor(Cursor.HAND_CURSOR));
                info.setAlignmentY((float) 0.8);
                results.insertComponent(info);
                results.append(messages.getString("c2sPacketQueuingDetected") + "\n");
            }
        }

        if ((tests & TEST_S2C) == TEST_S2C) {
            if (s2cspd < (ss2cspd * (1.0 - VIEW_DIFF))) {
                // TODO:  distinguish the host buffering from the middleboxes buffering
                JLabel info = new JLabel(messages.getString("information"));
                info.addMouseListener(new MouseAdapter() {

                    public void mouseClicked(MouseEvent e) {
                        showBufferedBytesInfo();
                    }

                });
                info.setForeground(Color.BLUE);
                info.setCursor(new Cursor(Cursor.HAND_CURSOR));
                info.setAlignmentY((float) 0.8);
                results.insertComponent(info);
                results.append(messages.getString("s2cPacketQueuingDetected") + "\n");
            }
        }

        statistics.append("\n\t------  " + messages.getString("clientInfo") + "------\n");
        statistics.append(messages.getString("osData") + " " + messages.getString("name") + " = " + osName
                + ", " + messages.getString("architecture") + " = " + osArch);
        statistics.append(", " + messages.getString("version") + " = " + osVer + "\n");
        statistics.append(messages.getString("javaData") + ": " + messages.getString("vendor") + " = "
                + javaVendor + ", " + messages.getString("version") + " = " + javaVer + "\n");

        report.put("os_name", osName);
        report.put("os_architecture", osArch);
        report.put("os_version", osVer);
        statistics.append("Java data: Vendor = " + javaVendor + ", Version = " + javaVer + "\n");
        report.put("java_vendor", javaVendor);
        report.put("java_version", javaVer);

        // statistics.append(" java.class.version=" + System.getProperty("java.class.version") + "\n");

        statistics.append("\n\t------  " + messages.getString("web100Details") + "  ------\n");
        if (c2sData == -2)
            statistics.append(messages.getString("insufficient") + "\n");
        else if (c2sData == -1)
            statistics.append(messages.getString("ipcFail") + "\n");
        else if (c2sData == 0)
            statistics.append(messages.getString("rttFail") + "\n");
        else if (c2sData == 1)
            statistics.append(messages.getString("foundDialup") + "\n");
        else if (c2sData == 2)
            statistics.append(messages.getString("foundDsl") + "\n");
        else if (c2sData == 3)
            statistics.append(messages.getString("found10mbps") + "\n");
        else if (c2sData == 4)
            statistics.append(messages.getString("found45mbps") + "\n");
        else if (c2sData == 5)
            statistics.append(messages.getString("found100mbps") + "\n");
        else if (c2sData == 6)
            statistics.append(messages.getString("found622mbps") + "\n");
        else if (c2sData == 7)
            statistics.append(messages.getString("found1gbps") + "\n");
        else if (c2sData == 8)
            statistics.append(messages.getString("found2.4gbps") + "\n");
        else if (c2sData == 9)
            statistics.append(messages.getString("found10gbps") + "\n");

        if (half_duplex == 0)
            statistics.append(messages.getString("linkFullDpx") + "\n");
        else
            statistics.append(messages.getString("linkHalfDpx") + "\n");

        if (congestion == 0)
            statistics.append(messages.getString("congestNo") + "\n");
        else
            statistics.append(messages.getString("congestYes") + "\n");

        if (bad_cable == 0)
            statistics.append(messages.getString("cablesOk") + "\n");
        else
            statistics.append(messages.getString("cablesNok") + "\n");

        if (mismatch == 0)
            statistics.append(messages.getString("duplexOk") + "\n");
        else if (mismatch == 1) {
            statistics.append(messages.getString("duplexNok") + " ");
            emailText += messages.getString("duplexNok") + " ";
        } else if (mismatch == 2) {
            statistics.append(messages.getString("duplexFullHalf") + "\n");
            emailText += messages.getString("duplexFullHalf") + "\n%0A ";
        } else if (mismatch == 3) {
            statistics.append(messages.getString("duplexHalfFull") + "\n");
            emailText += messages.getString("duplexHalfFull") + "\n%0A ";
        }

        statistics.append("\n" + messages.getString("web100rtt") + " =  " + prtdbl(avgrtt) + " " + "ms" + "; ");
        emailText += "\n%0A" + messages.getString("web100rtt") + " = " + prtdbl(avgrtt) + " " + "ms" + "; ";

        statistics.append(messages.getString("packetsize") + " = " + CurrentMSS + " "
                + messages.getString("bytes") + "; " + messages.getString("and") + " \n");
        emailText += messages.getString("packetsize") + " = " + CurrentMSS + " " + messages.getString("bytes")
                + "; " + messages.getString("and") + " \n%0A";

        report.put("rtt", prtdbl(avgrtt));
        rttLbl.setText(prtdbl(avgrtt));
        rttLbl.setText(String.format(padding + "%.0f msec", avgrtt));
        report.put("mss", Integer.toString(CurrentMSS));
        report.put("retransmissions", Integer.toString(PktsRetrans));
        report.put("sack_blocks", Integer.toString(SACKsRcvd));
        report.put("duplicate_acks", Integer.toString(DupAcksIn));
        report.put("timeouts", Integer.toString(Timeouts));
        report.put("wait_seconds", Double.toString(waitsec));
        report.put("out_of_order", Double.toString(order));
        report.put("loss", Double.toString(loss));
        report.put("jitter", get_jitter());
        lossLbl.setText(String.format(padding + "%.0f %%", loss * 100));
        jitterLbl.setText(padding + get_jitter() + " msec");

        if (PktsRetrans > 0) {
            statistics.append(PktsRetrans + " " + messages.getString("pktsRetrans"));
            statistics.append(", " + DupAcksIn + " " + messages.getString("dupAcksIn"));
            statistics.append(", " + messages.getString("and") + " " + SACKsRcvd + " "
                    + messages.getString("sackReceived") + "\n");
            emailText += PktsRetrans + " " + messages.getString("pktsRetrans");
            emailText += ", " + DupAcksIn + " " + messages.getString("dupAcksIn");
            emailText += ", " + messages.getString("and") + " " + SACKsRcvd + " "
                    + messages.getString("sackReceived") + "\n%0A";
            if (Timeouts > 0) {
                statistics.append(messages.getString("connStalled") + " " + Timeouts + " "
                        + messages.getString("timesPktLoss") + "\n");
            }

            statistics.append(messages.getString("connIdle") + " " + prtdbl(waitsec) + " "
                    + messages.getString("seconds") + " (" + prtdbl((waitsec / timesec) * 100)
                    + messages.getString("pctOfTime") + ")\n");
            emailText += messages.getString("connStalled") + " " + Timeouts + " "
                    + messages.getString("timesPktLoss") + "\n%0A";
            emailText += messages.getString("connIdle") + " " + prtdbl(waitsec) + " "
                    + messages.getString("seconds") + " (" + prtdbl((waitsec / timesec) * 100)
                    + messages.getString("pctOfTime") + ")\n%0A";
        } else if (DupAcksIn > 0) {
            statistics.append(messages.getString("noPktLoss1") + " - ");
            statistics.append(messages.getString("ooOrder") + " " + prtdbl(order * 100)
                    + messages.getString("pctOfTime") + "\n");
            emailText += messages.getString("noPktLoss1") + " - ";
            emailText += messages.getString("ooOrder") + " " + prtdbl(order * 100)
                    + messages.getString("pctOfTime") + "\n%0A";
        } else {
            statistics.append(messages.getString("noPktLoss2") + ".\n");
            emailText += messages.getString("noPktLoss2") + ".\n%0A";
        }

        if ((tests & TEST_C2S) == TEST_C2S) {
            if (c2sspd > sc2sspd) {
                if (sc2sspd < (c2sspd * (1.0 - VIEW_DIFF))) {
                    statistics.append(messages.getString("c2s") + " " + messages.getString("qSeen") + ": "
                            + prtdbl(100 * (c2sspd - sc2sspd) / c2sspd) + "%\n");
                } else {
                    statistics.append(messages.getString("c2s") + " " + messages.getString("qSeen") + ": "
                            + prtdbl(100 * (c2sspd - sc2sspd) / c2sspd) + "%\n");
                }
            }
        }

        if ((tests & TEST_S2C) == TEST_S2C) {
            if (ss2cspd > s2cspd) {
                if (s2cspd < (ss2cspd * (1.0 - VIEW_DIFF))) {
                    statistics.append(messages.getString("s2c") + " " + messages.getString("qSeen") + ": "
                            + prtdbl(100 * (ss2cspd - s2cspd) / ss2cspd) + "%\n");
                } else {
                    statistics.append(messages.getString("s2c") + " " + messages.getString("qSeen") + ": "
                            + prtdbl(100 * (ss2cspd - s2cspd) / ss2cspd) + "%\n");
                }
            }
        }

        if (rwintime > .015) {
            statistics.append(messages.getString("thisConnIs") + " " + messages.getString("limitRx") + " "
                    + prtdbl(rwintime * 100) + messages.getString("pctOfTime") + ".\n");
            emailText += messages.getString("thisConnIs") + " " + messages.getString("limitRx") + " "
                    + prtdbl(rwintime * 100) + messages.getString("pctOfTime") + ".\n%0A";
            pub_pctRcvrLimited = rwintime * 100;

            // I think there is a bug here, it sometimes tells you to increase the buffer
            // size, but the new size is smaller than the current.

            if (((2 * rwin) / rttsec) < mylink) {
                statistics.append("  " + messages.getString("incrRxBuf") + " (" + prtdbl(MaxRwinRcvd / 1024)
                        + " KB) " + messages.getString("willImprove") + "\n");
            }
        }
        if (sendtime > .015) {
            statistics.append(messages.getString("thisConnIs") + " " + messages.getString("limitTx") + " "
                    + prtdbl(sendtime * 100) + messages.getString("pctOfTime") + ".\n");
            emailText += messages.getString("thisConnIs") + " " + messages.getString("limitTx") + " "
                    + prtdbl(sendtime * 100) + messages.getString("pctOfTime") + ".\n%0A";
            if ((2 * (swin / rttsec)) < mylink) {
                statistics.append("  " + messages.getString("incrTxBuf") + " (" + prtdbl(Sndbuf / 2048)
                        + " KB) " + messages.getString("willImprove") + "\n");
            }
        }
        if (cwndtime > .005) {
            statistics.append(messages.getString("thisConnIs") + " " + messages.getString("limitNet") + " "
                    + prtdbl(cwndtime * 100) + messages.getString("pctOfTime") + ".\n");
            emailText += messages.getString("thisConnIs") + " " + messages.getString("limitNet") + " "
                    + prtdbl(cwndtime * 100) + messages.getString("pctOfTime") + ".\n%0A";
            // if (cwndtime > .15)
            //   statistics.append("  Contact your local network administrator to report a network problem\n");
            // if (order > .15)
            //   statistics.append("  Contact your local network admin and report excessive packet reordering\n");
        }
        if ((spd < 4) && (loss > .01)) {
            statistics.append(messages.getString("excLoss") + "\n");
        }

        statistics.append("\n" + messages.getString("web100tcpOpts") + " \n");
        statistics.append("RFC 2018 Selective Acknowledgment: ");
        if (SACKEnabled == Zero)
            statistics.append(messages.getString("off") + "\n");
        else
            statistics.append(messages.getString("on") + "\n");

        statistics.append("RFC 896 Nagle Algorithm: ");
        if (NagleEnabled == Zero)
            statistics.append(messages.getString("off") + "\n");
        else
            statistics.append(messages.getString("on") + "\n");

        statistics.append("RFC 3168 Explicit Congestion Notification: ");
        if (ECNEnabled == Zero)
            statistics.append(messages.getString("off") + "\n");
        else
            statistics.append(messages.getString("on") + "\n");

        statistics.append("RFC 1323 Time Stamping: ");
        if (TimestampsEnabled == 0)
            statistics.append(messages.getString("off") + "\n");
        else
            statistics.append(messages.getString("on") + "\n");

        statistics.append("RFC 1323 Window Scaling: ");
        if (MaxRwinRcvd < 65535)
            WinScaleRcvd = 0;
        if ((WinScaleRcvd == 0) || (WinScaleRcvd > 20)) {
            statistics.append(messages.getString("off") + "\n");
            report.put("window_scaling", "0");
        } else {
            statistics.append(messages.getString("on") + "; " + messages.getString("scalingFactors") + " -  "
                    + messages.getString("server") + "=" + WinScaleRcvd + ", " + messages.getString("client")
                    + "=" + WinScaleSent + "\n");
            report.put("window_scaling", "1");
        }
        statistics.append("\n");

        if ((tests & TEST_SFW) == TEST_SFW) {
            switch (c2sResult) {
            case SFW_NOFIREWALL:
                statistics.append(messages.getString("server") + " '" + host + "' "
                        + messages.getString("firewallNo") + "\n");
                emailText += messages.getString("server") + " '" + host + "' "
                        + messages.getString("firewallNo") + "\n%0A";
                break;
            case SFW_POSSIBLE:
                statistics.append(messages.getString("server") + " '" + host + "' "
                        + messages.getString("firewallYes") + "\n");
                emailText += messages.getString("server") + " '" + host + "' "
                        + messages.getString("firewallYes") + "\n%0A";
                break;
            case SFW_UNKNOWN:
            case SFW_NOTTESTED:
                break;
            }
            switch (s2cResult) {
            case SFW_NOFIREWALL:
                statistics
                        .append(messages.getString("client2") + " " + messages.getString("firewallNo") + "\n");
                emailText += messages.getString("client2") + " " + messages.getString("firewallNo") + "\n%0A";
                break;
            case SFW_POSSIBLE:
                statistics
                        .append(messages.getString("client2") + " " + messages.getString("firewallYes") + "\n");
                emailText += messages.getString("client2") + " " + messages.getString("firewallYes") + "\n%0A";
                break;
            case SFW_UNKNOWN:
            case SFW_NOTTESTED:
                break;
            }
        }

        //         diagnosis.append("\nEstimate = " + prtdbl(estimate) + " based on packet size = "
        //            + (CurrentMSS*8/1024) + "kbits, RTT = " + prtdbl(avgrtt) + "msec, " + "and loss = " + loss + "\n");
        diagnosis.append("\n");

        diagnosis.append(messages.getString("theoreticalLimit") + " " + prtdbl(estimate) + " " + "Mbps\n");
        emailText += messages.getString("theoreticalLimit") + " " + prtdbl(estimate) + " Mbps\n%0A";

        diagnosis.append(messages.getString("ndtServerHas") + " " + prtdbl(Sndbuf / 2048) + " "
                + messages.getString("kbyteBufferLimits") + " " + prtdbl(swin / rttsec) + " Mbps\n");
        emailText += messages.getString("ndtServerHas") + " " + prtdbl(Sndbuf / 2048) + " "
                + messages.getString("kbyteBufferLimits") + " " + prtdbl(swin / rttsec) + " Mbps\n%0A";

        diagnosis.append(messages.getString("yourPcHas") + " " + prtdbl(MaxRwinRcvd / 1024) + " "
                + messages.getString("kbyteBufferLimits") + " " + prtdbl(rwin / rttsec) + " Mbps\n");
        emailText += messages.getString("yourPcHas") + " " + prtdbl(MaxRwinRcvd / 1024) + " "
                + messages.getString("kbyteBufferLimits") + " " + prtdbl(rwin / rttsec) + " Mbps\n%0A";

        diagnosis.append(messages.getString("flowControlLimits") + " " + prtdbl(cwin / rttsec) + " Mbps\n");
        emailText += messages.getString("flowControlLimits") + " " + prtdbl(cwin / rttsec) + " Mbps\n%0A";

        diagnosis.append("\n" + messages.getString("clientDataReports") + " '" + prttxt(c2sData) + "', "
                + messages.getString("clientAcksReport") + " '" + prttxt(c2sAck) + "'\n"
                + messages.getString("serverDataReports") + " '" + prttxt(s2cData) + "', "
                + messages.getString("serverAcksReport") + " '" + prttxt(s2cAck) + "'\n");
        pub_diagnosis = diagnosis.getText();

    }
}

From source file:web.diva.server.model.SomClustering.SomClustImgGenerator.java

public void drawTable(Graphics gr, Point UL, Dataset dataset, int[] selection, Graphics navgGr,
        int countNavUnit) {

    Font f = getTableFont(squareL - 1);
    AnnotationManager annManager = AnnotationManager.getAnnotationManager();
    String[] rowIds = dataset.getRowIds();

    Set<String> annotations = dataset.getRowAnnotationNamesInUse();
    if (annotations == null) {
        annotations = annManager.getManagedRowAnnotationNames();
    }//ww w .j ava 2 s  . c o  m

    String[][] inf; // row annotation matrix
    String[] headers; // header of the row annotation matrix
    if (annotations.isEmpty()) {
        inf = new String[dataset.getDataLength()][1];
        for (int i = 0; i < inf.length; i++) {
            inf[i][0] = rowIds[i];
        }
        headers = new String[] { "Row ID" };
    } else {
        headers = annotations.toArray(new String[annotations.size()]);
        inf = new String[dataset.getDataLength()][annotations.size()];
        for (int i = 0; i < headers.length; i++) {
            //ann manager need to re implemeinted?
            AnnotationLibrary anns = annManager.getRowAnnotations(headers[i]);
            for (int j = 0; j < inf.length; j++) {
                inf[j][i] = rowIds[j];//anns.getAnnotation(rowIds[j]);//
            }
        }
    }

    Graphics2D g2d = (Graphics2D) gr;
    Graphics2D g2dNav = (Graphics2D) navgGr;
    g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    g2dNav.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

    int X = UL.x;
    int Y = UL.y;
    //        int H = squareL;

    int L = dataset.getDataLength();
    int W = headers.length;

    JLabel l = new JLabel("    ");
    JLabel lNav = new JLabel(" ");
    //        l.setFont(f);
    //        l.setIconTextGap(2);
    javax.swing.border.Border UB = javax.swing.BorderFactory.createMatteBorder(0, 0, 0, 0, Color.WHITE);
    javax.swing.border.Border LB = javax.swing.BorderFactory.createMatteBorder(0, 0, 0, 0, Color.WHITE);

    //          Color borderColor = hex2Rgb("#e3e3e3");
    javax.swing.border.Border navBorder = javax.swing.BorderFactory.createMatteBorder(2, 0, 0, 0, Color.WHITE);

    l.setMaximumSize(new Dimension(200, squareL));
    lNav.setSize(new Dimension(2, 5));
    lNav.setBorder(navBorder);

    boolean drawTableHeader = false;

    //if there is not enough room for a header.. skip header.
    //        if (UL.y < squareL) {
    //            drawTableHeader = false;
    //        }

    if (Wd == null) {
        Wd = new int[inf[0].length];
        WdSUM = new int[inf[0].length];

        if (drawTableHeader) {
            for (int i = 0; i < headers.length; i++) {
                l.setText(headers[i]);
                l.validate();
                if (l.getPreferredSize().width > Wd[i]) {
                    Wd[i] = l.getPreferredSize().width + 16;
                }
            }
        }
        for (String[] inf1 : inf) {
            for (int j = 0; j < Wd.length; j++) {
                if (squareL < 6) {
                    Wd[j] = 5;
                    continue;
                }
                l.setText(inf1[j]);
                l.validate();
                if (l.getPreferredSize().width > Wd[j]) {
                    Wd[j] = l.getPreferredSize().width + 16;
                }
            }
        }

        WdSUM[0] = 0;

        for (int i = 0; i < Wd.length; i++) {
            WdSUM[i] = -1;
            for (int j = 0; j < i; j++) {
                WdSUM[i] += Wd[j] + 3;
            }
        }
    }

    Rectangle BNDS = new Rectangle();

    l.setBackground(Color.WHITE);
    l.setOpaque(true);

    lNav.setBackground(Color.WHITE);
    lNav.setOpaque(true);

    if (sideTree == null) {
        return;
    }

    f = getTableFont(squareL - 1);
    l.setFont(f);

    int[] LArr = sideTree.arrangement;
    int Rindex = 0;

    //draw the table header.. (if wanted)
    //        if (drawTableHeader) {
    //
    //            l.setBackground(Color.WHITE);
    //            l.setForeground(Color.white);
    //
    //            for (int j = 0; j < W; j++) {
    //                X = UL.x + WdSUM[j];
    //                Y = UL.y;
    //                BNDS.setBounds(X, Y, Wd[j], squareL + 1);
    //
    //                if (gr.getClipBounds() != null && !gr.getClipBounds().intersects(BNDS)) {
    //                    continue;
    //                }
    //                gr.translate(X, Y);
    //                l.setBounds(0, 0, Wd[j] + 1, squareL + 1);
    //                l.setBorder(LB);
    //
    //                if (squareL >= 6) {
    //                    l.setText(headers[j]);
    //                }
    //                l.validate();
    //                l.paint(gr);
    //                gr.translate(-X, -Y);
    //            }
    //        }
    l.setForeground(Color.WHITE);

    boolean[] sel = selectedRows((selection == null ? null : selection), dataset);
    boolean coloredNav = false;
    int navCounter = 0;
    for (int i = 0; i < L; i++) {

        Rindex = LArr[i];
        for (int j = 0; j < W; j++) {
            X = UL.x + WdSUM[j];
            Y = UL.y + (squareL * (i + 1));

            BNDS.setBounds(X, Y, Wd[j], squareL + 1);

            if (gr.getClipBounds() != null && !gr.getClipBounds().intersects(BNDS)) {
                continue;
            }

            if (sel[LArr[i]]) {

                for (Group group : dataset.getRowGroups()) {
                    if (group.isActive()) {
                        if (group.hasMember(Rindex)) {
                            l.setBackground(group.getColor());
                            if (!coloredNav) {
                                lNav.setBackground(Color.RED);
                                lNav.setForeground(Color.RED);
                                coloredNav = true;
                            }

                            break;

                        }
                    }

                }

                //                    l.setBackground(new Color(225, 225, 255));
            } else {
                //                   
                //                    if (!coloredNav) {
                //                                    lNav.setBackground(Color.WHITE);
                //                                    lNav.setForeground(Color.WHITE);                                  
                //                                }

                l.setBackground(Color.WHITE);
            }
            if (i != 0)
                gr.translate(X, Y);
            l.setBounds(0, 0, Wd[j] + 1, squareL + 1);

            if (i < L - 1) {
                l.setBorder(UB);
            } else {
                l.setBounds(0, 0, Wd[j] + 1, squareL + 1);
                l.setBorder(LB);
            }
            if (squareL >= 6) {
                l.setText(inf[Rindex][j]);
            }
            l.validate();
            l.paint(gr);
            gr.translate(-X, -Y);

        }
        if (navCounter >= countNavUnit) {
            navCounter = 0;
            lNav.validate();
            lNav.paint(navgGr);
            navgGr.translate(2, 0);
            coloredNav = false;
            lNav.setBackground(Color.WHITE);
            lNav.setForeground(Color.WHITE);

        }
        navCounter++;
    }

    //        if (squareL < 6) {
    //            return;
    //        }
    //
    //        l.setBackground(Color.WHITE);
    //        f = getTableFont(squareL - 2);
    //        //f = new Font("Arial",1,squareL-2);
    //        l.setFont(f);
    //
    //
    //        for (int j = 0; j < W; j++) {
    //            X = UL.x + WdSUM[j];
    //            Y = UL.y;
    //
    //            BNDS.setBounds(X, Y, Wd[j], squareL + 1);
    //            if (gr.getClipBounds() != null && !gr.getClipBounds().intersects(BNDS)) {
    //                continue;
    //            }
    //
    //            gr.translate(X, Y);
    //            l.setBounds(0, 0, Wd[j], squareL + 1);
    ////            l.setBorder(javax.swing.BorderFactory.createLineBorder(GridCol));
    //            l.setText(headers[j]);
    //            l.validate();
    //            gr.translate(-X, -Y);
    //        }

}

From source file:com.openbravo.pos.sales.JRetailPanelTicket.java

private JPanel getLabelPanel(String msg) {
    JPanel panel = new JPanel();
    Font font = new Font("Verdana", Font.BOLD, 12);
    panel.setFont(font);/*from   w w  w.  j a va2 s .  com*/
    panel.setOpaque(true);
    JLabel label = new JLabel(msg, JLabel.LEFT);
    label.setForeground(Color.RED);
    label.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    panel.add(label);

    return panel;
}

From source file:Form.Principal.java

public void PanelUsuarios() {
    int i = 0;/*from   w  w w .  ja v  a2  s  .  com*/
    int Altura = 0;
    Color gris = new Color(44, 44, 44);
    Color azul = new Color(0, 153, 255);
    Color rojo = new Color(221, 76, 76);
    try {
        //Consultamos todos los clientes
        ResultSet Comandos = Funcion.Select(st, "SELECT * FROM usuarios where Tipo!='Administrador';");
        //Ciclo para crear un panel para cada uno
        while (Comandos.next()) {
            //Creamos un panel con alineacion a la izquierda
            JPanel Panel = new JPanel();
            Panel.setLayout(null);
            jPanel12.add(Panel);
            //Tamao del panel
            Panel.setSize(500, 200);
            // La posicion y del panel ira incrementando para que no se encimen
            Altura = 40 + (i * 220);
            Panel.setLocation(175, Altura);
            Panel.setBackground(Color.white);
            Panel.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
            //Creamos label para mostrar los datos del cliente, el codigo html es para que al llegar al final del panel
            //se pase a la siguiente linea y para el margen izquierdo
            JLabel Foto = new JLabel();
            Foto.setSize(150, 150);
            File FotoPerfil = new File("Imagenes/Fotos Perfil/" + Comandos.getInt("id") + ".png");
            File FotoPerfil2 = new File("Imagenes/Fotos Perfil/" + Comandos.getInt("id") + ".jpg");
            if (FotoPerfil.exists()) {
                ImageIcon Imagen = new ImageIcon("Imagenes/Fotos Perfil/" + Comandos.getInt("id") + ".png");
                Image ImagenEscalada = Imagen.getImage().getScaledInstance(Foto.getWidth(), Foto.getHeight(),
                        Image.SCALE_SMOOTH);
                Icon IconoEscalado = new ImageIcon(ImagenEscalada);
                Foto.setIcon(IconoEscalado);
            } else if (FotoPerfil2.exists()) {
                ImageIcon Imagen = new ImageIcon("Imagenes/Fotos Perfil/" + Comandos.getInt("id") + ".jpg");
                Image ImagenEscalada = Imagen.getImage().getScaledInstance(Foto.getWidth(), Foto.getHeight(),
                        Image.SCALE_SMOOTH);
                Icon IconoEscalado = new ImageIcon(ImagenEscalada);
                Foto.setIcon(IconoEscalado);
            } else {
                ImageIcon Imagen = new ImageIcon(getClass().getResource("/Imagen/Default.png"));
                Image ImagenEscalada = Imagen.getImage().getScaledInstance(Foto.getWidth(), Foto.getHeight(),
                        Image.SCALE_SMOOTH);
                Icon IconoEscalado = new ImageIcon(ImagenEscalada);
                Foto.setIcon(IconoEscalado);
            }
            JLabel Nombre = new JLabel();
            Nombre.setText("Nombre de Usuario: " + Comandos.getString("Nombre"));
            JLabel Contrasena = new JLabel();
            Contrasena.setText(("Contrasea: " + Comandos.getString("contrasena")));
            JButton Editar = new JButton();
            Editar.setText("Editar");
            Editar.setName(Comandos.getString("id"));
            Editar.setBackground(azul);
            JButton Eliminar = new JButton();
            Eliminar.setText("Eliminar");
            Eliminar.setName(Comandos.getString("id"));
            Eliminar.setBackground(rojo);
            MouseListener mlEditar = new MouseListener() {
                @Override
                public void mouseReleased(MouseEvent e) {
                    //System.out.println("Released!");
                }

                @Override
                public void mousePressed(MouseEvent e) {
                    //System.out.println("Pressed!");
                }

                @Override
                public void mouseExited(MouseEvent e) {
                    //System.out.println("Exited!");
                }

                @Override
                public void mouseEntered(MouseEvent e) {
                    //System.out.println("Entered!");
                }

                @Override
                public void mouseClicked(MouseEvent e) {
                    presionadoactual = 24;
                    Color azul = new Color(0, 182, 230);
                    jButton24.setBackground(azul);
                    JButton source = (JButton) e.getSource();
                    System.out.println(source.getName());
                    jPanel17.setVisible(false);
                    jButton30.setLocation(470, 480);
                    jButton31.setLocation(270, 480);
                    jLabel2.setToolTipText(null);
                    jTabbedPane2.setSelectedIndex(5);
                    editando = true;
                    PerfilUsuario(Integer.parseInt(source.getName()));
                    Color gris = new Color(44, 44, 44);
                    jButton4.setBackground(gris);
                }
            };
            MouseListener mlEliminar = new MouseListener() {
                @Override
                public void mouseReleased(MouseEvent e) {
                    //System.out.println("Released!");
                }

                @Override
                public void mousePressed(MouseEvent e) {
                    //System.out.println("Pressed!");
                }

                @Override
                public void mouseExited(MouseEvent e) {
                    //System.out.println("Exited!");
                }

                @Override
                public void mouseEntered(MouseEvent e) {
                    //System.out.println("Entered!");
                }

                @Override
                public void mouseClicked(MouseEvent e) {
                    JButton source = (JButton) e.getSource();
                    System.out.println(source.getName());
                    Funcion.Update(st, "DELETE FROM usuarios WHERE id = " + source.getName() + ";");
                    jPanel12.removeAll();
                    PanelUsuarios();
                    jPanel12.repaint();
                }
            };
            Editar.addMouseListener(mlEditar);
            Eliminar.addMouseListener(mlEliminar);
            //Fuente del texto;
            Nombre.setFont(new Font("Verdana", Font.PLAIN, 15));
            Nombre.setForeground(gris);
            Contrasena.setFont(new Font("Verdana", Font.PLAIN, 15));
            Contrasena.setForeground(gris);
            Editar.setFont(new Font("Verdana", Font.PLAIN, 15));
            Editar.setForeground(Color.white);
            Eliminar.setFont(new Font("Verdana", Font.PLAIN, 15));
            Eliminar.setForeground(Color.white);
            //Aadimos los label al panel correspondiente del cliente
            Panel.add(Foto);
            Panel.add(Nombre);
            Panel.add(Contrasena);
            Panel.add(Editar);
            Panel.add(Eliminar);
            Foto.setLocation(10, 20);
            Nombre.setLocation(170, 30);
            Nombre.setSize(300, 45);
            Contrasena.setLocation(170, 60);
            Contrasena.setSize(300, 45);
            Editar.setLocation(170, 100);
            Editar.setSize(120, 40);
            Eliminar.setLocation(315, 100);
            Eliminar.setSize(120, 40);
            i++;
        }
    } catch (SQLException ex) {
        Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
    }
    //Dependiendo de cuantos clientes se agregaron, se ajusta el tamao del panel principal para que el scroll llegue hasta ahi
    jPanel12.setPreferredSize(new Dimension(jPanel12.getWidth(), Altura + 150));

}

From source file:com.openbravo.pos.sales.JRetailPanelTakeAway.java

private JPanel getLabelPanel(String msg) {
    JPanel panel = new JPanel();
    Font font = new Font("Verdana", Font.BOLD, 12);
    panel.setFont(font);/*from   w w w. j  a  va 2 s.  c  om*/
    panel.setOpaque(true);
    // panel.setBackground(Color.BLUE);
    JLabel label = new JLabel(msg, JLabel.LEFT);
    label.setForeground(Color.RED);
    label.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    panel.add(label);

    return panel;
}

From source file:Form.Principal.java

public void PanelClientes() {
    int i = 0;/*from   w  w  w. j a  va2 s  .com*/
    int Altura = 0;
    Color gris = new Color(44, 44, 44);
    Color rojo = new Color(221, 76, 76);
    Color azul = new Color(0, 153, 255);
    try {
        //Consultamos todos los clientes
        ResultSet Comandos = Funcion.Select(st, "SELECT * FROM cliente;");
        //Ciclo para crear un panel para cada uno
        while (Comandos.next()) {
            //Creamos un panel con alineacion a la izquierda
            JPanel Panel = new JPanel();
            Panel.setLayout(null);
            jPanel8.add(Panel);
            //Tamao del panel
            Panel.setSize(700, 195);
            // La posicion y del panel ira incrementando para que no se encimen
            Altura = 30 + (i * 205);
            Panel.setLocation(50, Altura);
            Panel.setBackground(Color.white);
            Panel.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
            //Creamos label para mostrar los datos del cliente, el codigo html es para que al llegar al final del panel
            //se pase a la siguiente linea y para el margen izquierdo
            JLabel RFC = new JLabel();
            RFC.setText("RFC: " + Comandos.getString("RFC"));
            JLabel Nombre = new JLabel();
            Nombre.setText("Nombre: " + Comandos.getString("NombreCliente"));
            JTextArea Direccion = new JTextArea();
            Direccion.setLineWrap(true);
            Direccion.setBorder(null);
            Direccion.setText("Direccin: " + Comandos.getString("Direccion"));
            JLabel Correo = new JLabel();
            Correo.setText("Correo: " + Comandos.getString("correo"));
            JButton VerMas = new JButton();
            VerMas.setText("Ver ms");
            VerMas.setName(Comandos.getString("idCliente"));
            VerMas.setBackground(azul);
            JButton Eliminar = new JButton();
            Eliminar.setText("Eliminar");
            Eliminar.setName(Comandos.getString("idCliente"));
            Eliminar.setBackground(rojo);
            MouseListener mlVerMas = new MouseListener() {
                @Override
                public void mouseReleased(MouseEvent e) {
                    //System.out.println("Released!");
                }

                @Override
                public void mousePressed(MouseEvent e) {
                    //System.out.println("Pressed!");
                }

                @Override
                public void mouseExited(MouseEvent e) {
                    //System.out.println("Exited!");
                }

                @Override
                public void mouseEntered(MouseEvent e) {
                    //System.out.println("Entered!");
                    e.getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
                }

                @Override
                public void mouseClicked(MouseEvent e) {
                    JButton source = (JButton) e.getSource();
                    id = Integer.parseInt(source.getName());
                    jTabbedPane2.setSelectedIndex(4);
                    jButton16.setVisible(true);
                    jButton17.setVisible(true);
                    jButtonEditar.setVisible(true);
                    jPanel9.setVisible(true);
                    jPanel10.setVisible(true);
                    jPanel14.setVisible(false);
                    LlenarPanel();
                }
            };
            VerMas.addMouseListener(mlVerMas);
            MouseListener mlEliminar = new MouseListener() {
                @Override
                public void mouseReleased(MouseEvent e) {
                    //System.out.println("Released!");
                }

                @Override
                public void mousePressed(MouseEvent e) {
                    //System.out.println("Pressed!");
                }

                @Override
                public void mouseExited(MouseEvent e) {
                    //System.out.println("Exited!");
                }

                @Override
                public void mouseEntered(MouseEvent e) {
                    //System.out.println("Entered!");
                    e.getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
                }

                @Override
                public void mouseClicked(MouseEvent e) {
                    JButton source = (JButton) e.getSource();
                    Funcion.Update(st, "DELETE FROM cliente WHERE idCliente = " + source.getName() + ";");
                    Autocompletar.removeAllItems();
                    Autocompletar = new TextAutoCompleter(jTextField2);
                    ResultSet Comandos = Funcion.Select(st, "SELECT * FROM cliente;");
                    try {
                        while (Comandos.next()) {
                            Autocompletar.addItem(Comandos.getString("RFC"));
                        }
                    } catch (SQLException ex) {
                        //Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    jPanel8.removeAll();
                    PanelClientes();
                    jPanel8.repaint();
                }
            };
            Eliminar.addMouseListener(mlEliminar);
            //Fuente del texto
            RFC.setFont(new Font("Verdana", Font.PLAIN, 14));
            RFC.setForeground(gris);
            Nombre.setFont(new Font("Verdana", Font.PLAIN, 14));
            Nombre.setForeground(gris);
            Direccion.setFont(new Font("Verdana", Font.PLAIN, 14));
            Direccion.setForeground(gris);
            Correo.setFont(new Font("Verdana", Font.PLAIN, 14));
            Correo.setForeground(gris);
            VerMas.setFont(new Font("Verdana", Font.PLAIN, 14));
            VerMas.setForeground(Color.white);
            Eliminar.setFont(new Font("Verdana", Font.PLAIN, 14));
            Eliminar.setForeground(Color.white);
            /*VERMAS.setFont(new Font("Verdana", Font.PLAIN, 13));
            VERMAS.setForeground(azul);*/
            //Aadimos los label al panel correspondiente del cliente
            Panel.add(RFC);
            Panel.add(Nombre);
            Panel.add(Direccion);
            Panel.add(Correo);
            Panel.add(VerMas);
            Panel.add(Eliminar);
            RFC.setLocation(30, 10);
            RFC.setSize(610, 30);
            Nombre.setLocation(30, 40);
            Nombre.setSize(610, 30);
            Direccion.setLocation(30, 75);
            Direccion.setSize(610, 40);
            Correo.setLocation(30, 115);
            Correo.setSize(610, 30);
            VerMas.setLocation(210, 150);
            VerMas.setSize(120, 35);
            Eliminar.setLocation(390, 150);
            Eliminar.setSize(120, 35);
            //Panel.add(VERMAS);
            i++;
        }
    } catch (SQLException ex) {
        Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
    }
    //Dependiendo de cuantos clientes se agregaron, se ajusta el tamao del panel principal para que el scroll llegue hasta ahi
    jPanel8.setPreferredSize(new Dimension(jPanel8.getWidth(), Altura + 205));
}

From source file:Form.Principal.java

public void PanelFacturas() {
    int i = 0;/*w ww.  ja  v  a2  s  .co  m*/
    int Altura = 0;
    Color gris = new Color(44, 44, 44);
    Color azul = new Color(0, 153, 255);
    Color rojo = new Color(221, 76, 76);
    try {
        //Consultamos todos los clientes
        ResultSet Comandos = Funcion.Select(st,
                "SELECT factura_emitida.*, cliente.*  FROM cliente,factura_emitida  WHERE factura_emitida.idCliente = cliente.idCliente;");
        //Ciclo para crear un panel para cada uno
        while (Comandos.next()) {
            Variables.Comentario = Comandos.getString("Observaciones");
            //Creamos un panel con alineacion a la izquierda
            JPanel Panel = new JPanel();
            Panel.setLayout(null);
            jPanel11.add(Panel);
            //Tamao del panel
            Panel.setSize(680, 200);
            // La posicion y del panel ira incrementando para que no se encimen
            Altura = 30 + (i * 250);
            Panel.setLocation(50, Altura);
            Panel.setBackground(Color.white);
            Panel.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
            //Creamos label para mostrar los datos del cliente, el codigo html es para que al llegar al final del panel
            //se pase a la siguiente linea y para el margen izquierdo

            JLabel FolioFactura = new JLabel();
            FolioFactura.setText("Folio de factura: " + Comandos.getString("idFacturaEmitida"));
            JLabel RFC = new JLabel();
            RFC.setText("RFC: " + Comandos.getString("RFC"));
            JLabel Nombre = new JLabel();
            Nombre.setText("Nombre: " + Comandos.getString("NombreCliente"));
            JLabel Direccion = new JLabel();
            Direccion.setText("Direccion: " + Comandos.getString("Direccion"));
            JLabel Correo = new JLabel();
            Correo.setText("Correo: " + Comandos.getString("correo"));
            JLabel Fecha = new JLabel();
            Fecha.setText("Fecha y Hora de emisin: " + Comandos.getString("FechaEmision"));

            JButton Abre = new JButton();
            Abre.setText("Abrir");
            Abre.setName(Comandos.getString("idFacturaEmitida"));
            Abre.setBackground(azul);
            JButton Cancelar = new JButton();
            Cancelar.setText("Cancelar");
            Cancelar.setName(Comandos.getString("idFacturaEmitida"));
            Cancelar.setBackground(rojo);
            MouseListener mlAbre = new MouseListener() {
                @Override
                public void mouseReleased(MouseEvent e) {
                    //System.out.println("Released!");
                }

                @Override
                public void mousePressed(MouseEvent e) {
                    //System.out.println("Pressed!");
                }

                @Override
                public void mouseExited(MouseEvent e) {
                    //System.out.println("Exited!");
                }

                @Override
                public void mouseEntered(MouseEvent e) {
                    //System.out.println("Entered!");
                }

                @Override
                public void mouseClicked(MouseEvent e) {
                    try {
                        JButton source = (JButton) e.getSource();
                        idFacClien = Integer.parseInt(source.getName());
                        ResultSet Comandos = Funcion.Select(st,
                                "SELECT *FROM factura_emitida  WHERE idfacturaEmitida=" + idFacClien + ";");
                        while (Comandos.next()) {
                            Variables.FechaFactura = Comandos.getString("FechaEmision");
                            Variables.FechaSistema = Comandos.getString("fechasistema");
                            Variables.idFactura = Comandos.getInt("idFacturaEmitida");
                        }
                        Consulta();
                        Variables.guardar = false;
                        NuevoPdf pdf = new NuevoPdf("Factura.pdf");
                        pdf.main();
                        File myfile = new File("Factura.pdf");
                        Desktop.getDesktop().open(myfile);
                        Comandos = Funcion.Select(st, "SELECT * FROM factura_emitida;");
                        try {
                            if (Comandos.next()) {
                                Comandos.last();
                                Variables.idFactura = Comandos.getInt("idFacturaEmitida") + 1;
                            } else {
                                Variables.idFactura = 1;
                            }
                        } catch (SQLException ex) {
                            Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
                        }
                    } catch (Exception ex) {
                        Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            };
            MouseListener mlCancelar = new MouseListener() {
                @Override
                public void mouseReleased(MouseEvent e) {
                    //System.out.println("Released!");
                }

                @Override
                public void mousePressed(MouseEvent e) {
                    //System.out.println("Pressed!");
                }

                @Override
                public void mouseExited(MouseEvent e) {
                    //System.out.println("Exited!");
                }

                @Override
                public void mouseEntered(MouseEvent e) {
                    //System.out.println("Entered!");
                }

                @Override
                public void mouseClicked(MouseEvent e) {
                    JButton source = (JButton) e.getSource();
                    Variables.Cancelar = Integer.parseInt(source.getName());
                    String Comando = "UPDATE factura_emitida SET Observaciones='Factura Cancelada' WHERE idFacturaEmitida="
                            + Variables.Cancelar + ";";
                    Funcion.Update(st, Comando);
                    jPanel11.removeAll();
                    PanelFacturas();
                    jPanel11.repaint();
                }
            };
            Abre.addMouseListener(mlAbre);
            Cancelar.addMouseListener(mlCancelar);
            //Fuente del texto;
            FolioFactura.setFont(new Font("Verdana", Font.PLAIN, 13));
            FolioFactura.setForeground(gris);
            RFC.setFont(new Font("Verdana", Font.PLAIN, 13));
            RFC.setForeground(gris);
            Nombre.setFont(new Font("Verdana", Font.PLAIN, 13));
            Nombre.setForeground(gris);
            Direccion.setFont(new Font("Verdana", Font.PLAIN, 13));
            Direccion.setForeground(gris);
            Correo.setFont(new Font("Verdana", Font.PLAIN, 13));
            Correo.setForeground(gris);
            Fecha.setFont(new Font("Verdana", Font.PLAIN, 13));
            Fecha.setForeground(gris);
            /// Botones
            Abre.setFont(new Font("Verdana", Font.PLAIN, 15));
            Abre.setForeground(Color.white);
            Cancelar.setFont(new Font("Verdana", Font.PLAIN, 15));
            Cancelar.setForeground(Color.white);
            //Aadimos los label al panel correspondiente del cliente
            Panel.add(FolioFactura);
            Panel.add(RFC);
            Panel.add(Nombre);
            Panel.add(Direccion);
            Panel.add(Correo);
            Panel.add(Fecha);
            Panel.add(Abre);

            FolioFactura.setLocation(15, 5);
            FolioFactura.setSize(400, 45);

            RFC.setLocation(15, 25);
            RFC.setSize(400, 45);

            Nombre.setLocation(15, 45);
            Nombre.setSize(500, 45);

            Direccion.setLocation(15, 65);
            Direccion.setSize(650, 45);

            Correo.setLocation(15, 85);
            Correo.setSize(500, 45);

            Fecha.setLocation(15, 105);
            Fecha.setSize(500, 45);
            /// Botones Tamao y localizacion
            if (Variables.Tipo.equalsIgnoreCase("Administrador")) { // Verificamos que sea un Administrador
                Panel.add(Cancelar);
                Abre.setLocation(185, 160);
                Abre.setSize(120, 30);
                Cancelar.setLocation(350, 160);
                Cancelar.setSize(120, 30);

                if (Variables.Comentario.equalsIgnoreCase("Factura Cancelada")) {
                    Cancelar.setVisible(false);
                    Abre.setLocation(290, 160);
                    Abre.setSize(120, 30);
                }

            } else {
                Abre.setLocation(290, 160);
                Abre.setSize(120, 30);
            }

            i++;
        }
    } catch (SQLException ex) {
        Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
    }
    //Dependiendo de cuantos clientes se agregaron, se ajusta el tamao del panel principal para que el scroll llegue hasta ahi
    jPanel11.setPreferredSize(new Dimension(jPanel11.getWidth(), Altura + 300));

}

From source file:net.technicpack.launcher.ui.InstallerFrame.java

private void initComponents() {
    setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
    setIconImage(resources.getImage("icon.png"));
    setLayout(new BorderLayout());

    JPanel header = new JPanel();
    header.setBackground(Color.black);
    header.setLayout(new BoxLayout(header, BoxLayout.LINE_AXIS));
    header.setBorder(BorderFactory.createEmptyBorder(4, 8, 4, 8));
    add(header, BorderLayout.PAGE_START);

    JLabel title = new JLabel(resources.getString("launcher.installer.title"));
    title.setFont(resources.getFont(ResourceLoader.FONT_RALEWAY, 34));
    title.setForeground(LauncherFrame.COLOR_WHITE_TEXT);
    title.setOpaque(false);/*  w  w w .j  a  v a 2s.co  m*/
    title.setIcon(resources.getIcon("options_cog.png"));
    header.add(title);

    header.add(Box.createHorizontalGlue());

    JButton closeButton = new JButton();
    closeButton.setIcon(resources.getIcon("close.png"));
    closeButton.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    closeButton.setContentAreaFilled(false);
    closeButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    closeButton.setFocusPainted(false);
    closeButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            mainFrame.setVisible(true);
            dispose();
        }
    });
    header.add(closeButton);

    SimpleTabPane centerPanel = new SimpleTabPane();
    centerPanel.setBackground(LauncherFrame.COLOR_FORMELEMENT_INTERNAL);
    centerPanel.setForeground(LauncherFrame.COLOR_GREY_TEXT);
    centerPanel.setSelectedBackground(LauncherFrame.COLOR_BLUE);
    centerPanel.setSelectedForeground(LauncherFrame.COLOR_WHITE_TEXT);
    centerPanel.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 14));
    centerPanel.setOpaque(true);
    add(centerPanel, BorderLayout.CENTER);

    JPanel standardInstallPanel = new JPanel();
    standardInstallPanel.setBackground(LauncherFrame.COLOR_CENTRAL_BACK_OPAQUE);

    setupStandardInstall(standardInstallPanel);

    JPanel portableModePanel = new JPanel();
    portableModePanel.setBackground(LauncherFrame.COLOR_CENTRAL_BACK_OPAQUE);

    setupPortableMode(portableModePanel);

    centerPanel.addTab(resources.getString("launcher.installer.standard").toUpperCase(), standardInstallPanel);
    centerPanel.addTab(resources.getString("launcher.installer.portable").toUpperCase(), portableModePanel);

    if (settings.isPortable()) {
        centerPanel.setSelectedIndex(1);
    } else
        centerPanel.setSelectedIndex(0);

    setLocationRelativeTo(null);
}