Example usage for javax.swing JCheckBox JCheckBox

List of usage examples for javax.swing JCheckBox JCheckBox

Introduction

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

Prototype

public JCheckBox(Action a) 

Source Link

Document

Creates a check box where properties are taken from the Action supplied.

Usage

From source file:br.ufrgs.enq.jcosmo.ui.COSMOSACDialog.java

public COSMOSACDialog() {
    super("JCOSMO Simple");
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setLayout(new BorderLayout());

    db = COSMOSACDataBase.getInstance();

    COSMOSAC models[] = new COSMOSAC[5];
    models[0] = new COSMOSAC();
    models[1] = new COSMOPAC();
    models[2] = new COSMOSAC_SVP();
    models[3] = new COSMOSAC_G();
    models[4] = new PCMSAC();
    modelBox = new JComboBox(models);
    modelBox.addActionListener(this);

    JPanel north = new JPanel(new GridLayout(0, 2));
    add(north, BorderLayout.NORTH);
    JPanel northAba1 = new JPanel(new GridLayout(0, 4));
    JPanel northAba2 = new JPanel(new GridLayout(0, 2));

    //Where the GUI is created:
    JMenuBar menuBar;/*  w  ww  .  j ava  2 s  .co m*/
    JMenu file, help;
    JMenuItem menuItem;

    //Create the menu bar.
    menuBar = new JMenuBar();

    // the file menu
    file = new JMenu("File");
    file.setMnemonic(KeyEvent.VK_F);
    menuBar.add(file);
    menuItem = new JMenuItem("Quit", KeyEvent.VK_Q);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, ActionEvent.ALT_MASK));
    menuItem.setActionCommand(QUIT);
    menuItem.addActionListener(this);
    file.add(menuItem);

    // the help menu
    help = new JMenu("Help");
    file.setMnemonic(KeyEvent.VK_H);
    menuBar.add(help);
    menuItem = new JMenuItem("About", KeyEvent.VK_A);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0));
    menuItem.setActionCommand(ABOUT);
    menuItem.addActionListener(this);
    help.add(menuItem);

    setJMenuBar(menuBar);

    listModel = new DefaultListModel();
    list = new JList(listModel);
    list.setBorder(BorderFactory.createTitledBorder("compounds"));
    list.setVisibleRowCount(2);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    JScrollPane listScrollPane = new JScrollPane(list);

    JButton addButton = new JButton("Add");
    addButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            new AddCompoundDialog(COSMOSACDialog.this);
        }
    });

    removeButton = new JButton("Remove");
    removeButton.addActionListener(this);
    visibRemove(false);

    JButton calcButton = new JButton("Calculate");
    calcButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            rebuildChart();
            rebuildSigmaProfiles();
        }
    });

    JButton refreshButton = new JButton("Refresh");
    refreshButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            rebuildSigmaProfiles();
        }
    });

    ignoreSGButton = new JCheckBox("Ignore SG");
    ignoreSGButton.setToolTipText("Toogles the ignore flag for the Staverman-Guggenheim term");
    ignoreSGButton.addActionListener(this);

    JPanel but = new JPanel(new GridLayout(0, 1));
    but.add(addButton, BorderLayout.EAST);
    but.add(removeButton, BorderLayout.EAST);
    but.add(modelBox);
    north.add(listScrollPane);
    north.add(but);

    northAba1.add(new JLabel("Temperature [K]"));
    northAba1.add(temperature = new JTextField(10));
    temperature.setText("298");

    northAba1.add(new JLabel("Sigma HB"));
    northAba1.add(sigmaHB = new JTextField(10));
    northAba1.add(new JLabel("Sigma HB2"));
    northAba1.add(sigmaHB2 = new JTextField(10));
    northAba1.add(new JLabel("Sigma HB3"));
    northAba1.add(sigmaHB3 = new JTextField(10));

    northAba1.add(new JLabel("Charge HB"));
    northAba1.add(chargeHB = new JTextField(10));

    northAba1.add(new JLabel("Sigma Disp"));
    northAba1.add(sigmaDisp = new JTextField(10));
    northAba1.add(new JLabel("Charge Disp"));
    northAba1.add(chargeDisp = new JTextField(10));

    northAba1.add(new JLabel("Beta"));
    northAba1.add(beta = new JTextField(10));
    northAba1.add(new JLabel("fpol"));
    northAba1.add(fpol = new JTextField(10));
    northAba1.add(new JLabel("Anorm"));
    northAba1.add(anorm = new JTextField(10));

    northAba1.add(ignoreSGButton);
    northAba1.add(calcButton);
    northAba2.add(new JLabel(""));
    northAba2.add(refreshButton);

    //      chart = new JLineChart();
    //      add(chart, BorderLayout.CENTER);
    //      chart.setTitle("Gamma Plot");
    //      chart.setSubtitle("");
    //      chart.setXAxisLabel("Mole Fraction, x_1");
    //      chart.setYAxisLabel("ln gamma, gE/RT");
    //      chart.setSource(getTitle());
    //      chart.setLegendPosition(LegendPosition.BOTTOM);
    //      chart.setShapesVisible(true);

    JFreeChart chart = ChartFactory.createXYLineChart(null, "Mole Fraction, x_1", "ln gamma, gE/RT", null,
            PlotOrientation.VERTICAL, true, true, false);
    plot = (XYPlot) chart.getPlot();
    plot.getDomainAxis().setAutoRange(false);
    plot.getDomainAxis().setRange(new Range(0.0, 1.0));

    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) plot.getRenderer();
    r.setUseFillPaint(true);
    r.setBaseFillPaint(Color.white);
    r.setBaseShapesVisible(true);

    JFreeChart sigmaProfileChart = ChartFactory.createXYLineChart(null, "sigma", "P^x", null,
            PlotOrientation.VERTICAL, true, true, false);
    sigmaProfilePlot = sigmaProfileChart.getXYPlot();
    sigmaProfilePlot.getDomainAxis().setAutoRange(false);
    sigmaProfilePlot.getDomainAxis().setRange(new Range(-0.025, 0.025));

    //      sigmaProfilePlot.setBackgroundPaint(Color.lightGray);
    //      sigmaProfilePlot.setDomainGridlinePaint(Color.white);
    //      sigmaProfilePlot.setRangeGridlinePaint(Color.white);

    JFreeChart chartSegGamma = ChartFactory.createXYLineChart(null, "sigma", "Segment Gamma", null,
            PlotOrientation.VERTICAL, true, true, false);
    plotSegGamma = (XYPlot) chartSegGamma.getPlot();

    JPanel south = new JPanel();
    south.setLayout(new FlowLayout());
    south.add(new JLabel("<html>ln &gamma;<sup>&infin;</sup><sub>1</sub>:</html>"));
    south.add(lnGammaInf1Label = new JLabel());
    south.add(new JLabel("<html>ln &gamma;<sup>&infin;</sup><sub>2</sub>:</html>"));
    south.add(lnGammaInf2Label = new JLabel());
    south.add(Box.createHorizontalStrut(20));
    south.add(new JLabel("<html>&gamma;<sup>&infin;</sup><sub>1</sub>:</html>"));
    south.add(gammaInf1Label = new JLabel());
    south.add(new JLabel("<html>&gamma;<sup>&infin;</sup><sub>2</sub>:</html>"));
    south.add(gammaInf2Label = new JLabel());

    JPanel aba1 = new JPanel(new BorderLayout());
    aba1.add(northAba1, BorderLayout.NORTH);
    JPanel chartsPanel = new JPanel(new GridLayout(0, 2));
    aba1.add(chartsPanel, BorderLayout.CENTER);
    chartsPanel.add(new ChartPanel(chart));
    chartsPanel.add(new ChartPanel(chartSegGamma));
    aba1.add(south, BorderLayout.SOUTH);

    JPanel aba2 = new JPanel(new BorderLayout());
    aba2.add(northAba2, BorderLayout.NORTH);
    aba2.add(chartPanel = new ChartPanel(sigmaProfileChart), BorderLayout.CENTER);

    JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.addTab("gamma", aba1);
    tabbedPane.addTab("sigma", aba2);
    add(tabbedPane, BorderLayout.CENTER);

    //      cosmosac.setAEffPrime(6.596176570595075);
    //      cosmosac.setCoord(11.614599507917934);
    //      cosmosac.setVnorm(56.36966406129967);
    //      cosmosac.setAnorm(41.56058649432742);
    //      cosmosac.setCHB(65330.19484947528);
    //      cosmosac.setSigmaHB(0.008292411048046008);

    //Display the window.
    setSize(800, 600);
    setLocationRelativeTo(null);
    modelBox.setSelectedIndex(0);
    setVisible(true);

    // test for a mixture
    //      addList("WATER");
    //      addList("H3O+1");
    //      addList("OH-1");
    //      addList("CL-1");
    //      addList("OXYGEN");
    //      addList("sec-butylamine");
    //      addList("hydrogen-fluoride");
    //      addList("ACETONE");
    //      addList("METHANOL");
    //      addList("ACETONE.opt");
    //      addList("METHANOL.opt");
    //      addList("METHYL-ETHYL-KETONE");
    //      addList("ETHANOL");
    //      addList("N-HEPTANE");
    //      addList("PROPIONIC-ACID");
    //      addList("EMIM");
    //      addList("NTF2");
    //      addList("DCA");
    //      addList("N-OCTANE");
    addList("ETHYLENE CARBONATE");
    addList("BENZENE");
    addList("TOLUENE");
    removeButton.setEnabled(true);
}

