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:au.org.ala.delta.intkey.ui.WebSearchDialog.java

private void loadSearchEngines(File file, JComboBox cmb) {

    List<SearchEngineDescriptor> engines = new ArrayList<WebSearchDialog.SearchEngineDescriptor>();
    try {/* ww w . j  a  va  2 s .c o m*/
        List<String> lines = FileUtils.readLines(file);
        for (String line : lines) {
            SearchEngineDescriptor desc = parseSearchEngineDescriptor(line);
            if (desc != null) {
                engines.add(desc);
            } else {
                Logger.log("Could not parse search engine descriptor: " + line);
            }
        }

        ComboBoxModel model = new DefaultComboBoxModel(engines.toArray());
        cmb.setModel(model);
        if (model.getSize() > 0) {
            model.setSelectedItem(model.getElementAt(0));
        }

    } catch (IOException ioex) {
        throw new RuntimeException(ioex);
    }
}

From source file:sim.util.media.chart.TimeSeriesAttributes.java

public void buildAttributes() {
    // The following three variables aren't defined until AFTER construction if
    // you just define them above.  So we define them below here instead.

    dashPattern = 0; // dashPatterns[0];
    stretch = 1.0f;/*from   w ww. j a  v a  2s.  c  o  m*/
    thickness = 2.0f;

    // strokeColor = Color.black;  // rebuildGraphicsDefinitions will get called by our caller afterwards
    XYItemRenderer renderer = (((XYPlot) getPlot()).getRenderer());

    // NOTE:
    // Paint paint = renderer.getSeriesPaint(getSeriesIndex());        
    // In JFreeChart 1.0.6 getSeriesPaint returns null!!!
    // You need lookupSeriesPaint(), but that's not backward compatible.
    // The only thing consistent in all versions is getItemPaint 
    // (which looks like a gross miss-use, but gets the job done)

    Paint paint = renderer.getItemPaint(getSeriesIndex(), -1);

    strokeColor = (Color) paint;

    strokeColorWell = new ColorWell(strokeColor) {
        public Color changeColor(Color c) {
            strokeColor = c;
            rebuildGraphicsDefinitions();
            return c;
        }
    };
    addLabelled("Color", strokeColorWell);

    thicknessField = new NumberTextField(2.0, true) {
        public double newValue(double newValue) {
            if (newValue < 0.0)
                newValue = currentValue;
            thickness = (float) newValue;
            rebuildGraphicsDefinitions();
            return newValue;
        }
    };
    addLabelled("Width", thicknessField);

    dashPatternList = new JComboBox();
    dashPatternList.setEditable(false);
    dashPatternList.setModel(new DefaultComboBoxModel(
            new java.util.Vector(Arrays.asList(new String[] { "Solid", "__  __  __", "_  _  _  _", "_ _ _ _ _",
                    "_ _ . _ _ .", "_ . _ . _ .", "_ . . _ . .", ". . . . . . .", ".  .  .  .  ." }))));
    dashPatternList.setSelectedIndex(0);
    dashPatternList.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            dashPattern = dashPatternList.getSelectedIndex(); // dashPatterns[dashPatternList.getSelectedIndex()];
            rebuildGraphicsDefinitions();
        }
    });
    addLabelled("Dash", dashPatternList);
    stretchField = new NumberTextField(1.0, true) {
        public double newValue(double newValue) {
            if (newValue < 0.0)
                newValue = currentValue;
            stretch = (float) newValue;
            rebuildGraphicsDefinitions();
            return newValue;
        }
    };
    addLabelled("Stretch", stretchField);
}

From source file:gtu._work.ui.TextScanUI.java

