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() 

Source Link

Document

Constructs an empty DefaultComboBoxModel object.

Usage

From source file:de.tor.tribes.ui.windows.DSWorkbenchMainFrame.java

/**
 * Update on server change/* w w w. j  ava 2s.c  o m*/
 */
public void serverSettingsChangedEvent() {
    try {
        logger.info("Updating server settings");
        // <editor-fold defaultstate="collapsed" desc="Reset user profile specific contents">

        UserProfile profile = GlobalOptions.getSelectedProfile();
        String playerID = profile.toString();
        logger.info(" - using playerID " + playerID);
        profile.restoreProperties();
        jCurrentPlayer.setText(playerID);
        try {
            DefaultComboBoxModel model = new DefaultComboBoxModel();
            Tribe t = DataHolder.getSingleton().getTribeByName(profile.getTribeName());
            Village[] villages = t.getVillageList();
            Arrays.sort(villages, Village.CASE_INSENSITIVE_ORDER);
            for (Village v : villages) {
                model.addElement(v);
            }
            jCurrentPlayerVillages.setModel(model);
        } catch (Exception e) {
            jCurrentPlayerVillages.setModel(new DefaultComboBoxModel(new Object[] { "-keine Drfer-" }));
        }
        // </editor-fold>
        //update maps
        MapPanel.getSingleton().resetServerDependendSettings();
        MapPanel.getSingleton().updateMapPosition(dCenterX, dCenterY);
        MapPanel.getSingleton().getAttackAddFrame().buildUnitBox();
        //setup views
        DSWorkbenchMarkerFrame.getSingleton().resetView();
        DSWorkbenchMarkerFrame.getSingleton().restoreProperties();
        DSWorkbenchChurchFrame.getSingleton().resetView();
        DSWorkbenchChurchFrame.getSingleton().restoreProperties();
        DSWorkbenchWatchtowerFrame.getSingleton().resetView();
        DSWorkbenchWatchtowerFrame.getSingleton().restoreProperties();
        DSWorkbenchAttackFrame.getSingleton().resetView();
        DSWorkbenchAttackFrame.getSingleton().restoreProperties();
        DSWorkbenchAttackFrame.getSingleton().updateCountdownSettings();
        TacticsPlanerWizard.restoreProperties();
        ResourceDistributorWizard.restoreProperties();
        DSWorkbenchTagFrame.getSingleton().resetView();
        DSWorkbenchTagFrame.getSingleton().restoreProperties();
        DSWorkbenchConquersFrame.getSingleton().resetView();
        DSWorkbenchConquersFrame.getSingleton().restoreProperties();
        //update troops table and troops view
        TroopSetupConfigurationFrame.getSingleton().setup();
        DSWorkbenchTroopsFrame.getSingleton().resetView();
        DSWorkbenchTroopsFrame.getSingleton().restoreProperties();
        DistanceManager.getSingleton().clear();
        StatManager.getSingleton().setup();
        DSWorkbenchDistanceFrame.getSingleton().resetView();
        DSWorkbenchDistanceFrame.getSingleton().restoreProperties();
        DSWorkbenchStatsFrame.getSingleton().resetView();
        DSWorkbenchStatsFrame.getSingleton().restoreProperties();
        DSWorkbenchDoItYourselfAttackPlaner.getSingleton().resetView();
        DSWorkbenchDoItYourselfAttackPlaner.getSingleton().restoreProperties();
        DSWorkbenchReportFrame.getSingleton().resetView();
        DSWorkbenchReportFrame.getSingleton().restoreProperties();
        DSWorkbenchSOSRequestAnalyzer.getSingleton().resetView();
        DSWorkbenchSOSRequestAnalyzer.getSingleton().restoreProperties();
        DSWorkbenchFarmManager.getSingleton().resetView();
        DSWorkbenchFarmManager.getSingleton().restoreProperties();
        BBCodeEditor.getSingleton().reset();
        //update attack planner
        DSWorkbenchSettingsDialog.getSingleton().setupAttackColorTable();
        DSWorkbenchRankFrame.getSingleton().resetView();
        DSWorkbenchRankFrame.getSingleton().restoreProperties();

        jLabel1.setText("X");
        jLabel2.setText("Y");
        DSRealManager.getSingleton().checkFilesystem();

        jROIBox.setModel(new DefaultComboBoxModel(ROIManager.getSingleton().getROIs()));
        DSWorkbenchSelectionFrame.getSingleton().resetView();
        DSWorkbenchSelectionFrame.getSingleton().restoreProperties();
        DSWorkbenchNotepad.getSingleton().resetView();
        DSWorkbenchNotepad.getSingleton().restoreProperties();

        if (!GlobalOptions.isOfflineMode() && DSWorkbenchSimulatorFrame.getSingleton().isVisible()) {
            try {
                DSWorkbenchSimulatorFrame.getSingleton().showIntegratedVersion(
                        DSWorkbenchSettingsDialog.getSingleton().getWebProxy(),
                        GlobalOptions.getSelectedServer());
            } catch (Exception e) {
                logger.warn("Problem during writing Troops to AStar", e);
            }
        }
        ConquerManager.getSingleton().revalidate(true);
        //relevant for first start
        LayerOrderConfigurationFrame.getSingleton();
        MinimapPanel.getSingleton().redraw(true);
        DSWorkbenchFormFrame.getSingleton().resetView();
        DSWorkbenchFormFrame.getSingleton().restoreProperties();
        FormConfigFrame.getSingleton();
        DSWorkbenchSearchFrame.getSingleton();

        logger.info("Server settings updated");
        if (isVisible() && !DSWorkbenchSettingsDialog.getSingleton().isVisible()) {
            showReminder();
        }
    } catch (Exception e) {
        throw new RuntimeException("Initialization failed", e);
    }
}