From source file:hr.fer.zemris.vhdllab.platform.gui.dialog.save.SaveDialog.java

public SaveDialog(LocalizationSource source, SaveContext context) {
    super(source);
    Validate.notNull(context, "Save variant can't be null");
    // setup label
    JLabel label = new JLabel(getMainMessage(source, context));
    int width = DIALOG_WIDTH - 2 * BORDER;
    int height = LABEL_HEIGHT - 2 * BORDER;
    label.setPreferredSize(new Dimension(width, height));
    label.setBorder(BorderFactory.createEmptyBorder(BORDER, BORDER, BORDER, BORDER));

    // setup check box list
    list = new CheckBoxList();
    width = DIALOG_WIDTH - 2 * BORDER;/*from   ww w  .  j  a v a  2s . c o m*/
    height = 0; // because list is a center component and it doesnt need
    // height
    list.setPreferredSize(new Dimension(width, height));
    list.setBorder(BorderFactory.createEmptyBorder(BORDER, BORDER, BORDER, BORDER));

    // setup select all and deselect all buttons
    JButton selectAll = new JButton(source.getMessage(SELECT_ALL_MESSAGE));
    selectAll.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT));
    selectAll.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            list.setSelectionToAll(true);
        }
    });

    JButton deselectAll = new JButton(source.getMessage(DESELECT_ALL_MESSAGE));
    deselectAll.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT));
    deselectAll.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            list.setSelectionToAll(false);
        }
    });

    Box selectBox = Box.createHorizontalBox();
    selectBox.add(selectAll);
    selectBox.add(Box.createRigidArea(new Dimension(BORDER, BUTTON_HEIGHT)));
    selectBox.add(deselectAll);
    selectBox.setBorder(BorderFactory.createEmptyBorder(0, 0, BORDER, 0));

    // setup ok and cancel buttons
    JButton ok = new JButton(source.getMessage(OK_MESSAGE));
    ok.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT));
    ok.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            closeDialog(new ArrayList<File>());
        }
    });

    JButton cancel = new JButton(source.getMessage(CANCEL_MESSAGE));
    cancel.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT));
    cancel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            closeDialog(null);
        }
    });

    Box actionBox = Box.createHorizontalBox();
    actionBox.add(ok);
    actionBox.add(Box.createRigidArea(new Dimension(BORDER, BUTTON_HEIGHT)));
    actionBox.add(cancel);
    actionBox.setBorder(BorderFactory.createEmptyBorder(BORDER, 0, BORDER, 0));

    JPanel selectPanel = new JPanel(new BorderLayout());
    selectPanel.add(selectBox, BorderLayout.EAST);
    JPanel actionPanel = new JPanel(new BorderLayout());
    actionPanel.add(actionBox, BorderLayout.EAST);

    JCheckBox alwaysSave = new JCheckBox(source.getMessage(ALWAYS_SAVE_MESSAGE));
    alwaysSave.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JCheckBox checkBox = (JCheckBox) e.getSource();
            Preferences preferences = Preferences.userNodeForPackage(SaveDialog.class);
            preferences.putBoolean(SHOULD_AUTO_SAVE, checkBox.isSelected());
        }
    });
    alwaysSave.setSelected(false);
    JPanel alwaysSavePanel = new JPanel(new BorderLayout());
    alwaysSavePanel.add(alwaysSave, BorderLayout.WEST);

    JPanel lowerPanel = new JPanel(new BorderLayout());
    lowerPanel.add(selectPanel, BorderLayout.NORTH);
    lowerPanel.add(alwaysSavePanel, BorderLayout.CENTER);
    lowerPanel.add(actionPanel, BorderLayout.SOUTH);

    this.setLayout(new BorderLayout());
    JPanel messagePanel = new JPanel(new BorderLayout());
    messagePanel.add(label, BorderLayout.NORTH);
    messagePanel.add(list, BorderLayout.CENTER);
    messagePanel.add(lowerPanel, BorderLayout.SOUTH);
    this.getContentPane().add(messagePanel, BorderLayout.CENTER);
    this.getRootPane().setDefaultButton(ok);
    this.setPreferredSize(new Dimension(DIALOG_WIDTH, DIALOG_HEIGHT));
    this.setTitle(getTitle(source, context));
}

