Example usage for javax.swing DefaultComboBoxModel DefaultComboBoxModel

List of usage examples for javax.swing DefaultComboBoxModel DefaultComboBoxModel

Introduction

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

Prototype

public DefaultComboBoxModel(Vector<E> v) 

Source Link

Document

Constructs a DefaultComboBoxModel object initialized with a vector.

Usage

From source file:edu.harvard.mcz.imagecapture.SpecimenDetailsViewPane.java

private JComboBox getComboBoxElevUnits() {
    if (comboBoxElevUnits == null) {
        comboBoxElevUnits = new JComboBox();
        comboBoxElevUnits.setModel(new DefaultComboBoxModel(new String[] { "", "?", "m", "ft" }));
    }//from   ww  w.j av a2  s.  c  om
    return comboBoxElevUnits;
}

From source file:atlas.kingj.roi.FrmMain.java

private void LoadSettings() {
    try {//from  w  w  w.j a  va 2s  . c o m
        String saveloc = "";
        if (((new File("config.ser")).exists()) && !(new File(Consts.SETTINGS_FILENAME)).exists())
            saveloc = ((new File("config.ser")).getAbsolutePath());
        else
            saveloc = Consts.SETTINGS_FILENAME;
        FileInputStream fin = new FileInputStream(saveloc);
        ObjectInputStream ois = new ObjectInputStream(fin);
        environment = (Production) ois.readObject();
        ois.close();

        if (environment.SaveOnClose && !environment.SaveFileName.equals(saveloc)) {
            try {
                fin = new FileInputStream(environment.SaveFileName);
                ois = new ObjectInputStream(fin);
                environment = (Production) ois.readObject();
                ois.close();
                if (environment == null)
                    throw new Exception();
            } catch (Exception e) {
                // reload original
                fin = new FileInputStream(saveloc);
                ois = new ObjectInputStream(fin);
                environment = (Production) ois.readObject();
                ois.close();
                environment.SaveFileName = saveloc;
            }
        }

        environment.Unlocked = false;
        environment.StartStopTimes = true;
        environment.HrsPerDay = 24;
        environment.HrsPerShift = 8;
        environment.HrsPerYear = 6000;

        if (!environment.SaveOnClose) {
            environment = new Production();
            environment.SaveOnClose = false;
        } else {
            if (environment.getSchedule() == null)
                environment.setSchedule(new JobSchedule());
            else {
                int size = environment.getSchedule().getSize();
                for (int i = 0; i < size; ++i) {
                    scheduleModel.addElement(environment.getSchedule().getJob(i));
                }
                btnRemoveJob.setEnabled(true);
                btnUpSchedule.setEnabled(true);
                btnViewSchedule.setEnabled(true);
                btnClearSchedule.setEnabled(true);
                listSchedule.setSelectedIndex(size);
            }
            if (!environment.metric) {
                ChangeUnits();
                rdbtnmntmImperial.setSelected(true);
                // manual job form change
                cmbRewindCore.setModel(new DefaultComboBoxModel(Consts.REWIND_CORE_IN));
                cmbUnwindCore.setModel(new DefaultComboBoxModel(Consts.UNWIND_CORE_IN));
                cmbUnwindType.setModel(new DefaultComboBoxModel(
                        new String[] { "Length (ft)", "Weight (ton)", "Diameter (in)" }));
                cmbRewindType.setModel(new DefaultComboBoxModel(
                        new String[] { "Length (ft)", "Weight (lbs)", "Diameter (in)" }));
                cmbTargetTotal
                        .setModel(new DefaultComboBoxModel(new String[] { "Length (ft)", "Weight (ton)" }));
                cmbRewindCore.setSelectedIndex(1);
                txtThickness.setText("0.79");
                txtUnwindAmount.setText("32810");
                txtRewindAmount.setText("3281.0");
                txtLimitRunSpeed.setText("2624.8");
                txtTargetTotal.setText("32810");
                txtWebWidth.setText("53.15");
                txtSlitWidth.setText("53.15");
                lblTrim.setText("0 in");
                lblTrim.setText("0 in");
            }
        }
    } catch (Exception e) {
        environment = new Production();
    }
}

From source file:atlas.kingj.roi.FrmMain.java