From source file:gdt.jgui.entity.query.JQueryPanel.java

private void initElementSelector() {
    DefaultComboBoxModel<String> model = new DefaultComboBoxModel<String>();
    String[] sa = select();//  w  w  w.  ja  v a2 s .c  o m
    if (sa == null) {
        elementComboBox.setModel(model);
        return;
    }
    try {
        Entigrator entigrator = console.getEntigrator(entihome$);
        ArrayList<String> sl = new ArrayList<String>();
        Sack entity;
        String[] ea;
        for (String s : sa) {
            entity = entigrator.getEntityAtKey(s);
            if (entity == null)
                continue;
            ea = entity.elementsList();
            if (ea != null)
                for (String e : ea)
                    if (!sl.contains(e))
                        sl.add(e);
        }
        Collections.sort(sl);
        for (String s : sl)
            model.addElement(s);
        elementComboBox.setModel(model);
    } catch (Exception e) {
        Logger.getLogger(getClass().getName()).severe(e.toString());
    }
}

From source file:gdt.jgui.entity.query.JQueryPanel.java

private void initItemNameFieldSelector() {
    DefaultComboBoxModel<String> model = new DefaultComboBoxModel<String>();
    model.addElement("name");
    model.addElement("type");
    itemNameFieldComboBox.setModel(model);
}

From source file:gdt.jgui.entity.query.JQueryPanel.java

private void initItemNameSelector() {
    DefaultComboBoxModel<String> model = new DefaultComboBoxModel<String>();
    try {//ww  w .  j  a va 2  s . co m
        String element$ = (String) elementComboBox.getSelectedItem();
        String constituent$ = (String) itemNameFieldComboBox.getSelectedItem();
        Entigrator entigrator = console.getEntigrator(entihome$);
        String[] sa = select();
        ArrayList<String> sl = new ArrayList<String>();
        Sack entity;
        String[] ia;
        String item$;
        Core item;
        for (String s : sa) {
            entity = entigrator.getEntityAtKey(s);
            if (entity == null)
                continue;
            ia = entity.elementList(element$);
            if (ia != null)
                for (String i : ia) {
                    item$ = null;
                    item = entity.getElementItem(element$, i);
                    if ("name".equals(constituent$))
                        item$ = item.name;
                    if ("type".equals(constituent$))
                        item$ = item.type;
                    if (item$ != null && !sl.contains(item$))
                        sl.add(item$);
                }
        }
        Collections.sort(sl);
        for (String s : sl)
            model.addElement(s);
        itemNameComboBox.setModel(model);
    } catch (Exception e) {
        Logger.getLogger(getClass().getName()).severe(e.toString());
        itemNameComboBox.setModel(model);
    }
}

From source file:gdt.jgui.entity.query.JQueryPanel.java