From source file:ca.uhn.hl7v2.testpanel.ui.conn.Hl7ConnectionPanelHeader.java

/**
 * Create the panel./*from   w w w . j  a v  a  2 s.  com*/
 */
public Hl7ConnectionPanelHeader() {
    setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "Outbound Message Sender",
            TitledBorder.CENTER, TitledBorder.TOP, null, new Color(0, 0, 0)));
    GridBagLayout gridBagLayout = new GridBagLayout();
    gridBagLayout.columnWidths = new int[] { 138, 0 };
    gridBagLayout.rowHeights = new int[] { 0, 0, 0 };
    gridBagLayout.columnWeights = new double[] { 0.0, 1.0 };
    gridBagLayout.rowWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE };
    setLayout(gridBagLayout);

    myNameBox = new JTextField();
    myNameBox.getDocument().addDocumentListener(new SimpleDocumentListener() {
        @Override
        public void update(DocumentEvent theE) {
            myIgnoreNameChanges = true;
            try {
                myConnection.setNameExplicitly(myNameBox.getText());
            } finally {
                myIgnoreNameChanges = false;
            }
        }
    });

    myRememberAsCheckBox = new JCheckBox("Save With Name:");
    myRememberAsCheckBox
            .setToolTipText("If checked, this connection will be saved for the next time you start TestPanel");
    myRememberAsCheckBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myConnection.setPersistent(myRememberAsCheckBox.isSelected());
            updateRememberAsUi();
        }
    });
    GridBagConstraints gbc_RememberAsCheckBox = new GridBagConstraints();
    gbc_RememberAsCheckBox.insets = new Insets(0, 0, 5, 5);
    gbc_RememberAsCheckBox.gridx = 0;
    gbc_RememberAsCheckBox.gridy = 0;
    add(myRememberAsCheckBox, gbc_RememberAsCheckBox);
    GridBagConstraints gbc_NameBox = new GridBagConstraints();
    gbc_NameBox.insets = new Insets(0, 0, 5, 0);
    gbc_NameBox.fill = GridBagConstraints.HORIZONTAL;
    gbc_NameBox.gridx = 1;
    gbc_NameBox.gridy = 0;
    add(myNameBox, gbc_NameBox);
    myNameBox.setColumns(10);

    JPanel panel_5 = new JPanel();
    GridBagConstraints gbc_panel_5 = new GridBagConstraints();
    gbc_panel_5.anchor = GridBagConstraints.WEST;
    gbc_panel_5.fill = GridBagConstraints.VERTICAL;
    gbc_panel_5.gridx = 1;
    gbc_panel_5.gridy = 1;
    add(panel_5, gbc_panel_5);

    myStartButton = new JButton("Start");
    myStartButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myConnection.start();
        }
    });
    panel_5.add(myStartButton);

    myStopButton = new JButton("Stop");
    myStopButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myConnection.stop();
        }
    });
    panel_5.add(myStopButton);

    myStatusLabel = new JLabel("New label");
    panel_5.add(myStatusLabel);

}

From source file:com.github.alexfalappa.nbspringboot.projects.initializr.BootDependenciesPanel.java

private JCheckBox checkBoxForNode(String group, JsonNode dn) {
    final String name = dn.path("name").asText();
    final String id = dn.path("id").asText();
    final String description = dn.path("description").asText();
    final String versRange = dn.path("versionRange").asText();
    JCheckBox ch = new JCheckBox(name);
    ch.setName(id);/*from  w  w  w.  j a v a 2s.  com*/
    ch.putClientProperty(PROP_VERSION_RANGE, versRange);
    ch.putClientProperty(PROP_DESCRIPTION, description);
    if (!chkBoxesMap.containsKey(group)) {
        chkBoxesMap.put(group, new ArrayList<JCheckBox>());
    }
    chkBoxesMap.get(group).add(ch);
    return ch;
}

From source file:com.intuit.tank.tools.debugger.FindReplaceDialog.java

/**
 * Constructs a new find dialog according to the specified type of dialog requested. The dialog can be either a FIND
 * dialog, either a REPLACE dialog. In both cases, components displayed remain the sames, but the ones specific to
 * replace feature are grayed out./*www  . j  ava2  s.  c  o m*/
 * 
 * @param parent
 *            The window holder
 * @param type
 *            The type of the dialog: FindReplace.FIND or FindReplace.REPLACE
 * @param modal
 *            Displays dialog as a modal window if true
 */