private void ChangeUnits() {

    boolean backup = jobFormReady;
    jobFormReady = false;/*from  w w  w  .  ja va 2  s  . c  o m*/

    if (jobModel.getSize() > 0) {

        //ClearComponents();
        if (metric) {
            // Change metric -> imperial
            //PopulateComboBox(cmbRewindCore, Consts.REWIND_CORE_IN);
            //lblRewindCoremm.setText(Consts.LBL_REWIND_CORE_IN);
            ConvertTextBox(txtThickness, Core.MicroToMil(1));
            ConvertTextBox(txtSlitWidth, Core.MMToIn(1));
            ConvertTextBox(txtWebWidth, Core.MMToIn(1));
            ConvertTextBox(txtLimitRunSpeed, Core.MToFt(1));
            ConvertTextBox(txtTargetTotal, (cmbTargetTotal.getSelectedIndex() == 0 ? Core.MToFt(1)
                    : (cmbTargetTotal.getSelectedIndex() == 1 ? Core.KgToTon(1) : Core.TonneToTon(1))));
            ConvertTextBox(txtRewindAmount, (cmbRewindType.getSelectedIndex() == 0 ? Core.MToFt(1)
                    : (cmbRewindType.getSelectedIndex() == 1 ? Core.KgToLbs(1) : Core.MMToIn(1))));
            ConvertTextBox(txtUnwindAmount, (cmbUnwindType.getSelectedIndex() == 0 ? Core.MToFt(1)
                    : (cmbUnwindType.getSelectedIndex() == 1 ? Core.KgToTon(1) : Core.MMToIn(1))));

            int[] indices = { cmbUnwindType.getSelectedIndex(), cmbRewindType.getSelectedIndex(),
                    cmbTargetTotal.getSelectedIndex() };
            cmbUnwindType.setModel(
                    new DefaultComboBoxModel(new String[] { "Length (ft)", "Weight (ton)", "Diameter (in)" }));
            cmbRewindType.setModel(
                    new DefaultComboBoxModel(new String[] { "Length (ft)", "Weight (lbs)", "Diameter (in)" }));
            cmbTargetTotal.setModel(new DefaultComboBoxModel(new String[] { "Length (ft)", "Weight (ton)" }));
            if (oldTotalsIndex == 2)
                oldTotalsIndex = 1;
            cmbUnwindType.setSelectedIndex(indices[0]);
            cmbRewindType.setSelectedIndex(indices[1]);
            if (indices[2] > 1)
                indices[2] = 1;
            cmbTargetTotal.setSelectedIndex(indices[2]);

            //ConvertComboBox(cmbRewindCore, Core.MMToIn(1));
            //ConvertComboBox(cmbUnwindCore, Core.MMToIn(1));
            Double currVal = Double
                    .parseDouble(((JTextField) cmbRewindCore.getEditor().getEditorComponent()).getText());
            Double currVal2 = Double
                    .parseDouble(((JTextField) cmbUnwindCore.getEditor().getEditorComponent()).getText());
            currVal *= Core.MMToIn(1);
            currVal2 *= Core.MMToIn(1);
            cmbRewindCore.setModel(new DefaultComboBoxModel(Consts.REWIND_CORE_IN));
            cmbUnwindCore.setModel(new DefaultComboBoxModel(Consts.UNWIND_CORE_IN));
            ((JTextField) cmbRewindCore.getEditor().getEditorComponent())
                    .setText(Double.toString(roundTwoDecimals(currVal)));
            ((JTextField) cmbUnwindCore.getEditor().getEditorComponent())
                    .setText(Double.toString(roundTwoDecimals(currVal2)));

            lblTrim.setText("0 in");
        } else {
            // Change imperial -> metric
            //SetComponents();
            ConvertTextBox(txtThickness, Core.MilToMicro(1));
            ConvertTextBox(txtSlitWidth, Core.InToMM(1));
            ConvertTextBox(txtWebWidth, Core.InToMM(1));
            ConvertTextBox(txtLimitRunSpeed, Core.FtToM(1));
            ConvertTextBox(txtTargetTotal,
                    (((Job) listJobs.getSelectedValue()).getTotalType() == 0 ? Core.FtToM(1)
                            : (((Job) listJobs.getSelectedValue()).getTotalType() == 1 ? Core.TonToKg(1)
                                    : Core.TonToTonne(1))));
            ConvertTextBox(txtRewindAmount, (cmbRewindType.getSelectedIndex() == 0 ? Core.FtToM(1)
                    : (cmbRewindType.getSelectedIndex() == 1 ? Core.LbsToKg(1) : Core.InToMM(1))));
            ConvertTextBox(txtUnwindAmount, (cmbUnwindType.getSelectedIndex() == 0 ? Core.FtToM(1)
                    : (cmbUnwindType.getSelectedIndex() == 1 ? Core.TonToKg(1) : Core.InToMM(1))));

            int[] indices = { cmbUnwindType.getSelectedIndex(), cmbRewindType.getSelectedIndex(),
                    cmbTargetTotal.getSelectedIndex() };
            cmbUnwindType.setModel(
                    new DefaultComboBoxModel(new String[] { "Length (m)", "Weight (kg)", "Diameter (mm)" }));
            cmbRewindType.setModel(
                    new DefaultComboBoxModel(new String[] { "Length (m)", "Weight (kg)", "Diameter (mm)" }));
            cmbTargetTotal.setModel(
                    new DefaultComboBoxModel(new String[] { "Length (m)", "Weight (kg)", "Weight (tonnes)" }));
            cmbUnwindType.setSelectedIndex(indices[0]);
            cmbRewindType.setSelectedIndex(indices[1]);
            cmbTargetTotal.setSelectedIndex(((Job) listJobs.getSelectedValue()).getTotalType());//indices[2]);
            oldTotalsIndex = ((Job) listJobs.getSelectedValue()).getTotalType();

            //ConvertComboBox(cmbRewindCore, Core.InToMM(1));
            //ConvertComboBox(cmbUnwindCore, Core.InToMM(1));
            Double currVal = Double
                    .parseDouble(((JTextField) cmbRewindCore.getEditor().getEditorComponent()).getText());
            Double currVal2 = Double
                    .parseDouble(((JTextField) cmbUnwindCore.getEditor().getEditorComponent()).getText());
            currVal *= Core.InToMM(1);
            currVal2 *= Core.InToMM(1);
            cmbRewindCore.setModel(new DefaultComboBoxModel(Consts.REWIND_CORE_MM));
            cmbUnwindCore.setModel(new DefaultComboBoxModel(Consts.UNWIND_CORE_MM));
            ((JTextField) cmbRewindCore.getEditor().getEditorComponent())
                    .setText(Double.toString(roundTwoDecimals(currVal)));
            ((JTextField) cmbUnwindCore.getEditor().getEditorComponent())
                    .setText(Double.toString(roundTwoDecimals(currVal2)));

            lblTrim.setText("0 mm");

        }

    }

    jobFormReady = backup;

    ConvertLabels(labs, metric);

    metric = !metric;

    if (jobModel.getSize() < 1)
        ResetJobForm();

    environment.metric = metric;

    ChangeRoiUnits();

    UpdateJobForm();

    UpdateTrim();

    UpdateNumericalAnalysis();

    UpdateROI();

    if (!initialising) {
        ShowMessageSuccess("Units changed to: " + (metric ? "metric" : "imperial"));
    }
}

From source file:com.peterbochs.PeterBochsDebugger.java

private JComboBox getJSearchMemoryFromComboBox() {
    if (jSearchMemoryFromComboBox == null) {
        ComboBoxModel jSearchMemoryFromComboBoxModel = new DefaultComboBoxModel(new String[] {});
        jSearchMemoryFromComboBox = new JComboBox();
        jSearchMemoryFromComboBox.setModel(jSearchMemoryFromComboBoxModel);
        jSearchMemoryFromComboBox.setEditable(true);
        jSearchMemoryFromComboBox.setPreferredSize(new java.awt.Dimension(120, 22));
    }//  w w  w  .  j  a  v  a  2 s  .  c o m
    return jSearchMemoryFromComboBox;
}

From source file:com.peterbochs.PeterBochsDebugger.java

private JComboBox getJSearchMemoryToComboBox() {
    if (jSearchMemoryToComboBox == null) {
        ComboBoxModel jSearchMemoryToComboBoxModel = new DefaultComboBoxModel(new String[] {});
        jSearchMemoryToComboBox = new JComboBox();
        jSearchMemoryToComboBox.setModel(jSearchMemoryToComboBoxModel);
        jSearchMemoryToComboBox.setEditable(true);
        jSearchMemoryToComboBox.setPreferredSize(new java.awt.Dimension(120, 22));
    }/*from   www  .  j a  v  a  2s .  c  o m*/
    return jSearchMemoryToComboBox;
}

From source file:com.peterbochs.PeterBochsDebugger.java