private void initItemValueSelector() {
    DefaultComboBoxModel<String> model = new DefaultComboBoxModel<String>();
    try {// w w w.j  a  v a2 s  . c  o m
        String element$ = (String) elementComboBox.getSelectedItem();
        String field$ = (String) itemNameFieldComboBox.getSelectedItem();
        String itemName$ = (String) itemNameComboBox.getSelectedItem();
        Entigrator entigrator = console.getEntigrator(entihome$);
        String[] sa = select();
        ArrayList<String> sl = new ArrayList<String>();
        Sack entity;
        String[] ia;

        String value$;
        Core item;
        for (String s : sa) {
            entity = entigrator.getEntityAtKey(s);
            if (entity == null)
                continue;
            ia = entity.elementList(element$);
            if (ia != null)
                for (String i : ia) {
                    value$ = null;
                    item = entity.getElementItem(element$, i);
                    if ("name".equals(field$) && itemName$.equals(item.name))
                        value$ = item.value;

                    if ("type".equals(field$) && itemName$.equals(item.type))
                        value$ = item.value;
                    if (value$ != null && !sl.contains(value$))
                        sl.add(value$);
                }
        }
        Collections.sort(sl);
        for (String s : sl)
            model.addElement(s);
        itemValueComboBox.setModel(model);
    } catch (Exception e) {
        Logger.getLogger(getClass().getName()).severe(e.toString());
        itemValueComboBox.setModel(model);
    }
}

From source file:com.declarativa.interprolog.gui.ListenerWindow.java