public FindReplaceDialog(AgentDebuggerFrame parent, DialogType type) {
    super(parent, type == DialogType.REPLACE ? "Replace" : "Find", true);
    this.parent = parent;

    cbSearch = new JComboBox();
    cbSearch.setEditable(true);
    cbReplace = new JComboBox();
    cbReplace.setEditable(true);
    KeyHandler handler = new KeyHandler();
    tfSearchEditor = (JTextField) cbSearch.getEditor().getEditorComponent();
    tfSearchEditor.addKeyListener(handler);
    tfReplaceEditor = (JTextField) cbReplace.getEditor().getEditorComponent();
    tfReplaceEditor.addKeyListener(handler);

    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints constraints = new GridBagConstraints();
    getContentPane().setLayout(gridbag);
    ((JPanel) getContentPane()).setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    int gridX = 0;
    int gridY = 0;
    JLabel findLabel = new JLabel("Find");
    buildConstraints(constraints, gridX, gridY, 1, 1, 0, 0);
    constraints.anchor = GridBagConstraints.WEST;
    gridbag.setConstraints(findLabel, constraints);
    getContentPane().add(findLabel);
    gridX++;

    buildConstraints(constraints, gridX, gridY, 1, 1, 100, 0);
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.anchor = GridBagConstraints.CENTER;
    gridbag.setConstraints(cbSearch, constraints);
    getContentPane().add(cbSearch);
    gridX++;

    btnFind = new JButton("Find");
    btnFind.setToolTipText("Find text in scripts");
    btnFind.setMnemonic('F');
    btnFind.addActionListener(this);
    buildConstraints(constraints, gridX, gridY, 1, 1, 0, 0);
    constraints.anchor = GridBagConstraints.CENTER;
    gridbag.setConstraints(btnFind, constraints);
    getContentPane().add(btnFind);
    getRootPane().setDefaultButton(btnFind);
    gridX++;

    btnCancel = new JButton("Cancel");
    btnCancel.setMnemonic('C');
    btnCancel.addActionListener(this);
    buildConstraints(constraints, gridX, gridY, 1, 1, 0, 0);
    constraints.anchor = GridBagConstraints.CENTER;
    gridbag.setConstraints(btnCancel, constraints);
    getContentPane().add(btnCancel);
    gridY++;
    gridX = 0;
    if (type == DialogType.REPLACE) {
        JLabel replaceLabel = new JLabel("Replace");
        buildConstraints(constraints, gridX, gridY, 1, 1, 0, 0);
        constraints.anchor = GridBagConstraints.WEST;
        gridbag.setConstraints(replaceLabel, constraints);
        getContentPane().add(replaceLabel);
        gridX++;

        buildConstraints(constraints, gridX, gridY, 1, 1, 100, 0);
        constraints.fill = GridBagConstraints.HORIZONTAL;
        constraints.anchor = GridBagConstraints.CENTER;
        gridbag.setConstraints(cbReplace, constraints);
        getContentPane().add(cbReplace);
        gridX++;

        btnReplace = new JButton("Replace");
        btnReplace.setToolTipText("REplace in script");
        btnReplace.setMnemonic('R');
        btnReplace.addActionListener(this);
        buildConstraints(constraints, gridX, gridY, 1, 1, 0, 0);
        constraints.anchor = GridBagConstraints.CENTER;
        gridbag.setConstraints(btnReplace, constraints);
        getContentPane().add(btnReplace);
        gridX++;

        btnReplaceAll = new JButton("Replace All");
        btnReplaceAll.addActionListener(this);
        buildConstraints(constraints, gridX, gridY, 1, 1, 0, 0);
        constraints.anchor = GridBagConstraints.CENTER;
        gridbag.setConstraints(btnReplaceAll, constraints);
        getContentPane().add(btnReplaceAll);
        btnReplace.addKeyListener(handler);
        btnReplaceAll.addKeyListener(handler);
        gridY++;
        gridX = 0;
    }

    TitledBorder border = new TitledBorder("Options");
    JPanel panel = new JPanel(new GridLayout(1, 4));
    panel.setBorder(border);
    checkboxWrap = new JCheckBox("Wrap Search");
    panel.add(checkboxWrap);

    checkboxMatchCase = new JCheckBox("Case sensitive");
    panel.add(checkboxMatchCase);

    checkboxRegexp = new JCheckBox("Regular expressions");
    panel.add(checkboxRegexp);

    buildConstraints(constraints, gridX, gridY, 4, 1, 100, 100);
    constraints.anchor = GridBagConstraints.WEST;
    gridbag.setConstraints(panel, constraints);
    getContentPane().add(panel);

    FontMetrics fm = getFontMetrics(getFont());
    cbSearch.setPreferredSize(new Dimension(18 * fm.charWidth('m'), (int) cbSearch.getPreferredSize().height));
    cbReplace
            .setPreferredSize(new Dimension(18 * fm.charWidth('m'), (int) cbReplace.getPreferredSize().height));

    pack();
    // setResizable(false);
    WindowUtil.centerOnParent(this);

    // patch by MJB 8/1/2002
    btnFind.addKeyListener(handler);

    btnCancel.addKeyListener(handler);
    checkboxMatchCase.addKeyListener(handler);
    checkboxRegexp.addKeyListener(handler);

}

From source file:external.jung.demo.RoadEditorDemo.java

/**
 * create an instance of a simple graph with popup controls to create a
 * graph.//w w w . ja  va2 s .  c o m
 *
 */