private void initGUI() {
    try {/*from www. ja v  a2 s.  c o  m*/
        BorderLayout thisLayout = new BorderLayout();
        getContentPane().setLayout(thisLayout);
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        this.addComponentListener(new ComponentAdapter() {
            public void componentResized(ComponentEvent evt) {
                thisComponentResized(evt);
            }
        });
        this.addWindowStateListener(new WindowStateListener() {
            public void windowStateChanged(WindowEvent evt) {
                System.out.println("this.windowStateChanged, event=" + evt);
                // TODO add your code for this.windowStateChanged
            }
        });
        this.addWindowListener(new WindowAdapter() {
            public void windowIconified(WindowEvent evt) {
                System.out.println("this.windowIconified, event=" + evt);
                // TODO add your code for this.windowIconified
            }
        });
        this.setTitle(TITLE);
        {
            jPanel1 = new JPanel();
            getContentPane().add(jPanel1, BorderLayout.NORTH);
            GroupLayout jPanel1Layout = new GroupLayout((JComponent) jPanel1);
            jPanel1.setLayout(jPanel1Layout);
            jPanel1.setPreferredSize(new java.awt.Dimension(521, 89));
            jPanel1.setBounds(0, 0, 521, 89);
            {
                jButton1 = new JButton();
                jButton1.setText("File");
                jButton1.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        jButton1ActionPerformed(evt);
                    }
                });
            }
            {
                jButton2 = new JButton();
                jButton2.setText("Clipboard");
                jButton2.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        jButton2ActionPerformed(evt);
                    }
                });
            }
            {
                contentFilter = new JTextField();
                contentFilter.getDocument().addDocumentListener(new DocumentListener() {
                    public void insertUpdate(DocumentEvent paramDocumentEvent) {
                        jTextField2filterAgain();
                    }

                    public void removeUpdate(DocumentEvent paramDocumentEvent) {
                        jTextField2filterAgain();
                    }

                    public void changedUpdate(DocumentEvent paramDocumentEvent) {
                        jTextField2filterAgain();
                    }
                });
            }
            {
                fileFilter = new JTextField();
                fileFilter.getDocument().addDocumentListener(new DocumentListener() {
                    public void insertUpdate(DocumentEvent paramDocumentEvent) {
                        jTextField1DocumentListener(paramDocumentEvent);
                    }

                    public void removeUpdate(DocumentEvent paramDocumentEvent) {
                        jTextField1DocumentListener(paramDocumentEvent);
                    }

                    public void changedUpdate(DocumentEvent paramDocumentEvent) {
                        jTextField1DocumentListener(paramDocumentEvent);
                    }
                });
            }
            {
                totalLabel = new JLabel();
            }
            {
                matchLabel = new JLabel();
            }
            {
                jLabel4 = new JLabel();
                jLabel4.setText("Match : ");
            }
            {
                jLabel2 = new JLabel();
                jLabel2.setText("Total : ");
            }
            {
                ComboBoxModel jComboBox1Model = new DefaultComboBoxModel(new String[] { "All", "Match" });
                contextFilter = new JComboBox();
                contextFilter.setModel(jComboBox1Model);
                contextFilter.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        jTextField2filterAgain();
                    }
                });
            }
            {
                ComboBoxModel jComboBox1Model = new DefaultComboBoxModel(new String[] { "Regex", "find" });
                fileChk = new JComboBox();
                fileChk.setModel(jComboBox1Model);
                fileChk.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        fileChkActionPerformed(evt);
                    }
                });
            }
            {
                jScrollPane2 = new JScrollPane();
                {
                    ListModel groupListModel = new DefaultComboBoxModel();
                    groupList = new JList();
                    jScrollPane2.setViewportView(groupList);
                    groupList.setModel(groupListModel);
                    groupList.addKeyListener(new KeyAdapter() {
                        public void keyPressed(KeyEvent evt) {
                            groupListKeyPressed(evt);
                        }
                    });
                }
            }
            jPanel1Layout.setVerticalGroup(jPanel1Layout.createSequentialGroup().addContainerGap(16, 16)
                    .addGroup(jPanel1Layout.createParallelGroup()
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                            .addComponent(jButton1, GroupLayout.Alignment.BASELINE,
                                                    GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                                    GroupLayout.PREFERRED_SIZE)
                                            .addComponent(fileFilter, GroupLayout.Alignment.BASELINE,
                                                    GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                                    GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jLabel2, GroupLayout.Alignment.BASELINE,
                                                    GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE)
                                            .addComponent(fileChk, GroupLayout.Alignment.BASELINE,
                                                    GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                                    GroupLayout.PREFERRED_SIZE))
                                    .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addGroup(jPanel1Layout.createParallelGroup().addGroup(jPanel1Layout
                                            .createParallelGroup(GroupLayout.Alignment.BASELINE)
                                            .addComponent(jButton2, GroupLayout.Alignment.BASELINE,
                                                    GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                                    GroupLayout.PREFERRED_SIZE)
                                            .addComponent(contentFilter, GroupLayout.Alignment.BASELINE,
                                                    GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                                    GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jLabel4, GroupLayout.Alignment.BASELINE,
                                                    GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE)
                                            .addComponent(contextFilter, GroupLayout.Alignment.BASELINE,
                                                    GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                                    GroupLayout.PREFERRED_SIZE))
                                            .addComponent(matchLabel, GroupLayout.Alignment.LEADING,
                                                    GroupLayout.PREFERRED_SIZE, 24,
                                                    GroupLayout.PREFERRED_SIZE)))
                            .addGroup(jPanel1Layout.createParallelGroup()
                                    .addComponent(totalLabel, GroupLayout.Alignment.LEADING,
                                            GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jScrollPane2, GroupLayout.Alignment.LEADING,
                                            GroupLayout.PREFERRED_SIZE, 61, GroupLayout.PREFERRED_SIZE)))
                    .addContainerGap(12, 12));
            jPanel1Layout.setHorizontalGroup(jPanel1Layout.createSequentialGroup().addContainerGap(12, 12)
                    .addGroup(jPanel1Layout.createParallelGroup()
                            .addComponent(contextFilter, GroupLayout.Alignment.LEADING,
                                    GroupLayout.PREFERRED_SIZE, 87, GroupLayout.PREFERRED_SIZE)
                            .addComponent(fileChk, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE,
                                    87, GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel1Layout.createParallelGroup()
                            .addComponent(jLabel4, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel2, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE,
                                    45, GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel1Layout.createParallelGroup()
                            .addComponent(matchLabel, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE,
                                    67, GroupLayout.PREFERRED_SIZE)
                            .addComponent(totalLabel, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE,
                                    67, GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel1Layout.createParallelGroup()
                            .addComponent(contentFilter, GroupLayout.Alignment.LEADING,
                                    GroupLayout.PREFERRED_SIZE, 266, GroupLayout.PREFERRED_SIZE)
                            .addComponent(fileFilter, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE,
                                    266, GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(jPanel1Layout.createParallelGroup()
                            .addComponent(jButton1, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE,
                                    91, GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButton2, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE,
                                    91, GroupLayout.PREFERRED_SIZE))
                    .addGap(19)
                    .addComponent(jScrollPane2, GroupLayout.PREFERRED_SIZE, 36, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(16, 16));
        }
        {
            jScrollPane1 = new JScrollPane();
            getContentPane().add(jScrollPane1, BorderLayout.CENTER);
            jScrollPane1.setPreferredSize(new java.awt.Dimension(581, 235));
            {
                ListModel jList1Model = new DefaultComboBoxModel();
                matchList = new JList();
                jScrollPane1.setViewportView(matchList);

                // matchList.setPreferredSize(new java.awt.Dimension(575,
                // 232));// ???
                // ??
                // XXX
                // TODO
                // IMPORT
                // !!!!

                matchList.addMouseListener(new MouseAdapter() {
                    public void mouseClicked(MouseEvent evt) {
                        jList1MouseClicked(evt);
                    }
                });
                matchList.setModel(jList1Model);
            }
        }
        this.setSize(697, 440);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.ga.forms.DailyLogUI.java

private void initComponentsValues() {
    monthList = new ArrayList();
    yearList = new ArrayList();
    monthList = getMonthList();//w  ww  .j a  v  a  2 s .c o m
    yearList = getYearList();
    dateToday = new Date();
    dateFormatter = new SimpleDateFormat("MMM");
    currMonth = dateFormatter.format(dateToday);
    dateFormatter = new SimpleDateFormat("yyyy");
    currYear = dateFormatter.format(dateToday);
    monthCombo.setModel(new DefaultComboBoxModel(monthList.toArray()));
    monthCombo.setSelectedIndex(monthList.indexOf(currMonth));
    yearCombo.setModel(new DefaultComboBoxModel(yearList.toArray()));
    yearCombo.setSelectedIndex(yearList.indexOf(currYear));
    args = new HashMap();
    HashMap regex = new HashMap();
    regex.put("$regex", monthCombo.getSelectedItem().toString() + "-" + yearCombo.getSelectedItem().toString());
    args.put("date", regex);
    DailyLogRecord record = new DailyLogRecord();
    ArrayList logs = record.retrieveRecord(args);
    ArrayList duration = updateDailyLogTable(logs, this.currMonth, this.currYear);
    updateAnalysis(duration);
}

From source file:com.mirth.connect.client.ui.panels.connectors.ResponseSettingsPanel.java

public void updateResponseDropDown(ResponseConnectorProperties properties, boolean channelLoad) {
    boolean enabled = parent.isSaveEnabled();
    Channel channel = parent.channelEditPanel.currentChannel;

    Object selectedItem;//from  w ww. j av a 2 s. co m
    if (channelLoad) {
        /*
         * The response variable is the response map key. To ensure that the
         * destination name still shows up in the combo box, we use an Entry
         * object for the selected item, rather than a single String.
         */
        selectedItem = properties.getResponseVariable();
        for (Connector connector : channel.getDestinationConnectors()) {
            if (selectedItem.equals("d" + String.valueOf(connector.getMetaDataId()))) {
                selectedItem = new SimpleEntry<String, String>("d" + String.valueOf(connector.getMetaDataId()),
                        connector.getName()) {
                    @Override
                    public String toString() {
                        return getValue();
                    }
                };
                break;
            }
        }
    } else {
        selectedItem = responseComboBox.getSelectedItem();
    }

    Set<Object> variables = new LinkedHashSet<Object>();

    variables.addAll(Arrays.asList(properties.getDefaultQueueOffResponses()));

    List<Step> stepsToCheck = new ArrayList<Step>();
    stepsToCheck.addAll(channel.getSourceConnector().getTransformer().getSteps());

    List<String> scripts = new ArrayList<String>();

    for (Connector connector : channel.getDestinationConnectors()) {
        ConnectorSettingsPanel tempConnector = LoadedExtensions.getInstance().getDestinationConnectors()
                .get(connector.getTransportName());
        scripts.addAll(tempConnector.getScripts(connector.getProperties()));

        /*
         * We add an Entry object instead of just the connector name, so
         * that the back-end response variable is the "d#" key, while the
         * front-end combo box display is the full connector name.
         */
        variables.add(new SimpleEntry<String, String>("d" + String.valueOf(connector.getMetaDataId()),
                connector.getName()) {
            @Override
            public String toString() {
                return getValue();
            }
        });
        stepsToCheck.addAll(connector.getTransformer().getSteps());
        stepsToCheck.addAll(connector.getResponseTransformer().getSteps());
    }

    Pattern pattern = Pattern.compile(RESULT_PATTERN);

    for (Iterator it = stepsToCheck.iterator(); it.hasNext();) {
        Step step = (Step) it.next();
        Map data;
        data = (Map) step.getData();

        if (step.getType().equalsIgnoreCase(TransformerPane.JAVASCRIPT_TYPE)) {
            Matcher matcher = pattern.matcher(step.getScript());
            while (matcher.find()) {
                variables.add(getMapKey(matcher));
            }
        } else if (step.getType().equalsIgnoreCase(TransformerPane.MAPPER_TYPE)) {
            if (data.containsKey(UIConstants.IS_GLOBAL)) {
                if (((String) data.get(UIConstants.IS_GLOBAL))
                        .equalsIgnoreCase(UIConstants.IS_GLOBAL_RESPONSE)) {
                    variables.add((String) data.get("Variable"));
                }
            }
        }
    }

    scripts.add(channel.getPreprocessingScript());
    scripts.add(channel.getPostprocessingScript());

    for (String script : scripts) {
        if (script != null && script.length() > 0) {
            Matcher matcher = pattern.matcher(script);
            while (matcher.find()) {
                variables.add(getMapKey(matcher));
            }
        }
    }

    queueOnRespondFromNames = new ArrayList<String>(Arrays.asList(properties.getDefaultQueueOnResponses()));
    queueOffRespondFromNames = new ArrayList<Object>(variables);
    responseComboBox.setModel(new DefaultComboBoxModel(variables.toArray()));

    setSelectedItem(selectedItem);

    sourceQueueComboBoxActionPerformed(null);
    parent.setSaveEnabled(enabled);
}

From source file:com.petersoft.advancedswing.enhancedtextarea.EnhancedTextArea.java

private void initGUI() {
    try {//from   w  w w  .  j  a  v a  2 s. c  o m
        BorderLayout thisLayout = new BorderLayout();
        this.setLayout(thisLayout);
        this.setPreferredSize(new java.awt.Dimension(725, 290));
        {
            jToolBar = new JToolBar();
            this.add(jToolBar, BorderLayout.NORTH);
            {
                jSaveButton = new JButton();
                jToolBar.add(jSaveButton);
                jSaveButton.setText("Save");
                jSaveButton.setIcon(new ImageIcon(getClass().getClassLoader()
                        .getResource("com/petersoft/advancedswing/enhancedtextarea/disk.png")));
                jSaveButton.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        jSaveButtonActionPerformed(evt);
                    }
                });
            }
            {
                jLineWrapButton = new JToggleButton();
                jToolBar.add(jLineWrapButton);
                jLineWrapButton.setText("Wrap");
                jLineWrapButton.setIcon(new ImageIcon(getClass().getClassLoader()
                        .getResource("com/petersoft/advancedswing/enhancedtextarea/linewrap.png")));
                jLineWrapButton.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        jLineWrapButtonActionPerformed(evt);
                    }
                });
            }
            {
                jFontBiggerButton = new JButton();
                jToolBar.add(jFontBiggerButton);
                jFontBiggerButton.setIcon(new ImageIcon(getClass().getClassLoader()
                        .getResource("com/petersoft/advancedswing/enhancedtextarea/font_add.png")));
                jFontBiggerButton.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        jFontBiggerButtonActionPerformed(evt);
                    }
                });
            }
            {
                jFontSmallerButton = new JButton();
                jToolBar.add(jFontSmallerButton);
                jFontSmallerButton.setIcon(new ImageIcon(getClass().getClassLoader()
                        .getResource("com/petersoft/advancedswing/enhancedtextarea/font_delete.png")));
                jFontSmallerButton.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        jFontSmallerButtonActionPerformed(evt);
                    }
                });
            }
            {
                jLabel1 = new JLabel();
                jToolBar.add(jLabel1);
                jLabel1.setText(" ");
            }
            {
                jSearchTextField = new JSearchTextField();
                jToolBar.add(jSearchTextField);
                jSearchTextField.setMaximumSize(new java.awt.Dimension(100, 22));
                jSearchTextField.setPreferredSize(new java.awt.Dimension(100, 22));
                jSearchTextField.setSize(new java.awt.Dimension(100, 22));
                jSearchTextField.addKeyListener(new KeyAdapter() {
                    public void keyReleased(KeyEvent evt) {
                        jSearchTextFieldKeyReleased(evt);
                    }
                });

            }
            {
                jSeparatorLabel = new JLabel();
                jToolBar.add(jSeparatorLabel);
                jSeparatorLabel.setText(" ");
            }
            {
                GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment();
                Font[] fonts = e.getAllFonts();
                String fontNames[] = new String[fonts.length];
                int x = 0;
                for (Font f : fonts) {
                    fontNames[x++] = f.getFontName();
                }
                ComboBoxModel jFontComboBoxModel = new DefaultComboBoxModel(fontNames);
                jFontComboBox = new JComboBox();
                jToolBar.add(jFontComboBox);
                jFontComboBox.setModel(jFontComboBoxModel);
                jFontComboBox.setMaximumSize(new java.awt.Dimension(180, 22));
                jFontComboBox.setPreferredSize(new java.awt.Dimension(180, 22));
                jFontComboBox.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        jFontComboBoxActionPerformed(evt);
                    }
                });
            }
            {
                pager = new Pager();
                jToolBar.add(pager);
                pager.setVisible(false);
            }
        }
        {
            jScrollPane1 = new JScrollPane();
            this.add(jScrollPane1, BorderLayout.CENTER);
            {
                jTextArea = new JTextArea();
                jTextArea.getDocument().addDocumentListener(this);
                lines = new JTextArea(" 1 ");
                lines.setBackground(new Color(200, 230, 245));
                lines.setEditable(false);
                jScrollPane1.setRowHeaderView(lines);

                jTextArea.getDocument().addDocumentListener(new DocumentListener() {
                    public String getText() {
                        int caretPosition = jTextArea.getDocument().getLength();
                        Element root = jTextArea.getDocument().getDefaultRootElement();

                        int base = 0;
                        if (separateByLine == false) {
                            if (str != null) {
                                base = StringUtils.countMatches(
                                        str.substring(0, (pager.getPage() - 1) * pageSize),
                                        System.getProperty("line.separator"));
                                if (base == 1) {
                                    base = 0;
                                }
                            }
                        } else {
                            base = (pager.getPage() - 1) * pageSize;
                        }
                        base += lineNoBase;
                        String text = " " + (base + 1) + " " + System.getProperty("line.separator");
                        for (int i = 2; i < root.getElementIndex(caretPosition) + 2; i++) {
                            text += " " + (base + i) + " " + System.getProperty("line.separator");
                        }
                        return text;
                    }

                    @Override
                    public void changedUpdate(DocumentEvent de) {
                        lines.setText(getText());
                    }

                    @Override
                    public void insertUpdate(DocumentEvent de) {
                        lines.setText(getText());
                    }

                    @Override
                    public void removeUpdate(DocumentEvent de) {
                        lines.setText(getText());
                    }

                });
                jScrollPane1.setViewportView(jTextArea);
            }
        }
        {
            jStatusPanel = new JPanel();
            FlowLayout jStatusPanelLayout = new FlowLayout();
            jStatusPanelLayout.setAlignment(FlowLayout.LEFT);
            jStatusPanel.setLayout(jStatusPanelLayout);
            this.add(jStatusPanel, BorderLayout.SOUTH);
            {
                jStatusLabel = new JLabel();
                jStatusPanel.add(jStatusLabel);
            }
            {
                jSearchLabel = new JLabel();
                jStatusPanel.add(jSearchLabel);
            }
        }
        this.jFontComboBox.setSelectedItem(jTextArea.getFont().getFamily() + ".plain");
    } catch (Exception e) {
        e.printStackTrace();
    }
}

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