private void UpdategraphComponents2(Forest<String, Integer> graph) throws IOException {
    jLayeredPane5.removeAll();//from  w w w.  jav a  2s  . c  o m

    /*     
             
     List<String> heads = new ArrayList<>();
     List<String> subgrph = new ArrayList<>();
     ArgBuildManager manag = new ArgBuildManager();
     Forest<String, Integer> graphGUI = new DelegateForest<>();
            
            
     graphGUI = manag.getGraphJung();
     */
    Forest<String, Integer> graphGUI = new DelegateForest<>();

    graphGUI = graph;

    System.out.println("\t \t NUM UF VERT:" + graphGUI.getVertexCount());

    //ObservableGraph g = new ObservableGraph(new BalloonLayoutDemo().createTree(forest));
    ObservableGraph g = new ObservableGraph(graphGUI);

    //Layout layout = new BalloonLayout(forest);
    Layout layout = new BalloonLayout(graphGUI);
    //Layout layout = new TreeLayout(forest, 70, 70);

    final BaseJungScene scene2 = new SceneImpl(g, layout);

    jLayeredPane5.setLayout(new BorderLayout());
    //jf.setLayout(new BorderLayout());

    jLayeredPane5.add(new JScrollPane(scene2.createView()), BorderLayout.CENTER);
    //jf.add(new JScrollPane(scene2.createView()), BorderLayout.CENTER);

    JToolBar bar = new JToolBar();
    bar.setMargin(new Insets(5, 5, 5, 5));
    bar.setLayout(new FlowLayout(5));
    DefaultComboBoxModel<Layout> mdl = new DefaultComboBoxModel<>();
    mdl.addElement(new KKLayout(g));
    mdl.addElement(layout);
    mdl.addElement(new BalloonLayout(forest));
    mdl.addElement(new RadialTreeLayout(forest));
    mdl.addElement(new CircleLayout(g));
    mdl.addElement(new FRLayout(g));
    mdl.addElement(new FRLayout2(g));
    mdl.addElement(new ISOMLayout(g));
    mdl.addElement(new edu.uci.ics.jung.algorithms.layout.SpringLayout(g));
    mdl.addElement(new SpringLayout2(g));
    mdl.addElement(new DAGLayout(g));
    mdl.addElement(new XLayout(g));
    mdl.setSelectedItem(layout);
    final JCheckBox checkbox = new JCheckBox("Animate iterative layouts");

    scene2.setLayoutAnimationFramesPerSecond(48);

    final JComboBox<Layout> layouts = new JComboBox(mdl);
    layouts.setRenderer(new DefaultListCellRenderer() {
        @Override
        public Component getListCellRendererComponent(JList<?> jlist, Object o, int i, boolean bln,
                boolean bln1) {
            o = o.getClass().getSimpleName();
            return super.getListCellRendererComponent(jlist, o, i, bln, bln1); //To change body of generated methods, choose Tools | Templates.
        }
    });
    bar.add(new JLabel(" Layout Type"));
    bar.add(layouts);
    layouts.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            Layout layout = (Layout) layouts.getSelectedItem();
            // These two layouts implement IterativeContext, but they do
            // not evolve toward anything, they just randomly rearrange
            // themselves.  So disable animation for these.
            if (layout instanceof ISOMLayout || layout instanceof DAGLayout) {
                checkbox.setSelected(false);
            }
            scene2.setGraphLayout(layout, true);
        }
    });

    bar.add(new JLabel(" Connection Shape"));
    DefaultComboBoxModel<Transformer<Context<Graph<String, Number>, Number>, Shape>> shapes = new DefaultComboBoxModel<>();
    shapes.addElement(new EdgeShape.QuadCurve<String, Number>());
    shapes.addElement(new EdgeShape.BentLine<String, Number>());
    shapes.addElement(new EdgeShape.CubicCurve<String, Number>());
    shapes.addElement(new EdgeShape.Line<String, Number>());
    shapes.addElement(new EdgeShape.Box<String, Number>());
    shapes.addElement(new EdgeShape.Orthogonal<String, Number>());
    shapes.addElement(new EdgeShape.Wedge<String, Number>(10));

    final JComboBox<Transformer<Context<Graph<String, Number>, Number>, Shape>> shapesBox = new JComboBox<>(
            shapes);
    shapesBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            Transformer<Context<Graph<String, Number>, Number>, Shape> xform = (Transformer<Context<Graph<String, Number>, Number>, Shape>) shapesBox
                    .getSelectedItem();
            scene2.setConnectionEdgeShape(xform);
        }
    });
    shapesBox.setRenderer(new DefaultListCellRenderer() {
        @Override
        public Component getListCellRendererComponent(JList<?> jlist, Object o, int i, boolean bln,
                boolean bln1) {
            o = o.getClass().getSimpleName();
            return super.getListCellRendererComponent(jlist, o, i, bln, bln1); //To change body of generated methods, choose Tools | Templates.
        }
    });
    shapesBox.setSelectedItem(new EdgeShape.QuadCurve<>());
    bar.add(shapesBox);

    //jf.add(bar, BorderLayout.NORTH);
    bar.add(new ListenerWindow.MinSizePanel(scene2.createSatelliteView()));
    bar.setFloatable(false);
    bar.setRollover(true);

    final JLabel selectionLabel = new JLabel("<html>&nbsp;</html>");
    System.out.println("LOOKUP IS " + scene2.getLookup());
    Lookup.Result<String> selectedNodes = scene2.getLookup().lookupResult(String.class);
    LookupListener listener = new LookupListener() {
        @Override
        public void resultChanged(LookupEvent le) {
            System.out.println("RES CHANGED");
            Lookup.Result<String> res = (Lookup.Result<String>) le.getSource();
            StringBuilder sb = new StringBuilder("<html>");
            List<String> l = new ArrayList<>(res.allInstances());
            Collections.sort(l);
            for (String s : l) {
                if (sb.length() != 0) {
                    sb.append(", ");
                }
                sb.append(s);
            }
            sb.append("</html>");
            selectionLabel.setText(sb.toString());
            System.out.println("LOOKUP EVENT " + sb);
        }
    };
    selectedNodes.addLookupListener(listener);
    selectedNodes.allInstances();

    bar.add(selectionLabel);

    checkbox.setSelected(true);
    checkbox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            scene2.setAnimateIterativeLayouts(checkbox.isSelected());
        }
    });
    bar.add(checkbox);
    jLayeredPane6.setLayout(new BorderLayout());

    jLayeredPane6.add(bar);
    //        jf.setSize(jf.getGraphicsConfiguration().getBounds().width - 120, 700);
    //        jf.setSize(new Dimension(1280, 720));
    //        jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    // this.repaint();
    this.addWindowListener(new WindowAdapter() {
        @Override
        public void windowOpened(WindowEvent we) {
            scene2.relayout(true);
            scene2.validate();
        }
    });

}

From source file:eu.crisis_economics.abm.dashboard.Page_Parameters.java