public RoadEditorDemo() {
    roadGraphHelper = new RoadGraphHelper();
    this.graph = roadGraphHelper.createRoadGraph();
    this.layout = new StaticLayout<Vertex3DInfo, Edge3DInfo>(graph, new Dimension(600, 600));
    this.roadGraphHelper.setLayout(layout);

    vv = new VisualizationViewer<Vertex3DInfo, Edge3DInfo>(layout);
    vv.setBackground(Color.white);

    vv.getRenderContext().setVertexLabelTransformer(
            MapTransformer.<Vertex3DInfo, String>getInstance(LazyMap.<Vertex3DInfo, String>decorate(
                    new HashMap<Vertex3DInfo, String>(), new ToStringLabeller<Vertex3DInfo>())));
    vv.getRenderContext().setEdgeLabelTransformer(
            MapTransformer.<Edge3DInfo, String>getInstance(LazyMap.<Edge3DInfo, String>decorate(
                    new HashMap<Edge3DInfo, String>(), new ToStringLabeller<Edge3DInfo>())));
    vv.setVertexToolTipTransformer(vv.getRenderContext().getVertexLabelTransformer());
    vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line<Vertex3DInfo, Edge3DInfo>());

    Container content = getContentPane();
    final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
    content.add(panel);

    final EditingModalGraphMouse<Vertex3DInfo, Edge3DInfo> graphMouse = new EditingModalGraphMouse<Vertex3DInfo, Edge3DInfo>(
            vv.getRenderContext(), roadGraphHelper.vertexFactory, roadGraphHelper.edgeFactory);

    // the EditingGraphMouse will pass mouse event coordinates to the
    // vertexLocations function to set the locations of the vertices as
    // they are created
    //        graphMouse.setVertexLocations(vertexLocations);
    vv.setGraphMouse(graphMouse);
    vv.addKeyListener(graphMouse.getModeKeyListener());

    graphMouse.setMode(ModalGraphMouse.Mode.EDITING);

    final ScalingControl scaler = new CrossoverScalingControl();
    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });
    JButton minus = new JButton("-");
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1 / 1.1f, vv.getCenter());
        }
    });

    JButton help = new JButton("Build");
    help.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            //edgeAngle();
            roadGraphHelper.resetExtraDraw();
            roadGraphHelper.vertexIntersect();
            vv.repaint();

        }
    });

    AnnotationControls<Vertex3DInfo, Edge3DInfo> annotationControls = new AnnotationControls<Vertex3DInfo, Edge3DInfo>(
            graphMouse.getAnnotatingPlugin());
    JPanel controls = new JPanel();
    controls.add(plus);
    controls.add(minus);
    JComboBox modeBox = graphMouse.getModeComboBox();
    controls.add(modeBox);
    controls.add(annotationControls.getAnnotationsToolBar());
    controls.add(help);

    JSlider slider2 = new JSlider();
    slider2.setBorder(BorderFactory.createTitledBorder("Size"));
    slider2.setMajorTickSpacing(20);
    slider2.setMinorTickSpacing(5);
    slider2.setPaintTicks(true);
    controls.add(slider2);
    slider2.addChangeListener(new SliderListener());

    JPanel checkBoxes = new JPanel();
    //checkBoxes.setLayout(new GridLayout(1, 5));
    layer1Check = new JCheckBox("Layer1");
    layer1Check.setSelected(true);

    layer2Check = new JCheckBox("Layer2");
    layer2Check.setSelected(true);

    layer3Check = new JCheckBox("Layer3");
    layer3Check.setSelected(true);

    layer4Check = new JCheckBox("Layer4");
    layer4Check.setSelected(true);
    layer5Check = new JCheckBox("Layer5");
    layer5Check.setSelected(true);
    checkBoxes.add(layer1Check);
    checkBoxes.add(layer2Check);
    checkBoxes.add(layer3Check);
    checkBoxes.add(layer4Check);
    checkBoxes.add(layer5Check);
    JPanel twoLine = new JPanel();
    twoLine.setLayout(new GridLayout(2, 1));
    content.add(twoLine, BorderLayout.SOUTH);
    twoLine.add(controls);
    twoLine.add(checkBoxes);
    // 
    vv.addPostRenderPaintable(new PaintRoad());
    vv.addPreRenderPaintable(new PaintRoadUnder());
    vv.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            //edgeAngle();
            roadGraphHelper.resetExtraDraw();
            roadGraphHelper.vertexIntersect();
            vv.repaint();

        }
    });

}

From source file:gov.loc.repository.bagger.ui.SaveBagFrame.java