private JSplitPane getJSplitPane2() {
    jSplitPane2 = new JSplitPane();

    jSplitPane2.setPreferredSize(new java.awt.Dimension(1009, 781));
    jSplitPane2.setOrientation(JSplitPane.VERTICAL_SPLIT);
    {//from  ww w.  ja  v a2 s .  c o m
        jSplitPane1 = new JSplitPane();
        jSplitPane2.add(jSplitPane1, JSplitPane.TOP);
        jSplitPane1.setDividerLocation(400);
        {
            jTabbedPane1 = new JMaximizableTabbedPane();
            jSplitPane1.add(jTabbedPane1, JSplitPane.RIGHT);
            jTabbedPane1.addChangeListener(new ChangeListener() {
                public void stateChanged(ChangeEvent evt) {
                    jTabbedPane1StateChanged(evt);
                }
            });
            {
                jPanel10 = new JPanel();
                BorderLayout jPanel10Layout = new BorderLayout();
                jPanel10.setLayout(jPanel10Layout);
                jTabbedPane1.addTab(MyLanguage.getString("Instruction"),
                        new ImageIcon(getClass().getClassLoader()
                                .getResource("com/peterbochs/icons/famfam_icons/text_padding_top.png")),
                        jPanel10, null);
                jPanel10.setPreferredSize(new java.awt.Dimension(604, 452));
                {
                    jInstructionControlPanel = new JPanel();
                    jPanel10.add(jInstructionControlPanel, BorderLayout.NORTH);
                    {
                        ComboBoxModel jInstructionComboBoxModel = new DefaultComboBoxModel(new String[] {});
                        jInstructionComboBox = new JComboBox();
                        jInstructionControlPanel.add(jInstructionComboBox);
                        jInstructionControlPanel.add(getDisassembleButton());
                        jInstructionComboBox.setModel(jInstructionComboBoxModel);
                        jInstructionComboBox.setEditable(true);
                        jInstructionComboBox.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                jInstructionComboBoxActionPerformed(evt);
                            }
                        });
                    }
                    {
                        disassembleCurrentIPButton = new JButton();
                        jInstructionControlPanel.add(disassembleCurrentIPButton);
                        jInstructionControlPanel.add(getJInstructionUpTenButton());
                        jInstructionControlPanel.add(getJInstructionUpButton());
                        jInstructionControlPanel.add(getJButton22());
                        jInstructionControlPanel.add(getJButton3());
                        jInstructionControlPanel.add(getJButton12());
                        disassembleCurrentIPButton.setText(MyLanguage.getString("Disassemble") + " cs:eip");
                        disassembleCurrentIPButton.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                disassembleCurrentIPButtonActionPerformed(evt);
                            }
                        });
                    }
                }
                {
                    instructionTableScrollPane = new JScrollPane();
                    jPanel10.add(instructionTableScrollPane, BorderLayout.CENTER);
                    {
                        instructionTable = new JTable();
                        instructionTableScrollPane.setViewportView(instructionTable);
                        instructionTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
                        instructionTable.setModel(new InstructionTableModel());
                        instructionTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
                        instructionTable.getTableHeader().setReorderingAllowed(false);
                        instructionTable.getColumnModel().getColumn(0).setMaxWidth(20);
                        instructionTable.getColumnModel().getColumn(1).setPreferredWidth(40);
                        instructionTable.getColumnModel().getColumn(2).setPreferredWidth(200);
                        instructionTable.getColumnModel().getColumn(3).setPreferredWidth(40);
                        instructionTable.setDefaultRenderer(String.class, new InstructionTableCellRenderer());
                        instructionTable.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                instructionTableMouseClicked(evt);
                            }
                        });
                    }
                }
            }
            {
                jPanel4 = new JPanel();
                jTabbedPane1
                        .addTab(MyLanguage.getString("Breakpoint"),
                                new ImageIcon(getClass().getClassLoader()
                                        .getResource("com/peterbochs/icons/famfam_icons/cancel.png")),
                                jPanel4, null);
                BorderLayout jPanel4Layout = new BorderLayout();
                jPanel4.setLayout(jPanel4Layout);
                {
                    jScrollPane9 = new JScrollPane();
                    jPanel4.add(jScrollPane9, BorderLayout.CENTER);
                    {
                        breakpointTable = new JTable();
                        breakpointTable.getTableHeader().setReorderingAllowed(false);
                        jScrollPane9.setViewportView(breakpointTable);
                        breakpointTable.setModel(jBreakpointTableModel);
                        breakpointTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
                        breakpointTable.getColumnModel().getColumn(0)
                                .setCellRenderer(new BreakpointTableCellRenderer());
                        breakpointTable.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                breakpointTableMouseClicked(evt);
                            }
                        });
                        breakpointTable.getColumnModel().getColumn(2).setPreferredWidth(100);
                        breakpointTable.getColumnModel().getColumn(3).setPreferredWidth(20);
                    }
                }
                {
                    jPanel12 = new JPanel();
                    jPanel4.add(jPanel12, BorderLayout.SOUTH);
                    {
                        jAddBreakpointButton = new JButton();
                        jPanel12.add(jAddBreakpointButton);
                        jAddBreakpointButton.setText(MyLanguage.getString("Add"));
                        jAddBreakpointButton.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                jAddBreakpointButtonActionPerformed(evt);
                            }
                        });
                    }
                    {
                        jDeleteBreakpointButton = new JButton();
                        jPanel12.add(jDeleteBreakpointButton);
                        jDeleteBreakpointButton.setText(MyLanguage.getString("Del"));
                        jDeleteBreakpointButton.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                jDeleteBreakpointButtonActionPerformed(evt);
                            }
                        });
                    }
                    {
                        jRefreshBreakpointButton = new JButton();
                        jPanel12.add(jRefreshBreakpointButton);
                        jRefreshBreakpointButton.setText(MyLanguage.getString("Refresh"));
                        jRefreshBreakpointButton.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                jRefreshBreakpointButtonActionPerformed(evt);
                            }
                        });
                    }
                    {
                        jEnableBreakpointButton = new JButton();
                        jPanel12.add(jEnableBreakpointButton);
                        jEnableBreakpointButton.setText(MyLanguage.getString("Enable"));
                        jEnableBreakpointButton.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                jEnableBreakpointButtonActionPerformed(evt);
                            }
                        });
                    }
                    {
                        jDisableBreakpointButton = new JButton();
                        jPanel12.add(jDisableBreakpointButton);
                        jDisableBreakpointButton.setText(MyLanguage.getString("Disable"));
                        jDisableBreakpointButton.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                jDisableBreakpointButtonActionPerformed(evt);
                            }
                        });
                    }
                    {
                        jSaveBreakpointButton = new JButton();
                        jPanel12.add(jSaveBreakpointButton);
                        jSaveBreakpointButton.setText(MyLanguage.getString("Save"));
                        jSaveBreakpointButton.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                jSaveBreakpointButtonActionPerformed(evt);
                            }
                        });
                    }
                    {
                        jLoadBreakpointButton = new JDropDownButton();
                        jPanel12.add(jLoadBreakpointButton);
                        jPanel12.add(getJSBButton());
                        jPanel12.add(getJSBAButton());
                        jLoadBreakpointButton.setText(MyLanguage.getString("Load"));
                        jLoadBreakpointButton.add(loadElfMenuItem);
                        jLoadBreakpointButton.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                jLoadBreakpointButtonActionPerformed(evt);
                            }
                        });
                    }
                }
            }
            {
                jPanel1 = new JPanel();
                jTabbedPane1.addTab(MyLanguage.getString("Bochs"),
                        new ImageIcon(getClass().getClassLoader()
                                .getResource("com/peterbochs/icons/famfam_icons/application_xp_terminal.png")),
                        jPanel1, null);
                jTabbedPane1.addTab("ELF",
                        new ImageIcon(getClass().getClassLoader()
                                .getResource("com/peterbochs/icons/famfam_icons/linux.png")),
                        getJELFBreakpointPanel(), null);
                DiskPanel diskPanel = getDiskPanel();
                if (diskPanel.getFile() != null) {
                    jTabbedPane1.addTab(diskPanel.getFile().getName(),
                            new ImageIcon(getClass().getClassLoader()
                                    .getResource("com/peterbochs/icons/famfam_icons/package.png")),
                            diskPanel, null);
                }
                BorderLayout jPanel1Layout = new BorderLayout();
                jPanel1.setLayout(jPanel1Layout);
                {
                    jScrollPane4 = new JScrollPane();
                    jPanel1.add(jScrollPane4, BorderLayout.CENTER);
                    {
                        bochsEditorPane = new JEditorPane();
                        jScrollPane4.setViewportView(bochsEditorPane);
                    }
                }
                {
                    jPanel2 = new JPanel();
                    TableLayout jPanel2Layout = new TableLayout(new double[][] {
                            { TableLayout.FILL, 411.0, TableLayout.MINIMUM, TableLayout.MINIMUM },
                            { TableLayout.FILL } });
                    jPanel2Layout.setHGap(5);
                    jPanel2Layout.setVGap(5);
                    jPanel2.setLayout(jPanel2Layout);
                    jPanel1.add(jPanel2, BorderLayout.SOUTH);
                    {
                        bochsCommandTextField = new JTextField();
                        jPanel2.add(bochsCommandTextField, "0, 0, 1, 0");
                        bochsCommandTextField.addKeyListener(new KeyAdapter() {
                            public void keyPressed(KeyEvent evt) {
                                jBochsCommandTextFieldKeyPressed(evt);
                            }

                            public void keyTyped(KeyEvent evt) {
                                bochsCommandTextFieldKeyTyped(evt);
                            }
                        });
                    }
                    {
                        bochsCommandButton = new JButton();
                        jPanel2.add(bochsCommandButton, "2, 0");
                        jPanel2.add(getJClearBochsButton(), "3, 0");
                        bochsCommandButton.setText("Run");
                        bochsCommandButton.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                bochsCommandButtonActionPerformed(evt);
                            }
                        });
                    }
                }
            }
        }
        {
            jTabbedPane3 = new JMaximizableTabbedPane();
            jSplitPane1.add(jTabbedPane3, JSplitPane.LEFT);
            {
                jPanel8 = new JPanel();
                BorderLayout jPanel8Layout = new BorderLayout();
                jPanel8.setLayout(jPanel8Layout);
                jTabbedPane3
                        .addTab(MyLanguage.getString("Memory"),
                                new ImageIcon(getClass().getClassLoader()
                                        .getResource("com/peterbochs/icons/famfam_icons/memory.png")),
                                jPanel8, null);
                {
                    jScrollPane2 = new JScrollPane();
                    jPanel8.add(jScrollPane2, BorderLayout.CENTER);
                    {
                        jHexTable1 = new HexTable();
                        jHexTable1.getColumnModel().getColumn(0).setPreferredWidth(30);
                        for (int x = 1; x < 9; x++) {
                            jHexTable1.getColumnModel().getColumn(x).setPreferredWidth(10);
                        }
                        jScrollPane2.setViewportView(jHexTable1);
                        jHexTable1.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
                        jHexTable1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
                        jHexTable1.setCellSelectionEnabled(true);
                        jHexTable1.getTableHeader().setReorderingAllowed(false);
                        jHexTable1.setDefaultRenderer(String.class, new MemoryTableCellRenderer());
                        jHexTable1.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                jHexTable1MouseClicked(evt);
                            }
                        });
                    }
                }
                {
                    jPanel9 = new JPanel();
                    FlowLayout jPanel9Layout = new FlowLayout();
                    jPanel9.setLayout(jPanel9Layout);
                    jPanel8.add(jPanel9, BorderLayout.NORTH);
                    {
                        jMemoryAddressComboBox = new JComboBox();
                        jPanel9.add(jMemoryAddressComboBox);
                        jMemoryAddressComboBox.setSelectedItem("0x00000000");
                        jMemoryAddressComboBox.setEditable(true);
                        jMemoryAddressComboBox.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                jMemoryAddressComboBoxActionPerformed(evt);
                            }
                        });
                        new Thread("addMemoryAddressComboBox thread") {
                            public void run() {
                                TreeSet<String> vector = Setting.getInstance().getMemoryCombo();

                                Iterator<String> iterator = vector.iterator();
                                while (iterator.hasNext()) {
                                    addMemoryAddressComboBox(iterator.next());
                                }
                            }
                        }.start();
                        jMemoryAddressComboBox.setSelectedItem("0x00000000");
                    }
                    {
                        jGOMemoryButton = new JButton();
                        jPanel9.add(jGOMemoryButton);
                        jPanel9.add(getJGoLinearButton());
                        jPanel9.add(getJPreviousMemoryButton());
                        jPanel9.add(getJNextMemoryPageButton());
                        jPanel9.add(getJButton2());
                        jPanel9.add(getJButton5());
                        jGOMemoryButton.setText(MyLanguage.getString("Go"));
                        jGOMemoryButton.setToolTipText(MyLanguage.getString("Physical_address"));
                        jGOMemoryButton.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                jGOMemoryButtonActionPerformed(evt);
                            }
                        });
                    }
                    {
                        jBinaryRadioButton = new JRadioButton();
                        jPanel9.add(jBinaryRadioButton);
                        jBinaryRadioButton.setText("2");
                        jBinaryRadioButton.addItemListener(new ItemListener() {
                            public void itemStateChanged(ItemEvent evt) {
                                jBinaryRadioButtonItemStateChanged(evt);
                            }
                        });
                        jBinaryRadioButton.addChangeListener(new ChangeListener() {
                            public void stateChanged(ChangeEvent evt) {
                                jBinaryRadioButtonStateChanged(evt);
                            }
                        });
                        getButtonGroup1().add(jBinaryRadioButton);
                    }
                    {
                        jOctRadioButton1 = new JRadioButton();
                        jPanel9.add(jOctRadioButton1);
                        jOctRadioButton1.setText("8");
                        jOctRadioButton1.addItemListener(new ItemListener() {
                            public void itemStateChanged(ItemEvent evt) {
                                jOctRadioButton1ItemStateChanged(evt);
                            }
                        });
                        jOctRadioButton1.addChangeListener(new ChangeListener() {
                            public void stateChanged(ChangeEvent evt) {
                                jOctRadioButton1StateChanged(evt);
                            }
                        });
                        getButtonGroup1().add(jOctRadioButton1);
                    }
                    {
                        jDecRadioButton = new JRadioButton();
                        jPanel9.add(jDecRadioButton);
                        jDecRadioButton.setText("10");
                        jDecRadioButton.addItemListener(new ItemListener() {
                            public void itemStateChanged(ItemEvent evt) {
                                jDecRadioButtonItemStateChanged(evt);
                            }
                        });
                        jDecRadioButton.addChangeListener(new ChangeListener() {
                            public void stateChanged(ChangeEvent evt) {
                                jDecRadioButtonStateChanged(evt);
                            }
                        });
                        getButtonGroup1().add(jDecRadioButton);
                    }
                    {
                        jHexRadioButton = new JRadioButton();
                        jPanel9.add(jHexRadioButton);
                        jHexRadioButton.setText("16");
                        jHexRadioButton.setSelected(true);
                        jHexRadioButton.addItemListener(new ItemListener() {
                            public void itemStateChanged(ItemEvent evt) {
                                jHexRadioButtonItemStateChanged(evt);
                            }
                        });
                        jHexRadioButton.addChangeListener(new ChangeListener() {
                            public void stateChanged(ChangeEvent evt) {
                                jHexRadioButtonStateChanged(evt);
                            }
                        });
                        getButtonGroup1().add(jHexRadioButton);
                    }
                }
            }
            {
                jPanel5 = new JPanel();
                jTabbedPane3
                        .addTab(MyLanguage.getString("GDT"),
                                new ImageIcon(getClass().getClassLoader()
                                        .getResource("com/peterbochs/icons/famfam_icons/gdt.png")),
                                jPanel5, null);
                BorderLayout jPanel5Layout = new BorderLayout();
                jPanel5.setLayout(jPanel5Layout);
                {
                    jScrollPane3 = new JScrollPane();
                    jPanel5.add(jScrollPane3, BorderLayout.CENTER);
                    jPanel5.add(getJPanel14(), BorderLayout.NORTH);
                    {
                        GDTTableModel jGDTTableModel = new GDTTableModel();
                        jGDTTable = new JTable();
                        jGDTTable.setModel(jGDTTableModel);
                        jScrollPane3.setViewportView(jGDTTable);
                        jGDTTable.getColumnModel().getColumn(0).setMaxWidth(40);
                        jGDTTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
                        jGDTTable.getTableHeader().setReorderingAllowed(false);
                        jGDTTable.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                jGDTTableMouseClicked(evt);
                            }
                        });

                    }
                }
            }
            {
                jPanel6 = new JPanel();
                BorderLayout jPanel6Layout = new BorderLayout();
                jPanel6.setLayout(jPanel6Layout);
                jTabbedPane3
                        .addTab(MyLanguage.getString("IDT"),
                                new ImageIcon(getClass().getClassLoader()
                                        .getResource("com/peterbochs/icons/famfam_icons/idt.png")),
                                jPanel6, null);
                {
                    jScrollPane10 = new JScrollPane();
                    jPanel6.add(jScrollPane10, BorderLayout.CENTER);
                    jPanel6.add(getJPanel15(), BorderLayout.NORTH);
                    {
                        IDTTableModel jIDTTableModel = new IDTTableModel();
                        jIDTTable = new JTable();
                        jIDTTable.setModel(jIDTTableModel);
                        jScrollPane10.setViewportView(jIDTTable);
                        jIDTTable.getColumnModel().getColumn(0).setMaxWidth(40);
                        jIDTTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
                        jIDTTable.getTableHeader().setReorderingAllowed(false);
                        jIDTTable.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                jIDTTableMouseClicked(evt);
                            }
                        });
                    }
                }
            }
            {
                jPanel7 = new JPanel();
                BorderLayout jPanel7Layout = new BorderLayout();
                jPanel7.setLayout(jPanel7Layout);
                jTabbedPane3
                        .addTab(MyLanguage.getString("LDT"),
                                new ImageIcon(getClass().getClassLoader()
                                        .getResource("com/peterbochs/icons/famfam_icons/ldt.png")),
                                jPanel7, null);
                jTabbedPane3.addTab(MyLanguage.getString("Search_memory"),
                        new ImageIcon(getClass().getClassLoader()
                                .getResource("com/peterbochs/icons/famfam_icons/memory.png")),
                        getJPanel17(), null);
                jTabbedPane3.addTab("bochsout.txt",
                        new ImageIcon(getClass().getClassLoader()
                                .getResource("com/peterbochs/icons/famfam_icons/script.png")),
                        getJPanel31(), null);
                {
                    jScrollPane11 = new JScrollPane();
                    jPanel7.add(jScrollPane11, BorderLayout.CENTER);
                    jPanel7.add(getJPanel16(), BorderLayout.NORTH);
                    {
                        LDTTableModel jLDTTableModel = new LDTTableModel();
                        jLDTTable = new JTable();
                        jLDTTable.setModel(jLDTTableModel);
                        jScrollPane11.setViewportView(jLDTTable);
                        jLDTTable.getColumnModel().getColumn(0).setMaxWidth(40);
                        jLDTTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
                        jLDTTable.getTableHeader().setReorderingAllowed(false);
                        jLDTTable.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                jLDTTableMouseClicked(evt);
                            }
                        });
                    }
                }
            }
        }
    }
    {
        jTabbedPane2 = new JMaximizableTabbedPane();
        // jTabbedPane2.setCloseIcon(true);
        // jTabbedPane2.setMaxIcon(true);
        //
        // jTabbedPane2.addCloseListener(new CloseListener() {
        // public void closeOperation(MouseEvent e) {
        // jTabbedPane2.remove(jTabbedPane2.getOverTabIndex());
        // }
        // });
        //
        // jTabbedPane2.addMaxListener(new MaxListener() {
        // public void maxOperation(MouseEvent e) {
        // jTabbedPane2.detachTab(jTabbedPane2.getOverTabIndex());
        // }
        // });

        jSplitPane2.add(jTabbedPane2, JSplitPane.BOTTOM);
        {
            registerPanelScrollPane = new JScrollPane();
            jTabbedPane2.addTab(MyLanguage.getString("Register"),
                    new ImageIcon(getClass().getClassLoader()
                            .getResource("com/peterbochs/icons/famfam_icons/text_kerning.png")),
                    registerPanelScrollPane, null);
            {
                registerPanel = new RegisterPanel(this);
                registerPanelScrollPane.setViewportView(registerPanel);
            }
        }
        {
            jPanel3 = new JPanel();
            jTabbedPane2.addTab(MyLanguage.getString("History"),
                    new ImageIcon(getClass().getClassLoader()
                            .getResource("com/peterbochs/icons/famfam_icons/book_addresses.png")),
                    jPanel3, null);
            BorderLayout jPanel3Layout = new BorderLayout();
            jPanel3.setLayout(jPanel3Layout);
            {
                jScrollPane6 = new JScrollPane();
                jPanel3.add(jScrollPane6, BorderLayout.CENTER);
                jPanel3.add(getJPanel13(), BorderLayout.NORTH);
                jScrollPane6.setViewportView(getJHistoryTable());
            }
        }
        {
            jPanel11 = new JPanel();
            jTabbedPane2
                    .addTab(MyLanguage.getString("Paging"),
                            new ImageIcon(getClass().getClassLoader()
                                    .getResource("com/peterbochs/icons/famfam_icons/page_copy.png")),
                            jPanel11, null);
            jTabbedPane2.addTab(MyLanguage.getString("Address_translate"),
                    new ImageIcon(getClass().getClassLoader()
                            .getResource("com/peterbochs/icons/famfam_icons/page_go.png")),
                    getJAddressTranslatePanel(), null);
            jTabbedPane2.addTab("Page table graph (experimental)",
                    new ImageIcon(getClass().getClassLoader()
                            .getResource("com/peterbochs/icons/famfam_icons/page_lightning.png")),
                    getJPageTableGraphPanel(), null);
            if (!Global.debug) {
                jTabbedPane2.removeTabAt(jTabbedPane2.getTabCount() - 1);
            }
            jTabbedPane2.addTab(MyLanguage.getString("Table_translate"),
                    new ImageIcon(getClass().getClassLoader()
                            .getResource("com/peterbochs/icons/famfam_icons/page_refresh.png")),
                    getJTableTranslateScrollPane(), null);
            jTabbedPane2.addTab(MyLanguage.getString("ELF_dump"),
                    new ImageIcon(getClass().getClassLoader()
                            .getResource("com/peterbochs/icons/famfam_icons/linux.png")),
                    getJELFDumpScrollPane(), null);
            jTabbedPane2.addTab("OS debug informations",
                    new ImageIcon(getClass().getClassLoader()
                            .getResource("com/peterbochs/icons/famfam_icons/bug.png")),
                    getJOSDebugStandardPanel(), null);
            BorderLayout jPanel11Layout = new BorderLayout();
            jPanel11.setLayout(jPanel11Layout);
            jPanel11.add(getJSplitPane3(), BorderLayout.CENTER);
            jPanel11.add(getJPanel19(), BorderLayout.NORTH);
        }
    }
    return jSplitPane2;
}