@SuppressWarnings("serial")
private JPanel createParamsweepGUI() {

    // left/*from   w  ww  .  j a  v  a 2 s. co  m*/
    parameterList = new JList();
    parameterList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    new ListAction(parameterList, new AbstractAction() {
        public void actionPerformed(final ActionEvent event) {
            final AvailableParameter selectedParameter = (AvailableParameter) parameterList.getSelectedValue();
            addParameterToTree(new AvailableParameter[] { selectedParameter }, parameterTreeBranches.get(0));
            enableDisableParameterCombinationButtons();
        }
    });
    parameterList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (!parameterList.isSelectionEmpty()) {
                boolean success = true;
                if (editedNode != null)
                    success = modify();

                if (success) {
                    cancelAllSelectionBut(parameterList);
                    resetSettings();
                    updateDescriptionField(parameterList.getSelectedValues());
                    enableDisableParameterCombinationButtons();
                } else
                    parameterList.clearSelection();
            }
        }
    });

    final JScrollPane parameterListPane = new JScrollPane(parameterList);
    parameterListPane.setBorder(BorderFactory.createTitledBorder("")); // for rounded border
    parameterListPane.setPreferredSize(new Dimension(300, 300));

    final JPanel parametersPanel = FormsUtils.build("p ' p:g", "[DialogBorder]00||" + "12||" + "34||" +
    //                                          "56||" + 
            "55||" + "66 f:p:g", new FormsUtils.Separator("<html><b>General parameters</b></html>"),
            NUMBER_OF_TURNS_LABEL_TEXT, numberOfTurnsFieldPSW, NUMBER_OF_TIMESTEPS_TO_IGNORE_LABEL_TEXT,
            numberTimestepsIgnoredPSW,
            //                                          UPDATE_CHARTS_LABEL_TEXT,onLineChartsCheckBoxPSW,
            new FormsUtils.Separator("<html><b>Model parameters</b></html>"), parameterListPane).getPanel();

    combinationsPanel = new JPanel(new GridLayout(0, 1, 5, 5));
    combinationsScrPane = new JScrollPane(combinationsPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    combinationsScrPane.setBorder(null);
    combinationsScrPane.setPreferredSize(new Dimension(550, 500));

    parameterDescriptionLabel = new JXLabel();
    parameterDescriptionLabel.setLineWrap(true);
    parameterDescriptionLabel.setVerticalAlignment(SwingConstants.TOP);
    final JScrollPane descriptionScrollPane = new JScrollPane(parameterDescriptionLabel);
    descriptionScrollPane.setBorder(BorderFactory.createTitledBorder(null, "Description", TitledBorder.LEADING,
            TitledBorder.BELOW_TOP));
    descriptionScrollPane.setPreferredSize(
            new Dimension(PARAMETER_DESCRIPTION_LABEL_WIDTH, PARAMETER_DESCRIPTION_LABEL_HEIGHT));
    descriptionScrollPane.setViewportBorder(null);

    final JButton addNewBoxButton = new JButton("Add new combination");
    addNewBoxButton.setActionCommand(ACTIONCOMMAND_ADD_BOX);

    final JPanel left = FormsUtils.build("p ~ f:p:g ~ p", "011 f:p:g ||" + "0_2 p", parametersPanel,
            combinationsScrPane, addNewBoxButton).getPanel();
    left.setBorder(BorderFactory.createTitledBorder(null, "Specify parameter combinations",
            TitledBorder.LEADING, TitledBorder.BELOW_TOP));
    Style.registerCssClasses(left, Dashboard.CSS_CLASS_COMMON_PANEL);

    final JPanel leftAndDesc = new JPanel(new BorderLayout());
    leftAndDesc.add(left, BorderLayout.CENTER);
    leftAndDesc.add(descriptionScrollPane, BorderLayout.SOUTH);
    Style.registerCssClasses(leftAndDesc, Dashboard.CSS_CLASS_COMMON_PANEL);

    // right
    editedParameterText = new JLabel(ORIGINAL_TEXT);
    editedParameterText.setPreferredSize(new Dimension(280, 40));
    constDef = new JRadioButton("Constant");
    listDef = new JRadioButton("List");
    incrDef = new JRadioButton("Increment");

    final JPanel rightTop = FormsUtils.build("p:g", "[DialogBorder]0||" + "1||" + "2||" + "3",
            editedParameterText, constDef, listDef, incrDef).getPanel();

    Style.registerCssClasses(rightTop, Dashboard.CSS_CLASS_COMMON_PANEL);

    constDefField = new JTextField();
    final JPanel constDefPanel = FormsUtils
            .build("p ~ p:g", "[DialogBorder]01 p", "Constant value: ", CellConstraints.TOP, constDefField)
            .getPanel();

    listDefArea = new JTextArea();
    final JScrollPane listDefScr = new JScrollPane(listDefArea,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    final JPanel listDefPanel = FormsUtils.build("p ~ p:g", "[DialogBorder]01|" + "_1 f:p:g||" + "_2 p",
            "Value list: ", listDefScr, "(Separate values with spaces!)").getPanel();

    incrStartValueField = new JTextField();
    incrEndValueField = new JTextField();
    incrStepField = new JTextField();

    final JPanel incrDefPanel = FormsUtils.build("p ~ p:g", "[DialogBorder]01||" + "23||" + "45",
            "Start value: ", incrStartValueField, "End value: ", incrEndValueField, "Step: ", incrStepField)
            .getPanel();

    enumDefBox = new JComboBox(new DefaultComboBoxModel());
    final JPanel enumDefPanel = FormsUtils
            .build("p ~ p:g", "[DialogBorder]01 p", "Constant value:", CellConstraints.TOP, enumDefBox)
            .getPanel();

    submodelTypeBox = new JComboBox();
    final JPanel submodelTypePanel = FormsUtils
            .build("p ~ p:g", "[DialogBorder]01", "Constant value:", CellConstraints.TOP, submodelTypeBox)
            .getPanel();

    fileTextField = new JTextField();
    fileTextField.addKeyListener(new KeyAdapter() {
        public void keyTyped(final KeyEvent e) {
            final char character = e.getKeyChar();
            final File file = new File(Character.isISOControl(character) ? fileTextField.getText()
                    : fileTextField.getText() + character);
            fileTextField.setToolTipText(file.getAbsolutePath());
        }
    });
    fileBrowseButton = new JButton(BROWSE_BUTTON_TEXT);
    fileBrowseButton.setActionCommand(ACTIONCOMMAND_BROWSE);
    final JPanel fileDefPanel = FormsUtils
            .build("p ~ p:g ~p", "[DialogBorder]012", "File:", fileTextField, fileBrowseButton).getPanel();

    constDefPanel.setName("CONST");
    listDefPanel.setName("LIST");
    incrDefPanel.setName("INCREMENT");
    enumDefPanel.setName("ENUM");
    submodelTypePanel.setName("SUBMODEL");
    fileDefPanel.setName("FILE");

    Style.registerCssClasses(constDefPanel, Dashboard.CSS_CLASS_COMMON_PANEL);
    Style.registerCssClasses(listDefPanel, Dashboard.CSS_CLASS_COMMON_PANEL);
    Style.registerCssClasses(incrDefPanel, Dashboard.CSS_CLASS_COMMON_PANEL);
    Style.registerCssClasses(enumDefPanel, Dashboard.CSS_CLASS_COMMON_PANEL);
    Style.registerCssClasses(submodelTypePanel, Dashboard.CSS_CLASS_COMMON_PANEL);
    Style.registerCssClasses(fileDefPanel, Dashboard.CSS_CLASS_COMMON_PANEL);

    rightMiddle = new JPanel(new CardLayout());
    Style.registerCssClasses(rightMiddle, Dashboard.CSS_CLASS_COMMON_PANEL);
    rightMiddle.add(constDefPanel, constDefPanel.getName());
    rightMiddle.add(listDefPanel, listDefPanel.getName());
    rightMiddle.add(incrDefPanel, incrDefPanel.getName());
    rightMiddle.add(enumDefPanel, enumDefPanel.getName());
    rightMiddle.add(submodelTypePanel, submodelTypePanel.getName());
    rightMiddle.add(fileDefPanel, fileDefPanel.getName());

    modifyButton = new JButton("Modify");
    cancelButton = new JButton("Cancel");

    final JPanel rightBottom = FormsUtils
            .build("p:g p ~ p ~ p:g", "[DialogBorder]_01_ p", modifyButton, cancelButton).getPanel();

    Style.registerCssClasses(rightBottom, Dashboard.CSS_CLASS_COMMON_PANEL);

    final JPanel right = new JPanel(new BorderLayout());
    right.add(rightTop, BorderLayout.NORTH);
    right.add(rightMiddle, BorderLayout.CENTER);
    right.add(rightBottom, BorderLayout.SOUTH);
    right.setBorder(BorderFactory.createTitledBorder(null, "Parameter settings", TitledBorder.LEADING,
            TitledBorder.BELOW_TOP));

    Style.registerCssClasses(right, Dashboard.CSS_CLASS_COMMON_PANEL);

    // the whole paramsweep panel

    final JPanel content = FormsUtils.build("p:g p", "01 f:p:g", leftAndDesc, right).getPanel();
    Style.registerCssClasses(content, Dashboard.CSS_CLASS_COMMON_PANEL);

    sweepPanel = new JPanel();
    Style.registerCssClasses(sweepPanel, Dashboard.CSS_CLASS_COMMON_PANEL);
    sweepPanel.setLayout(new BorderLayout());
    final JScrollPane sp = new JScrollPane(content);
    sp.setBorder(null);
    sp.setViewportBorder(null);
    sweepPanel.add(sp, BorderLayout.CENTER);

    GUIUtils.createButtonGroup(constDef, listDef, incrDef);
    constDef.setSelected(true);
    constDef.setActionCommand("CONST");
    listDef.setActionCommand("LIST");
    incrDef.setActionCommand("INCREMENT");

    constDefField.setActionCommand("CONST_FIELD");
    incrStartValueField.setActionCommand("START_FIELD");
    incrEndValueField.setActionCommand("END_FIELD");
    incrStepField.setActionCommand("STEP_FIELD");

    modifyButton.setActionCommand("EDIT");
    cancelButton.setActionCommand("CANCEL");

    listDefArea.setLineWrap(true);
    listDefArea.setWrapStyleWord(true);
    listDefScr.setPreferredSize(new Dimension(100, 200));

    GUIUtils.addActionListener(this, modifyButton, cancelButton, constDef, listDef, incrDef, constDefField,
            incrStartValueField, incrEndValueField, incrStepField, addNewBoxButton, submodelTypeBox,
            fileBrowseButton);

    return sweepPanel;
}

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

void reloadFileExtensionComboBox() {
    DefaultComboBoxModel model = new DefaultComboBoxModel();
    model.addElement("");
    for (String extension : fileExtenstionSet) {
        model.addElement(extension);// w  w  w  . ja  va  2s .c  om
    }
    fileExtensionComboBox.setModel(model);
    fileExtensionFilter.setModel(model);
}

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

void reloadAuthorComboBox() {
    DefaultComboBoxModel model = new DefaultComboBoxModel();
    model.addElement("");
    for (String author : authorSet) {
        boolean findRef = false;
        for (Map.Entry<?, ?> _entry : authorProps.entrySet()) {
            if (_entry.getKey().equals(author)) {
                model.addElement(_entry);
                findRef = true;/*from   w  w  w . ja v  a2s .co  m*/
                break;
            }
        }
        if (!findRef) {
            model.addElement(author);
        }
    }
    authorComboBox.setModel(model);
}

From source file:com.declarativa.interprolog.gui.Ini2.java

private void graphComponents() throws IOException {

    Forest<String, Integer> forest = new DelegateForest<>();
    ObservableGraph g = new ObservableGraph(new BalloonLayoutDemo().createTree(forest));

    Layout layout = new BalloonLayout(forest);
    //Layout layout = new TreeLayout(forest, 70, 70);

    final BaseJungScene scene = new SceneImpl(g, layout);

    jLayeredPane1.setLayout(new BorderLayout());
    //jf.setLayout(new BorderLayout());

    jLayeredPane1.add(new JScrollPane(scene.createView()), BorderLayout.CENTER);
    //jf.add(new JScrollPane(scene.createView()), BorderLayout.CENTER);

    JToolBar bar = new JToolBar();
    bar.setMargin(new Insets(5, 5, 5, 5));
    bar.setLayout(new FlowLayout(5));
    DefaultComboBoxModel<Layout> mdl = new DefaultComboBoxModel<>();
    mdl.addElement(new KKLayout(g));
    mdl.addElement(layout);/*from   w  w  w. java2 s .  c  o  m*/
    mdl.addElement(new BalloonLayout(forest));
    mdl.addElement(new RadialTreeLayout(forest));
    mdl.addElement(new CircleLayout(g));
    mdl.addElement(new FRLayout(g));
    mdl.addElement(new FRLayout2(g));
    mdl.addElement(new ISOMLayout(g));
    mdl.addElement(new SpringLayout(g));
    mdl.addElement(new SpringLayout2(g));
    mdl.addElement(new DAGLayout(g));
    mdl.addElement(new XLayout(g));
    mdl.setSelectedItem(layout);
    final JCheckBox checkbox = new JCheckBox("Animate iterative layouts");

    scene.setLayoutAnimationFramesPerSecond(48);

    final JComboBox<Layout> layouts = new JComboBox(mdl);
    layouts.setRenderer(new DefaultListCellRenderer() {
        @Override
        public Component getListCellRendererComponent(JList<?> jlist, Object o, int i, boolean bln,
                boolean bln1) {
            o = o.getClass().getSimpleName();
            return super.getListCellRendererComponent(jlist, o, i, bln, bln1); //To change body of generated methods, choose Tools | Templates.
        }
    });
    bar.add(new JLabel(" Layout Type"));
    bar.add(layouts);
    layouts.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            Layout layout = (Layout) layouts.getSelectedItem();
            // These two layouts implement IterativeContext, but they do
            // not evolve toward anything, they just randomly rearrange
            // themselves.  So disable animation for these.
            if (layout instanceof ISOMLayout || layout instanceof DAGLayout) {
                checkbox.setSelected(false);
            }
            scene.setGraphLayout(layout, true);
        }
    });

    bar.add(new JLabel(" Connection Shape"));
    DefaultComboBoxModel<Transformer<Context<Graph<String, Number>, Number>, Shape>> shapes = new DefaultComboBoxModel<>();
    shapes.addElement(new EdgeShape.QuadCurve<String, Number>());
    shapes.addElement(new EdgeShape.BentLine<String, Number>());
    shapes.addElement(new EdgeShape.CubicCurve<String, Number>());
    shapes.addElement(new EdgeShape.Line<String, Number>());
    shapes.addElement(new EdgeShape.Box<String, Number>());
    shapes.addElement(new EdgeShape.Orthogonal<String, Number>());
    shapes.addElement(new EdgeShape.Wedge<String, Number>(10));

    final JComboBox<Transformer<Context<Graph<String, Number>, Number>, Shape>> shapesBox = new JComboBox<>(
            shapes);
    shapesBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            Transformer<Context<Graph<String, Number>, Number>, Shape> xform = (Transformer<Context<Graph<String, Number>, Number>, Shape>) shapesBox
                    .getSelectedItem();
            scene.setConnectionEdgeShape(xform);
        }
    });
    shapesBox.setRenderer(new DefaultListCellRenderer() {
        @Override
        public Component getListCellRendererComponent(JList<?> jlist, Object o, int i, boolean bln,
                boolean bln1) {
            o = o.getClass().getSimpleName();
            return super.getListCellRendererComponent(jlist, o, i, bln, bln1); //To change body of generated methods, choose Tools | Templates.
        }
    });
    shapesBox.setSelectedItem(new EdgeShape.QuadCurve<>());
    bar.add(shapesBox);

    //jf.add(bar, BorderLayout.NORTH);

    bar.add(new MinSizePanel(scene.createSatelliteView()));
    bar.setFloatable(false);
    bar.setRollover(true);

    final JLabel selectionLabel = new JLabel("<html>&nbsp;</html>");
    System.out.println("LOOKUP IS " + scene.getLookup());
    Lookup.Result<String> selectedNodes = scene.getLookup().lookupResult(String.class);
    LookupListener listener = new LookupListener() {
        @Override
        public void resultChanged(LookupEvent le) {
            System.out.println("RES CHANGED");
            Lookup.Result<String> res = (Lookup.Result<String>) le.getSource();
            StringBuilder sb = new StringBuilder("<html>");
            List<String> l = new ArrayList<>(res.allInstances());
            Collections.sort(l);
            for (String s : l) {
                if (sb.length() != 0) {
                    sb.append(", ");
                }
                sb.append(s);
            }
            sb.append("</html>");
            selectionLabel.setText(sb.toString());
            System.out.println("LOOKUP EVENT " + sb);
        }
    };
    selectedNodes.addLookupListener(listener);
    selectedNodes.allInstances();

    bar.add(selectionLabel);

    checkbox.setSelected(true);
    checkbox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            scene.setAnimateIterativeLayouts(checkbox.isSelected());
        }
    });
    bar.add(checkbox);
    jLayeredPane3.setLayout(new BorderLayout());

    jLayeredPane3.add(bar);
    //        jf.setSize(jf.getGraphicsConfiguration().getBounds().width - 120, 700);
    //        jf.setSize(new Dimension(1280, 720));
    //        jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    this.addWindowListener(new WindowAdapter() {
        @Override
        public void windowOpened(WindowEvent we) {
            scene.relayout(true);
            scene.validate();
        }
    });

}