private JPanel createComponents() {
    Border border = new EmptyBorder(5, 5, 5, 5);

    TitlePane titlePane = new TitlePane();
    initStandardCommands();//from   www.j  ava 2s .  c o  m
    JPanel pageControl = new JPanel(new BorderLayout());
    JPanel titlePaneContainer = new JPanel(new BorderLayout());
    titlePane.setTitle(bagView.getPropertyMessage("SaveBagFrame.title"));
    titlePane.setMessage(new DefaultMessage(bagView.getPropertyMessage("Define the Bag settings")));
    titlePaneContainer.add(titlePane.getControl());
    titlePaneContainer.add(new JSeparator(), BorderLayout.SOUTH);
    pageControl.add(titlePaneContainer, BorderLayout.NORTH);
    JPanel contentPane = new JPanel();

    // TODO: Add bag name field
    // TODO: Add save name file selection button
    JLabel location = new JLabel("Save in:");
    browseButton = new JButton(getMessage("bag.button.browse"));
    browseButton.addActionListener(new SaveBagAsHandler());
    browseButton.setEnabled(true);
    browseButton.setToolTipText(getMessage("bag.button.browse.help"));
    String fileName = "";
    DefaultBag bag = bagView.getBag();
    if (bag != null) {
        fileName = bag.getName();
    }
    bagNameField = new JTextField(fileName);
    bagNameField.setCaretPosition(fileName.length());
    bagNameField.setEditable(false);
    bagNameField.setEnabled(false);

    // Holey bag control
    JLabel holeyLabel = new JLabel(bagView.getPropertyMessage("bag.label.isholey"));
    holeyLabel.setToolTipText(bagView.getPropertyMessage("bag.isholey.help"));
    holeyCheckbox = new JCheckBox(bagView.getPropertyMessage("bag.checkbox.isholey"));
    holeyCheckbox.setBorder(border);
    holeyCheckbox.setSelected(bag.isHoley());
    holeyCheckbox.addActionListener(new HoleyBagHandler());
    holeyCheckbox.setToolTipText(bagView.getPropertyMessage("bag.isholey.help"));

    urlLabel = new JLabel(bagView.getPropertyMessage("baseURL.label"));
    urlLabel.setToolTipText(bagView.getPropertyMessage("baseURL.description"));
    urlLabel.setEnabled(bag.isHoley());
    urlField = new JTextField("");
    try {
        urlField.setText(bag.getFetch().getBaseURL());
    } catch (Exception e) {
        log.error("fetch baseURL: " + e.getMessage());
    }
    urlField.setEnabled(false);

    // TODO: Add format label
    JLabel serializeLabel;
    serializeLabel = new JLabel(getMessage("bag.label.ispackage"));
    serializeLabel.setToolTipText(getMessage("bag.serializetype.help"));

    // TODO: Add format selection panel
    noneButton = new JRadioButton(getMessage("bag.serializetype.none"));
    noneButton.setEnabled(true);
    AbstractAction serializeListener = new SerializeBagHandler();
    noneButton.addActionListener(serializeListener);
    noneButton.setToolTipText(getMessage("bag.serializetype.none.help"));

    zipButton = new JRadioButton(getMessage("bag.serializetype.zip"));
    zipButton.setEnabled(true);
    zipButton.addActionListener(serializeListener);
    zipButton.setToolTipText(getMessage("bag.serializetype.zip.help"));

    /*
    tarButton = new JRadioButton(getMessage("bag.serializetype.tar"));
    tarButton.setEnabled(true);
    tarButton.addActionListener(serializeListener);
    tarButton.setToolTipText(getMessage("bag.serializetype.tar.help"));
            
    tarGzButton = new JRadioButton(getMessage("bag.serializetype.targz"));
    tarGzButton.setEnabled(true);
    tarGzButton.addActionListener(serializeListener);
    tarGzButton.setToolTipText(getMessage("bag.serializetype.targz.help"));
            
    tarBz2Button = new JRadioButton(getMessage("bag.serializetype.tarbz2"));
    tarBz2Button.setEnabled(true);
    tarBz2Button.addActionListener(serializeListener);
    tarBz2Button.setToolTipText(getMessage("bag.serializetype.tarbz2.help"));
    */

    short mode = bag.getSerialMode();
    if (mode == DefaultBag.NO_MODE) {
        this.noneButton.setEnabled(true);
    } else if (mode == DefaultBag.ZIP_MODE) {
        this.zipButton.setEnabled(true);
    } /*else if (mode == DefaultBag.TAR_MODE) {
       this.tarButton.setEnabled(true);
      } else if (mode == DefaultBag.TAR_GZ_MODE) {
       this.tarGzButton.setEnabled(true);
      } else if (mode == DefaultBag.TAR_BZ2_MODE) {
       this.tarBz2Button.setEnabled(true);
      } */else {
        this.noneButton.setEnabled(true);
    }

    ButtonGroup serializeGroup = new ButtonGroup();
    serializeGroup.add(noneButton);
    serializeGroup.add(zipButton);
    //serializeGroup.add(tarButton);
    //serializeGroup.add(tarGzButton);
    //serializeGroup.add(tarBz2Button);
    serializeGroupPanel = new JPanel(new FlowLayout());
    serializeGroupPanel.add(serializeLabel);
    serializeGroupPanel.add(noneButton);
    serializeGroupPanel.add(zipButton);
    //serializeGroupPanel.add(tarButton);
    //serializeGroupPanel.add(tarGzButton);
    //serializeGroupPanel.add(tarBz2Button);
    serializeGroupPanel.setBorder(border);
    serializeGroupPanel.setEnabled(true);
    serializeGroupPanel.setToolTipText(bagView.getPropertyMessage("bag.serializetype.help"));

    JLabel tagLabel = new JLabel(getMessage("bag.label.istag"));
    tagLabel.setToolTipText(getMessage("bag.label.istag.help"));
    isTagCheckbox = new JCheckBox();
    isTagCheckbox.setBorder(border);
    isTagCheckbox.setSelected(bag.isBuildTagManifest());
    isTagCheckbox.addActionListener(new TagManifestHandler());
    isTagCheckbox.setToolTipText(getMessage("bag.checkbox.istag.help"));

    JLabel tagAlgorithmLabel = new JLabel(getMessage("bag.label.tagalgorithm"));
    tagAlgorithmLabel.setToolTipText(getMessage("bag.label.tagalgorithm.help"));
    ArrayList<String> listModel = new ArrayList<String>();
    for (Algorithm algorithm : Algorithm.values()) {
        listModel.add(algorithm.bagItAlgorithm);
    }
    tagAlgorithmList = new JComboBox(listModel.toArray());
    tagAlgorithmList.setName(getMessage("bag.tagalgorithmlist"));
    tagAlgorithmList.setSelectedItem(bag.getTagManifestAlgorithm());
    tagAlgorithmList.addActionListener(new TagAlgorithmListHandler());
    tagAlgorithmList.setToolTipText(getMessage("bag.tagalgorithmlist.help"));

    JLabel payloadLabel = new JLabel(getMessage("bag.label.ispayload"));
    payloadLabel.setToolTipText(getMessage("bag.ispayload.help"));
    isPayloadCheckbox = new JCheckBox();
    isPayloadCheckbox.setBorder(border);
    isPayloadCheckbox.setSelected(bag.isBuildPayloadManifest());
    isPayloadCheckbox.addActionListener(new PayloadManifestHandler());
    isPayloadCheckbox.setToolTipText(getMessage("bag.ispayload.help"));

    JLabel payAlgorithmLabel = new JLabel(bagView.getPropertyMessage("bag.label.payalgorithm"));
    payAlgorithmLabel.setToolTipText(getMessage("bag.payalgorithm.help"));
    payAlgorithmList = new JComboBox(listModel.toArray());
    payAlgorithmList.setName(getMessage("bag.payalgorithmlist"));
    payAlgorithmList.setSelectedItem(bag.getPayloadManifestAlgorithm());
    payAlgorithmList.addActionListener(new PayAlgorithmListHandler());
    payAlgorithmList.setToolTipText(getMessage("bag.payalgorithmlist.help"));

    GridBagLayout layout = new GridBagLayout();
    GridBagConstraints glbc = new GridBagConstraints();
    JPanel panel = new JPanel(layout);
    panel.setBorder(new EmptyBorder(10, 10, 10, 10));

    int row = 0;

    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(location, glbc);
    panel.add(location);

    buildConstraints(glbc, 2, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.EAST);
    glbc.ipadx = 5;
    layout.setConstraints(browseButton, glbc);
    glbc.ipadx = 0;
    panel.add(browseButton);

    buildConstraints(glbc, 1, row, 1, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST);
    glbc.ipadx = 5;
    layout.setConstraints(bagNameField, glbc);
    glbc.ipadx = 0;
    panel.add(bagNameField);

    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(holeyLabel, glbc);
    panel.add(holeyLabel);
    buildConstraints(glbc, 1, row, 1, 1, 80, 50, GridBagConstraints.WEST, GridBagConstraints.WEST);
    layout.setConstraints(holeyCheckbox, glbc);
    panel.add(holeyCheckbox);
    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(urlLabel, glbc);
    panel.add(urlLabel);
    buildConstraints(glbc, 1, row, 1, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER);
    layout.setConstraints(urlField, glbc);
    panel.add(urlField);
    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(serializeLabel, glbc);
    panel.add(serializeLabel);
    buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST);
    layout.setConstraints(serializeGroupPanel, glbc);
    panel.add(serializeGroupPanel);
    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(tagLabel, glbc);
    panel.add(tagLabel);
    buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER);
    layout.setConstraints(isTagCheckbox, glbc);
    panel.add(isTagCheckbox);
    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(tagAlgorithmLabel, glbc);
    panel.add(tagAlgorithmLabel);
    buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER);
    layout.setConstraints(tagAlgorithmList, glbc);
    panel.add(tagAlgorithmList);
    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(payloadLabel, glbc);
    panel.add(payloadLabel);
    buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER);
    layout.setConstraints(isPayloadCheckbox, glbc);
    panel.add(isPayloadCheckbox);
    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(payAlgorithmLabel, glbc);
    panel.add(payAlgorithmLabel);
    buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER);
    layout.setConstraints(payAlgorithmList, glbc);
    panel.add(payAlgorithmList);
    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER);

    GuiStandardUtils.attachDialogBorder(contentPane);
    pageControl.add(panel);
    JComponent buttonBar = createButtonBar();
    pageControl.add(buttonBar, BorderLayout.SOUTH);

    this.pack();
    return pageControl;

}