From source file:base.BasePlayer.Main.java

static void setChromDrop(String dir) {
    try {//w ww  .java 2  s . co  m

        if (!new File(genomeDir.getCanonicalPath() + "/" + dir).exists() || dir.length() == 0) {

            /*String[] empty = {""};         
            chromModel = new DefaultComboBoxModel<String>(empty);
            chromosomeDropdown = new SteppedComboBox(chromModel);
            */
            if (chromModel != null) {
                chromModel.removeAllElements();
                chromosomeDropdown.removeAllItems();
                chromosomeDropdown.revalidate();
                chromosomeDropdown.repaint();
                Main.searchTable.clear();
                if (Main.drawCanvas.splits.size() > 0) {
                    Main.drawCanvas.splits.get(0).clearGenes();
                }
                Main.chromDraw.updateExons = true;
                Main.chromDraw.repaint();
            } else {
                String[] empty = { "" };
                chromModel = new DefaultComboBoxModel<String>(empty);
                chromosomeDropdown = new SteppedComboBox(chromModel);
                chromosomeDropdown.revalidate();
                chromosomeDropdown.repaint();
            }
        } else {

            File chromindex = null;
            selectedGenome = dir;
            File defdir = new File(genomeDir.getCanonicalPath() + "/" + dir);

            File[] files = defdir.listFiles();
            if (files == null) {
                return;
            }
            String chromtemp = "";
            chromnamevector = Collections.synchronizedList(new ArrayList<String>());
            //      boolean faifound = false;
            for (int i = 0; i < files.length; i++) {
                if (files[i].isDirectory()) {
                    continue;
                }
                if (files[i].getName().contains(".gz")) {
                    continue;
                } else if (files[i].getName().contains(".fai")) {
                    chromindex = new File(defdir.getCanonicalPath() + "/" + files[i].getName());
                    //         faifound = true;
                } else if (files[i].getName().contains(".fa")) {
                    chromtemp = defdir.getCanonicalPath() + "/" + files[i].getName();
                }
            }
            if (chromtemp.equals("")) {
                String[] empty = { "" };

                chromModel = new DefaultComboBoxModel<String>(empty);
                chromosomeDropdown = new SteppedComboBox(chromModel);
                chromosomeDropdown.revalidate();
                chromosomeDropdown.repaint();
                return;
            }

            if (referenceFile != null) {
                referenceFile.close();
            }
            referenceFile = new RandomAccessFile(chromtemp, "r");

            ref = new File(chromtemp);

            BufferedReader reader = new BufferedReader(new FileReader(chromindex));
            String line;
            String[] split;
            ChromDraw.chromPos = new HashMap<String, Integer>();
            chromIndex = new Hashtable<String, Long[]>();
            textlength = 0;
            while ((line = reader.readLine()) != null) {

                split = line.split("\t");
                chromnamevector.add(split[0]);
                Long[] add = { Long.parseLong(split[2]), Long.parseLong(split[1]), Long.parseLong(split[3]) };
                if (split[0].equals("MT")) {
                    ChromDraw.chromPos.put("M", Integer.parseInt(split[1]));
                    chromIndex.put("M", add);
                }
                chromIndex.put(split[0], add);
                if (split[0].length() > textlength) {
                    textlength = split[0].length();
                }
                ChromDraw.chromPos.put(split[0], Integer.parseInt(split[1]));

            }
            reader.close();
            MethodLibrary.ChromSorter sorter = new MethodLibrary.ChromSorter();
            Collections.sort(chromnamevector, sorter);
            chromnames = new String[chromnamevector.size()];

            if (chromnamevector.get(0).contains("chr")) {

                refchrom = "chr";
            } else {
                refchrom = "";
            }
            for (int i = 0; i < chromnames.length; i++) {
                chromnames[i] = chromnamevector.get(i).replace(refchrom, "");

            }

            chromModel = new DefaultComboBoxModel<String>(chromnames);
            if (chromosomeDropdown == null) {
                chromosomeDropdown = new SteppedComboBox(chromModel);

            } else {

                chromosomeDropdown.setModel(chromModel);
            }
            clicked = false;

            refDropdown.setSelectedItem(dir);
            clicked = true;
            clickedAnno = false;
            setAnnotationDrop(dir);

            if (defaultAnnotation.length() == 0) {
                geneDropdown.setSelectedIndex(0);
            } else {
                geneDropdown.setSelectedItem(defaultAnnotation);
            }
            clickedAnno = true;

            int letterlength = chromosomeDropdown.getFontMetrics(chromosomeDropdown.getFont()).stringWidth("E");
            chromosomeDropdown.setPopupWidth(textlength * letterlength + 25);
            chromosomeDropdown.revalidate();
            chromosomeDropdown.repaint();
            refDropdown.setToolTipText(refDropdown.getSelectedItem().toString());
            geneDropdown.setToolTipText(geneDropdown.getSelectedItem().toString());
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:atlas.kingj.roi.FrmMain.java

private void UpdateSetReel() {
    if (jobFormReady && (SetReelType != cmbJobDomain.getSelectedIndex())) {
        Double newval = 0., val = 0.;
        int slits = 0;
        try {/*from w  w w  . j  a  v  a  2  s  .co m*/
            val = (metric ? ((Job) listJobs.getSelectedValue()).getRewindWeight()
                    : Core.KgToLbs(((Job) listJobs.getSelectedValue()).getRewindWeight()));//Double.parseDouble(txtRewindAmount.getText());
            slits = Integer.parseInt(txtSlits.getText());
        } catch (NumberFormatException ee) {
            val = 0.;
            slits = 0;
        }

        int index = cmbRewindType.getSelectedIndex();
        jobFormReady = false;

        if (cmbJobDomain.getSelectedIndex() == 0) {
            newval = (slits == 0 ? 0 : val / slits);
            SetReelType = 0;

            if (metric)
                cmbRewindType.setModel(new DefaultComboBoxModel(
                        new String[] { "Length (m)", "Weight (kg)", "Diameter (mm)" }));
            else
                cmbRewindType.setModel(new DefaultComboBoxModel(
                        new String[] { "Length (ft)", "Weight (lbs)", "Diameter (in)" }));

            cmbRewindType.setSelectedIndex(1);
        } else if (cmbJobDomain.getSelectedIndex() == 1) {
            newval = val;// * slits;
            SetReelType = 1;

            if (index == 2)
                index = 0;
            if (metric)
                cmbRewindType
                        .setModel(new DefaultComboBoxModel(new String[] { /*"Length (m)", */"Weight (kg)" }));
            else
                cmbRewindType
                        .setModel(new DefaultComboBoxModel(new String[] { /*"Length (ft)",*/ "Weight (lbs)" }));

            cmbRewindType.setSelectedIndex(0);
        }

        txtRewindAmount.setText(Double.toString(roundTwoDecimals(newval)));
        jobFormReady = true;

    }
}

From source file:com.cch.aj.entryrecorder.frame.SettingsJFrame.java

private void UpdateProductUI(Product currentProduct) {
    txtProductCode.setText(currentProduct.getCode() == null || currentProduct.getCode() == "- Select -" ? ""
            : currentProduct.getCode().toString());
    ;/*from   w w  w .ja  va 2  s  . c o m*/
    txtProductDesc
            .setText(currentProduct.getDescription() == null ? "" : currentProduct.getDescription().toString());
    ;
    txtProductPerc1.setText(currentProduct.getAdditiveAPercentage() == null ? ""
            : currentProduct.getAdditiveAPercentage().toString());
    ;
    txtProductPerc2.setText(currentProduct.getAdditiveBPercentage() == null ? ""
            : currentProduct.getAdditiveBPercentage().toString());
    ;
    txtProductPerc3.setText(currentProduct.getAdditiveCPercentage() == null ? ""
            : currentProduct.getAdditiveCPercentage().toString());
    txtProductWeightMax
            .setText(currentProduct.getWeightMax() == null ? "" : currentProduct.getWeightMax().toString());
    txtProductWeightMin
            .setText(currentProduct.getWeightMin() == null ? "" : currentProduct.getWeightMin().toString());
    //combobox
    this.FillMouldComboBox(this.cbProductMould,
            currentProduct.getMouldId() != null ? currentProduct.getMouldId().getId() : 0);
    this.FillPolymerComboBox(this.cbProductPolymer,
            currentProduct.getPolymerId() != null ? currentProduct.getPolymerId().getId() : 0);
    this.FillAdditiveComboBox(this.cbProductAdditive1,
            currentProduct.getAdditiveAId() != null ? currentProduct.getAdditiveAId().getId() : 0);
    this.FillAdditiveComboBox(this.cbProductAdditive2,
            currentProduct.getAdditiveBId() != null ? currentProduct.getAdditiveBId().getId() : 0);
    this.FillAdditiveComboBox(this.cbProductAdditive3,
            currentProduct.getAdditiveCId() != null ? currentProduct.getAdditiveCId().getId() : 0);

    FillEmbossingComboBox(this.cbProductInsert,
            currentProduct.getInsertId() != null ? currentProduct.getInsertId().getId() : 0, "INSERT");
    FillEmbossingComboBox(this.cbProductEmbossing,
            currentProduct.getEmbossingId() != null ? currentProduct.getEmbossingId().getId() : 0, "EMBOSSING");
    List<String> threadBoresA = new ArrayList<String>();
    threadBoresA.add("- Select -");
    if (settingMould.getThreadBoreASize1() != null && !settingMould.getThreadBoreASize1().equals("")) {
        threadBoresA.add(settingMould.getThreadBoreASize1());
    }
    if (settingMould.getThreadBoreASize2() != null && !settingMould.getThreadBoreASize2().equals("")) {
        threadBoresA.add(settingMould.getThreadBoreASize2());
    }
    if (settingMould.getThreadBoreASize3() != null && !settingMould.getThreadBoreASize3().equals("")) {
        threadBoresA.add(settingMould.getThreadBoreASize3());
    }
    this.cbProductBoreA.setModel(new DefaultComboBoxModel(threadBoresA.toArray()));
    this.cbProductBoreA1.setModel(new DefaultComboBoxModel(threadBoresA.toArray()));
    List<String> threadBoresB = new ArrayList<String>();
    threadBoresB.add("- Select -");
    if (settingMould.getThreadBoreBSize1() != null && !settingMould.getThreadBoreBSize1().equals("")) {
        threadBoresB.add(settingMould.getThreadBoreBSize1());
    }
    if (settingMould.getThreadBoreBSize2() != null && !settingMould.getThreadBoreBSize2().equals("")) {
        threadBoresB.add(settingMould.getThreadBoreBSize2());
    }
    if (settingMould.getThreadBoreBSize3() != null && !settingMould.getThreadBoreBSize3().equals("")) {
        threadBoresB.add(settingMould.getThreadBoreBSize3());
    }
    this.cbProductBoreB.setModel(new DefaultComboBoxModel(threadBoresB.toArray()));
    this.cbProductBoreB1.setModel(new DefaultComboBoxModel(threadBoresB.toArray()));
    List<String> threadNecks = new ArrayList<String>();
    threadNecks.add("- Select -");
    if (settingMould.getThreadNeckSize1() != null && !settingMould.getThreadNeckSize1().equals("")) {
        threadNecks.add(settingMould.getThreadNeckSize1());
    }
    if (settingMould.getThreadNeckSize2() != null && !settingMould.getThreadNeckSize2().equals("")) {
        threadNecks.add(settingMould.getThreadNeckSize2());
    }
    if (settingMould.getThreadNeckSize3() != null && !settingMould.getThreadNeckSize3().equals("")) {
        threadNecks.add(settingMould.getThreadNeckSize3());
    }
    this.cbProductNeck.setModel(new DefaultComboBoxModel(threadNecks.toArray()));
    this.cbProductNeck1.setModel(new DefaultComboBoxModel(threadNecks.toArray()));
    if (currentProduct.getBung() != null && !currentProduct.getBung().equals("")) {
        this.cbProductBung.setSelectedItem(currentProduct.getBung().toString());
    }
    if (currentProduct.getPierced() != null && !currentProduct.getPierced().equals("")) {
        this.cbProductPierced.setSelectedItem(currentProduct.getPierced().toString());
    }
    if (currentProduct.getViewLine() != null && !currentProduct.getViewLine().equals("")) {
        this.cbProductViewLine.setSelectedItem(currentProduct.getViewLine().toString());
    }
    if (currentProduct.getDgnondg() != null) {
        this.cbProductDg.setSelectedIndex(currentProduct.getDgnondg());
    }
    if (currentProduct.getThreadBoreA() != null) {
        this.cbProductBoreA.setSelectedIndex(currentProduct.getThreadBoreA());
    }
    if (currentProduct.getThreadBoreB() != null) {
        this.cbProductBoreB.setSelectedIndex(currentProduct.getThreadBoreB());
    }
    if (currentProduct.getThreadNeck() != null) {
        this.cbProductNeck.setSelectedIndex(currentProduct.getThreadNeck());
    }
    if (currentProduct.getThreadBoreA1() != null) {
        this.cbProductBoreA1.setSelectedIndex(currentProduct.getThreadBoreA1());
    }
    if (currentProduct.getThreadBoreB1() != null) {
        this.cbProductBoreB1.setSelectedIndex(currentProduct.getThreadBoreB1());
    }
    if (currentProduct.getThreadNeck1() != null) {
        this.cbProductNeck1.setSelectedIndex(currentProduct.getThreadNeck1());
    }
    if (currentProduct.getClosureType() != null) {
        this.cbProductClosureType.setSelectedItem(currentProduct.getClosureType());
    }
    //
    DefaultTableModel model = (DefaultTableModel) this.tblCheck.getModel();
    model.setRowCount(0);
    model.fireTableDataChanged();
    List<Checkitem> checks = this.checkitemService.GetAllEntities();
    List<Checkitem> list = new ArrayList<Checkitem>();
    for (Checkitem ci : checks) {
        if (ci.getProductCollection().contains(this.settingProduct)) {
            list.add(ci);
        }
    }
    if (list != null) {
        for (Checkitem item : list) {
            model.addRow(new Object[] { item.getId(), item.getDescription() });
        }
    }
    this.txtCheckDesc.setText("");
    //
    if (this.settingProduct.getWeightMin() == null && this.settingProduct.getWeightMax() == null) {
        this.txtProductWeightMin.setText(
                this.settingMould.getWeightDgMin() != null ? this.settingMould.getWeightDgMin().toString()
                        : "");
        this.txtProductWeightMax.setText(
                this.settingMould.getWeightDgMax() != null ? this.settingMould.getWeightDgMax().toString()
                        : "");
    } else {
        this.txtProductWeightMin.setText(
                this.settingProduct.getWeightMin() != null ? this.settingProduct.getWeightMin().toString()
                        : "");
        this.txtProductWeightMax.setText(
                this.settingProduct.getWeightMax() != null ? this.settingProduct.getWeightMax().toString()
                        : "");
    }

    if (currentProduct.getProductImage() != null) {
        this.labDrawingImage1.setText(currentProduct.getProductImage().toString());
        AppHelper.DisplayImage(currentProduct.getProductImage().toString(), this.pnlDrawingImage1);
    } else {
        this.labDrawingImage1.setText("Image File Path");
        this.pnlDrawingImage1.removeAll();
    }

    if (currentProduct.getClosureType() != null && currentProduct.getClosureType().equals("TWIN")) {
        this.cbProductBoreA1.setVisible(true);
        this.cbProductBoreB1.setVisible(true);
        this.cbProductNeck1.setVisible(true);
    } else {
        this.cbProductBoreA1.setVisible(false);
        this.cbProductBoreB1.setVisible(false);
        this.cbProductNeck1.setVisible(false);
    }

}

From source file:atlas.kingj.roi.FrmMain.java

private void EnableROI() {

    lblSellingPrice.setEnabled(true);/*from   w  w w .j  a  v a2 s . co m*/
    lblPerTonne.setEnabled(true);
    lblpound1.setEnabled(true);
    lblvalueadded.setEnabled(true);
    txtcontribution.setEnabled(true);
    txtsellingprice.setEnabled(true);
    lblValueAddedlbl.setEnabled(true);
    lblpercent.setEnabled(true);
    lblContribution.setEnabled(true);

    lblMachine_1.setEnabled(true);
    cmbMachineEnergy.setEnabled(true);
    lblPleaseSetPower.setEnabled(true);
    lblEnergyCostl.setEnabled(true);
    lblpound2.setEnabled(true);
    lblPerKwh.setEnabled(true);
    txtenergycost.setEnabled(true);

    rdbtnAveragePower.setEnabled(true);
    rdbtnHourlyUsage.setEnabled(true);
    rdbtnAnnualUsage.setEnabled(true);

    txtmaintenancehours.setEnabled(true);
    txtmaintenanceparts.setEnabled(true);
    txtmaintenanceperhour.setEnabled(true);
    cmbMachinesmaintenance.setEnabled(true);
    lblpound10.setEnabled(true);
    lblpound11.setEnabled(true);
    lbltotalmaintcost.setEnabled(true);
    lblProdLoss.setEnabled(true);
    lblMaintenanceHoursPer.setEnabled(true);
    lblRepairCostsPer.setEnabled(true);
    lblPartsCostsPer.setEnabled(true);

    lblWasteSavedPer_1.setEnabled(true);
    lblWasteSavedPer_2.setEnabled(true);
    lblM_1.setEnabled(true);
    lblM_2.setEnabled(true);
    txtwastesavedflags.setEnabled(true);
    txtwastesavedguide.setEnabled(true);

    // update machine selection combobox
    int[] indices = listCompareRoi.getSelectedIndices();
    String[] machineNames = new String[indices.length];
    for (int i = 0; i < indices.length; ++i) {
        machineNames[i] = ((Machine) listCompareRoi.getModel().getElementAt(indices[i])).model.toString() + ": "
                + ((Machine) listCompareRoi.getModel().getElementAt(indices[i])).name;
    }

    //cmbMachineEnergy.setModel(new DefaultComboBoxModel(machineNames));
    // update machine selection combobox
    String[] allMachineNames = new String[listModel.getSize()];
    for (int i = 0; i < listModel.getSize(); ++i) {
        allMachineNames[i] = ((Machine) listModel.getElementAt(i)).model.toString() + ": "
                + ((Machine) listModel.getElementAt(i)).name;
    }
    cmbMachineEnergy.setModel(new DefaultComboBoxModel(allMachineNames));
    cmbMachinesmaintenance.setModel(new DefaultComboBoxModel(allMachineNames));
    //cmbMachinesmaintenance.setSelectedIndex(0);

    /*if(rdbtnHourlyUsage.isSelected()){
      txthourlyusage.setEnabled(true);
      lblKwh.setEnabled(true);
      rdbtnHourlyUsage.doClick();
    }else if(rdbtnAnnualUsage.isSelected()){
      txtannualusage.setEnabled(true);
      lblKwh_1.setEnabled(true);
      rdbtnAnnualUsage.doClick();
    }else{//if(rdbtnAveragePower.isSelected()){*/
    txtaveragepower.setEnabled(true);
    lblKw.setEnabled(true);
    /*rdbtnAveragePower.doClick();
    }*/
    //UpdateEnergyView();
}