private void configureComboBoxValue(String item) {
    comboBoxValue.setEditable(false);/*from  w w  w .  ja v a 2s  .c o  m*/
    if (item.equals("scientific name")) {
        comboBoxValue.setEditable(true);
    }
    if (item.equals("sex")) {
        comboBoxValue.setModel(new DefaultComboBoxModel(Sex.getSexValues()));
    }
    if (item.equals("life stage")) {
        comboBoxValue.setModel(new DefaultComboBoxModel(LifeStage.getLifeStageValues()));
    }
    if (item.equals("caste")) {
        comboBoxValue.setModel(new DefaultComboBoxModel(Caste.getCasteValues()));
    }
}

From source file:edu.gmu.cs.sim.util.media.chart.TimeSeriesAttributes.java

public void buildAttributes() {
    // The following three variables aren't defined until AFTER construction if
    // you just define them above.  So we define them below here instead.

    dashPattern = 0; // dashPatterns[0];
    stretch = 1.0f;//from   w w w  .j  a v  a2s. co  m
    thickness = 2.0f;

    // strokeColor = Color.black;  // rebuildGraphicsDefinitions will get called by our caller afterwards
    XYItemRenderer renderer = (((XYPlot) getPlot()).getRenderer());

    // NOTE:
    // Paint paint = renderer.getSeriesPaint(getSeriesIndex());        
    // In JFreeChart 1.0.6 getSeriesPaint returns null!!!
    // You need lookupSeriesPaint(), but that's not backward compatible.
    // The only thing consistent in all versions is getItemPaint 
    // (which looks like a gross miss-use, but gets the job done)

    Paint paint = renderer.getItemPaint(getSeriesIndex(), -1);

    strokeColor = (Color) paint;

    strokeColorWell = new ColorWell(strokeColor) {
        public Color changeColor(Color c) {
            strokeColor = c;
            rebuildGraphicsDefinitions();
            return c;
        }
    };
    addLabelled("Color", strokeColorWell);

    thicknessField = new NumberTextField(2.0, true) {
        public double newValue(double newValue) {
            if (newValue < 0.0) {
                newValue = currentValue;
            }
            thickness = (float) newValue;
            rebuildGraphicsDefinitions();
            return newValue;
        }
    };
    addLabelled("Width", thicknessField);

    dashPatternList = new JComboBox();
    dashPatternList.setEditable(false);
    dashPatternList.setModel(new DefaultComboBoxModel(
            new java.util.Vector(Arrays.asList(new String[] { "Solid", "__  __  __", "_  _  _  _", "_ _ _ _ _",
                    "_ _ . _ _ .", "_ . _ . _ .", "_ . . _ . .", ". . . . . . .", ".  .  .  .  ." }))));
    dashPatternList.setSelectedIndex(0);
    dashPatternList.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            dashPattern = dashPatternList.getSelectedIndex(); // dashPatterns[dashPatternList.getSelectedIndex()];
            rebuildGraphicsDefinitions();
        }
    });
    addLabelled("Dash", dashPatternList);
    stretchField = new NumberTextField(1.0, true) {
        public double newValue(double newValue) {
            if (newValue < 0.0) {
                newValue = currentValue;
            }
            stretch = (float) newValue;
            rebuildGraphicsDefinitions();
            return newValue;
        }
    };
    addLabelled("Stretch", stretchField);
}