From source file:com.surenpi.autotest.suite.SuiteRunnerLauncher.java

/**
 * @param centerPanel//from   www  .  ja  v a 2  s. c o  m
 * @param urlList
 */
private static void createItemsPanel(JPanel centerPanel, List<URL> urlList) {
    JPanel itemsPanel = new JPanel();
    centerPanel.add(itemsPanel, BorderLayout.CENTER);

    if (CollectionUtils.isEmpty(urlList)) {
        return;
    }

    for (URL url : urlList) {
        String text = url.getFile();
        JCheckBox box = new JCheckBox(new File(text).getName());
        box.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                JCheckBox source = (JCheckBox) e.getSource();
                if (source.isSelected()) {
                    runnerList.add(source.getText());
                } else {
                    runnerList.remove(source.getText());
                }
            }
        });

        itemsPanel.add(box);
    }
}

From source file:it.cnr.icar.eric.client.ui.swing.BusinessQueryPanel.java

/**
 * Class Constructor.//from  w  w  w . j a v a  2s  . c  o  m
 */
public BusinessQueryPanel(final FindParamsPanel findParamsPanel, ConfigurationType uiConfigurationType)
        throws JAXRException {
    super(findParamsPanel, uiConfigurationType);

    GridBagLayout gbl = new GridBagLayout();
    setLayout(gbl);

    objectTypeLabel = new JLabel(resourceBundle.getString("title.objectType"), SwingConstants.LEADING);

    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(objectTypeLabel, c);
    add(objectTypeLabel);

    //TODO: SwingBoost: Localize this
    TreeNode tempTreeNode = new DefaultMutableTreeNode("loading object types...");
    objectTypeCombo = new it.cnr.icar.eric.client.ui.swing.TreeCombo(new DefaultTreeModel(tempTreeNode));

    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 4, 4);
    gbl.setConstraints(objectTypeCombo, c);
    add(objectTypeCombo);
    objectTypeCombo.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent ev) {
            if (ev.getStateChange() == ItemEvent.DESELECTED) {
                return;
            }

            @SuppressWarnings("unused")
            String objectType = getObjectType().toString();
        }
    });

    //The caseSensitive CheckBox
    caseSensitiveCheckBox = new JCheckBox(resourceBundle.getString("title.caseSensitiveSearch"));
    caseSensitiveCheckBox.setSelected(false);
    caseSensitiveCheckBox.setEnabled(true);
    c.gridx = 0;
    c.gridy = 2;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(caseSensitiveCheckBox, c);
    add(caseSensitiveCheckBox);

    //The name Text
    nameLabel = new JLabel(resourceBundle.getString("title.name"), SwingConstants.LEADING);
    c.gridx = 0;
    c.gridy = 3;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(nameLabel, c);
    add(nameLabel);

    nameText = new JTextField();
    c.gridx = 0;
    c.gridy = 4;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 4, 4);
    gbl.setConstraints(nameText, c);
    add(nameText);

    nameText.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            findParamsPanel.find();
        }
    });

    //The description text
    descLabel = new JLabel(resourceBundle.getString("title.description"), SwingConstants.LEADING);
    c.gridx = 0;
    c.gridy = 5;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(descLabel, c);
    add(descLabel);

    descText = new JTextField();
    c.gridx = 0;
    c.gridy = 6;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 4, 4);
    gbl.setConstraints(descText, c);
    add(descText);

    descText.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            findParamsPanel.find();
        }
    });

    //Classifications
    classificationsLabel = new JLabel(resourceBundle.getString("title.classifications"),
            SwingConstants.LEADING);
    c.gridx = 0;
    c.gridy = 7;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(classificationsLabel, c);
    add(classificationsLabel);

    classificationsList = new ClassificationsList();
    classificationsList.setEditable(true);
    classificationsList.setVisibleRowCount(3);

    JScrollPane classificationsListScrollPane = new JScrollPane(classificationsList);

    //Workaround for bug 740746 where very wide item resulted in too short a height
    classificationsListScrollPane.setMinimumSize(new Dimension(-1, 50));

    c.gridx = 0;
    c.gridy = 8;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 4, 4);
    gbl.setConstraints(classificationsListScrollPane, c);
    add(classificationsListScrollPane);

    //Identifiers
    identifiersLabel = new JLabel(resourceBundle.getString("title.externalIdentifiers"),
            SwingConstants.LEADING);
    c.gridx = 0;
    c.gridy = 9;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(identifiersLabel, c);
    add(identifiersLabel);

    extIdsList = new ExternalIdentifiersList();
    extIdsList.setEditable(true);
    extIdsList.setVisibleRowCount(3);

    JScrollPane extIdsListScrollPane = new JScrollPane(extIdsList);

    //Workaround for bug 740746 where very wide item resulted in too short a height
    extIdsListScrollPane.setMinimumSize(new Dimension(-1, 50));

    c.gridx = 0;
    c.gridy = 10;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 4, 4);
    gbl.setConstraints(extIdsListScrollPane, c);
    add(extIdsListScrollPane);

    //External Links
    linksLabel = new JLabel(resourceBundle.getString("title.externalLinks"), SwingConstants.TRAILING);
    c.gridx = 0;
    c.gridy = 11;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(linksLabel, c);
    add(linksLabel);

    linksList = new ExternalLinksList();
    linksList.setEditable(true);
    linksList.setVisibleRowCount(3);

    JScrollPane linksListScrollPane = new JScrollPane(linksList);

    //Workaround for bug 740746 where very wide item resulted in too short a height
    linksListScrollPane.setMinimumSize(new Dimension(-1, 50));

    c.gridx = 0;
    c.gridy = 12;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 4, 4);
    gbl.setConstraints(linksListScrollPane, c);
    add(linksListScrollPane);

    //add listener for 'locale' bound property
    RegistryBrowser.getInstance().addPropertyChangeListener(RegistryBrowser.PROPERTY_LOCALE, this);
}

From source file:EdgeLabelDemo.java

/**
 * create an instance of a simple graph with controls to
 * demo the label positioning features/*www .  j a v a2  s .c  o  m*/
 * 
 */
@SuppressWarnings("serial")
public EdgeLabelDemo() {

    // create a simple graph for the demo
    graph = new SparseMultigraph<Integer, Number>();
    Integer[] v = createVertices(3);
    createEdges(v);

    Layout<Integer, Number> layout = new CircleLayout<Integer, Number>(graph);
    vv = new VisualizationViewer<Integer, Number>(layout, new Dimension(600, 400));
    vv.setBackground(Color.white);

    vertexLabelRenderer = vv.getRenderContext().getVertexLabelRenderer();
    edgeLabelRenderer = vv.getRenderContext().getEdgeLabelRenderer();

    Transformer<Number, String> stringer = new Transformer<Number, String>() {
        public String transform(Number e) {
            return "Edge:" + graph.getEndpoints(e).toString();
        }
    };
    vv.getRenderContext().setEdgeLabelTransformer(stringer);
    vv.getRenderContext().setEdgeDrawPaintTransformer(
            new PickableEdgePaintTransformer<Number>(vv.getPickedEdgeState(), Color.black, Color.cyan));
    vv.getRenderContext().setVertexFillPaintTransformer(
            new PickableVertexPaintTransformer<Integer>(vv.getPickedVertexState(), Color.red, Color.yellow));
    // add my listener for ToolTips
    vv.setVertexToolTipTransformer(new ToStringLabeller<Integer>());

    // create a frome to hold the graph
    final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
    Container content = getContentPane();
    content.add(panel);

    final DefaultModalGraphMouse<Integer, Number> graphMouse = new DefaultModalGraphMouse<Integer, Number>();
    vv.setGraphMouse(graphMouse);

    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });
    JButton minus = new JButton("-");
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1 / 1.1f, vv.getCenter());
        }
    });

    ButtonGroup radio = new ButtonGroup();
    JRadioButton lineButton = new JRadioButton("Line");
    lineButton.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line<Integer, Number>());
                vv.repaint();
            }
        }
    });

    JRadioButton quadButton = new JRadioButton("QuadCurve");
    quadButton.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.QuadCurve<Integer, Number>());
                vv.repaint();
            }
        }
    });

    JRadioButton cubicButton = new JRadioButton("CubicCurve");
    cubicButton.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.CubicCurve<Integer, Number>());
                vv.repaint();
            }
        }
    });
    radio.add(lineButton);
    radio.add(quadButton);
    radio.add(cubicButton);

    graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING);

    JCheckBox rotate = new JCheckBox("<html><center>EdgeType<p>Parallel</center></html>");
    rotate.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            AbstractButton b = (AbstractButton) e.getSource();
            edgeLabelRenderer.setRotateEdgeLabels(b.isSelected());
            vv.repaint();
        }
    });
    rotate.setSelected(true);
    MutableDirectionalEdgeValue mv = new MutableDirectionalEdgeValue(.5, .7);
    vv.getRenderContext().setEdgeLabelClosenessTransformer(mv);
    JSlider directedSlider = new JSlider(mv.getDirectedModel()) {
        public Dimension getPreferredSize() {
            Dimension d = super.getPreferredSize();
            d.width /= 2;
            return d;
        }
    };
    JSlider undirectedSlider = new JSlider(mv.getUndirectedModel()) {
        public Dimension getPreferredSize() {
            Dimension d = super.getPreferredSize();
            d.width /= 2;
            return d;
        }
    };

    JSlider edgeOffsetSlider = new JSlider(0, 50) {
        public Dimension getPreferredSize() {
            Dimension d = super.getPreferredSize();
            d.width /= 2;
            return d;
        }
    };
    edgeOffsetSlider.addChangeListener(new ChangeListener() {

        public void stateChanged(ChangeEvent e) {
            JSlider s = (JSlider) e.getSource();
            AbstractEdgeShapeTransformer<Integer, Number> aesf = (AbstractEdgeShapeTransformer<Integer, Number>) vv
                    .getRenderContext().getEdgeShapeTransformer();
            aesf.setControlOffsetIncrement(s.getValue());
            vv.repaint();
        }

    });

    Box controls = Box.createHorizontalBox();

    JPanel zoomPanel = new JPanel(new GridLayout(0, 1));
    zoomPanel.setBorder(BorderFactory.createTitledBorder("Scale"));
    zoomPanel.add(plus);
    zoomPanel.add(minus);

    JPanel edgePanel = new JPanel(new GridLayout(0, 1));
    edgePanel.setBorder(BorderFactory.createTitledBorder("EdgeType Type"));
    edgePanel.add(lineButton);
    edgePanel.add(quadButton);
    edgePanel.add(cubicButton);

    JPanel rotatePanel = new JPanel();
    rotatePanel.setBorder(BorderFactory.createTitledBorder("Alignment"));
    rotatePanel.add(rotate);

    JPanel labelPanel = new JPanel(new BorderLayout());
    JPanel sliderPanel = new JPanel(new GridLayout(3, 1));
    JPanel sliderLabelPanel = new JPanel(new GridLayout(3, 1));
    JPanel offsetPanel = new JPanel(new BorderLayout());
    offsetPanel.setBorder(BorderFactory.createTitledBorder("Offset"));
    sliderPanel.add(directedSlider);
    sliderPanel.add(undirectedSlider);
    sliderPanel.add(edgeOffsetSlider);
    sliderLabelPanel.add(new JLabel("Directed", JLabel.RIGHT));
    sliderLabelPanel.add(new JLabel("Undirected", JLabel.RIGHT));
    sliderLabelPanel.add(new JLabel("Edges", JLabel.RIGHT));
    offsetPanel.add(sliderLabelPanel, BorderLayout.WEST);
    offsetPanel.add(sliderPanel);
    labelPanel.add(offsetPanel);
    labelPanel.add(rotatePanel, BorderLayout.WEST);

    JPanel modePanel = new JPanel(new GridLayout(2, 1));
    modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode"));
    modePanel.add(graphMouse.getModeComboBox());

    controls.add(zoomPanel);
    controls.add(edgePanel);
    controls.add(labelPanel);
    controls.add(modePanel);
    content.add(controls, BorderLayout.SOUTH);
    quadButton.setSelected(true);
}