From source file:com.projity.dialog.ResourceMappingDialog.java

public boolean bind(boolean get) {
    if (form == null)
        return false;
    if (get) {/*from  w  w  w . ja  v a  2  s.c  om*/
        field1.setModel(new DefaultComboBoxModel(form.getMergeFields()));
        field1.setSelectedItem(form.getMergeField());
        editorCombo.setModel(new DefaultComboBoxModel(form.getResources()));
        editorCombo.setSelectedIndex(0);

        accessControl.setSelectedIndex(form.getAccessControlType());
        localProject.setSelected(form.isLocal());
        setLocal(form.isLocal());

        //associationTable.setModel(new AssociationTableModel());
        AssociationTableModel tableModel = (AssociationTableModel) associationTable.getModel();
        tableModel.update();
    } else {
        form.setAccessControlType(accessControl.getSelectedIndex());
        //associationTable.finishCurrentOperations();
    }
    return true;
}

From source file:ja.lingo.application.gui.main.settings.dictionaries.add.AddPanel.java

public void onReaderSelected() {
    editorPane.setText(getSelectedReader().getDescription());
    fileChooser.getChooser().setFileFilter(getSelectedReader().getFileFilter());

    encodingCardPanel.show(//  www.  j a v a2  s .c  o m
            getSelectedReader().getSupportedEncodings().isEmpty() ? encodingAutoComboBox : encodingComboBox);
    encodingComboBox.setModel(new DefaultComboBoxModel(getSelectedReader().getSupportedEncodings().toArray()));
}