Example usage for javax.swing JButton setToolTipText

List of usage examples for javax.swing JButton setToolTipText

Introduction

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

Prototype

@BeanProperty(bound = false, preferred = true, description = "The text to display in a tool tip.")
public void setToolTipText(String text) 

Source Link

Document

Registers the text to display in a tool tip.

Usage

From source file:jchrest.gui.VisualSearchPane.java

private JPanel constructButtons() {

    Box buttons = Box.createVerticalBox();
    JSpinner numFixations = new JSpinner(new SpinnerNumberModel(20, 1, 1000, 1));

    JPanel labelledSpinner = new JPanel();
    labelledSpinner.setLayout(new GridLayout(1, 2));
    labelledSpinner.add(new JLabel("Number of fixations: "));
    labelledSpinner.add(numFixations);//from w  ww. j a v a2 s  .c  om

    JButton recallButton = new JButton(new RecallAction(numFixations));
    recallButton.setToolTipText("Scan shown scene and display results");

    final JCheckBox showFixations = new JCheckBox("Show fixations", false);
    showFixations.setToolTipText("Show fixations for recalled scene");
    showFixations.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            _sceneDisplay.setShowFixations(showFixations.isSelected());
        }
    });

    buttons.add(Box.createRigidArea(new Dimension(0, 20)));
    buttons.add(labelledSpinner);
    buttons.add(recallButton);
    buttons.add(Box.createRigidArea(new Dimension(0, 20)));
    buttons.add(showFixations);
    buttons.add(Box.createRigidArea(new Dimension(0, 20)));

    // TODO: There must be a better solution to this problem!
    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.add(buttons, BorderLayout.NORTH);

    return panel;
}

From source file:davmail.ui.SettingsFrame.java

protected JPanel getLoggingSettingsPanel() {
    JPanel loggingLevelPanel = new JPanel();
    JPanel leftLoggingPanel = new JPanel(new GridLayout(2, 2));
    JPanel rightLoggingPanel = new JPanel(new GridLayout(2, 2));
    loggingLevelPanel.add(leftLoggingPanel);
    loggingLevelPanel.add(rightLoggingPanel);

    rootLoggingLevelField = new JComboBox(LOG_LEVELS);
    davmailLoggingLevelField = new JComboBox(LOG_LEVELS);
    httpclientLoggingLevelField = new JComboBox(LOG_LEVELS);
    wireLoggingLevelField = new JComboBox(LOG_LEVELS);
    logFilePathField = new JTextField(Settings.getProperty("davmail.logFilePath"), 15);
    logFileSizeField = new JTextField(Settings.getProperty("davmail.logFileSize"), 15);

    rootLoggingLevelField.setSelectedItem(Settings.getLoggingLevel("rootLogger"));
    davmailLoggingLevelField.setSelectedItem(Settings.getLoggingLevel("davmail"));
    httpclientLoggingLevelField.setSelectedItem(Settings.getLoggingLevel("org.apache.commons.httpclient"));
    wireLoggingLevelField.setSelectedItem(Settings.getLoggingLevel("httpclient.wire"));

    addSettingComponent(leftLoggingPanel, BundleMessage.format("UI_LOG_DEFAULT"), rootLoggingLevelField);
    addSettingComponent(leftLoggingPanel, BundleMessage.format("UI_LOG_DAVMAIL"), davmailLoggingLevelField);
    addSettingComponent(rightLoggingPanel, BundleMessage.format("UI_LOG_HTTPCLIENT"),
            httpclientLoggingLevelField);
    addSettingComponent(rightLoggingPanel, BundleMessage.format("UI_LOG_WIRE"), wireLoggingLevelField);

    JPanel logFilePathPanel = new JPanel(new GridLayout(2, 2));
    addSettingComponent(logFilePathPanel, BundleMessage.format("UI_LOG_FILE_PATH"), logFilePathField);
    addSettingComponent(logFilePathPanel, BundleMessage.format("UI_LOG_FILE_SIZE"), logFileSizeField);

    JButton defaultButton = new JButton(BundleMessage.format("UI_BUTTON_DEFAULT"));
    defaultButton.setToolTipText(BundleMessage.format("UI_BUTTON_DEFAULT_HELP"));
    defaultButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            rootLoggingLevelField.setSelectedItem(Level.WARN);
            davmailLoggingLevelField.setSelectedItem(Level.DEBUG);
            httpclientLoggingLevelField.setSelectedItem(Level.WARN);
            wireLoggingLevelField.setSelectedItem(Level.WARN);
        }/* w  ww  .ja  va  2s.  c  o  m*/
    });

    JPanel loggingPanel = new JPanel();
    loggingPanel.setLayout(new BoxLayout(loggingPanel, BoxLayout.Y_AXIS));
    loggingPanel.setBorder(BorderFactory.createTitledBorder(BundleMessage.format("UI_LOGGING_LEVELS")));
    loggingPanel.add(logFilePathPanel);
    loggingPanel.add(loggingLevelPanel);
    loggingPanel.add(defaultButton);

    updateMaximumSize(loggingPanel);
    return loggingPanel;
}

From source file:com.rapidminer.gui.graphs.GraphViewer.java

private JComponent createControlPanel() {
    // === mouse behaviour ===
    if (graphMouse != null) {
        vv.setGraphMouse(graphMouse);/*from   w  ww  . jav a  2 s  . c  o  m*/
        vv.addKeyListener(graphMouse.getModeKeyListener());
        graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING);
    }
    transformAction.setEnabled(false);
    pickingAction.setEnabled(true);

    vv.addGraphMouseListener(new GraphMouseListener<V>() {

        @Override
        public void graphClicked(V vertex, MouseEvent arg1) {
        }

        @Override
        public void graphPressed(V arg0, MouseEvent arg1) {
        }

        @Override
        public void graphReleased(V vertex, MouseEvent arg1) {
            if (currentMode.equals(ModalGraphMouse.Mode.TRANSFORMING)) {
                if (graphCreator.getObjectViewer() != null) {
                    vv.getPickedVertexState().clear();
                    vv.getPickedVertexState().pick(vertex, true);
                    graphCreator.getObjectViewer().showObject(graphCreator.getObject(vertex));
                }
            }
        }
    });

    JPanel controls = new JPanel();
    GridBagLayout gbLayout = new GridBagLayout();
    controls.setLayout(gbLayout);
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.insets = new Insets(4, 4, 4, 4);
    c.weightx = 1;
    c.weighty = 0;

    // zooming
    JToolBar zoomBar = new ExtendedJToolBar();
    zoomBar.setLayout(new FlowLayout(FlowLayout.CENTER));
    zoomBar.add(new ZoomInAction(this, IconSize.SMALL));
    zoomBar.add(new ZoomOutAction(this, IconSize.SMALL));
    zoomBar.setBorder(BorderFactory.createTitledBorder("Zoom"));
    c.gridwidth = GridBagConstraints.REMAINDER;
    gbLayout.setConstraints(zoomBar, c);
    controls.add(zoomBar);

    // mode
    JToolBar modeBar = new ExtendedJToolBar();
    modeBar.setLayout(new FlowLayout(FlowLayout.CENTER));
    modeBar.add(transformAction);
    modeBar.add(pickingAction);
    modeBar.setBorder(BorderFactory.createTitledBorder("Mode"));
    c.gridwidth = GridBagConstraints.REMAINDER;
    gbLayout.setConstraints(modeBar, c);
    controls.add(modeBar);

    // layout selection
    c.gridwidth = GridBagConstraints.REMAINDER;
    gbLayout.setConstraints(layoutSelection, c);
    controls.add(layoutSelection);

    // show node labels
    JCheckBox nodeLabels = new JCheckBox("Node Labels", graphCreator.showVertexLabelsDefault());
    nodeLabels.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            togglePaintVertexLabels();
        }
    });
    c.gridwidth = GridBagConstraints.REMAINDER;
    gbLayout.setConstraints(nodeLabels, c);
    controls.add(nodeLabels);

    // show edge labels
    JCheckBox edgeLabels = new JCheckBox("Edge Labels", graphCreator.showEdgeLabelsDefault());
    edgeLabels.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            togglePaintEdgeLabels();
        }
    });
    c.gridwidth = GridBagConstraints.REMAINDER;
    gbLayout.setConstraints(edgeLabels, c);
    controls.add(edgeLabels);

    // option components
    for (int i = 0; i < graphCreator.getNumberOfOptionComponents(); i++) {
        JComponent optionComponent = graphCreator.getOptionComponent(this, i);
        if (optionComponent != null) {
            c.gridwidth = GridBagConstraints.REMAINDER;
            gbLayout.setConstraints(optionComponent, c);
            controls.add(optionComponent);
        }
    }

    // save image
    JButton imageButton = new JButton("Save Image...");
    imageButton.setToolTipText("Saves an image of the current graph.");
    imageButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final Component tosave = vv;
            new ExportImageAction(false) {

                private static final long serialVersionUID = 1L;

                @Override
                protected PrintableComponent getPrintableComponent() {
                    return new SimplePrintableComponent(tosave, "Graph");
                }

            }.actionPerformed(e);
        }
    });
    c.gridwidth = GridBagConstraints.REMAINDER;
    gbLayout.setConstraints(imageButton, c);
    controls.add(imageButton);

    // help
    JButton help = new JButton("Help");
    help.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            JOptionPane.showMessageDialog(vv, INSTRUCTIONS);
        }
    });
    c.gridwidth = GridBagConstraints.REMAINDER;
    gbLayout.setConstraints(help, c);
    controls.add(help);

    JPanel fillPanel = new JPanel();
    c.weighty = 1.0d;
    c.gridwidth = GridBagConstraints.REMAINDER;
    gbLayout.setConstraints(fillPanel, c);
    controls.add(fillPanel);

    return controls;
}

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

void buildManipulators() {
    JButton removeButton = new JButton(I_CLOSE);
    removeButton.setPressedIcon(I_CLOSE_PRESSED);
    removeButton.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));//4,4,4,4));
    removeButton.setBorderPainted(false);
    removeButton.setContentAreaFilled(false);
    removeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (JOptionPane.showOptionDialog(null, "Remove the Series " + getSeriesName() + "?", "Confirm",
                    JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null,
                    new Object[] { "Remove", "Cancel" }, null) == 0) // remove
                getGenerator().removeSeries(getSeriesIndex());
        }/* w  w  w  .j a v  a 2s  .  co  m*/
    });
    removeButton.setToolTipText("Remove this series");

    JButton upButton = new JButton(I_UP);
    upButton.setPressedIcon(I_UP_PRESSED);
    upButton.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));//4,4,4,4));
    upButton.setBorderPainted(false);
    upButton.setContentAreaFilled(false);
    upButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            getGenerator().moveSeries(getSeriesIndex(), true);
        }
    });
    upButton.setToolTipText("Draw this series higher in the series order");

    JButton downButton = new JButton(I_DOWN);
    downButton.setPressedIcon(I_DOWN_PRESSED);
    downButton.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));//4,4,4,4));
    downButton.setBorderPainted(false);
    downButton.setContentAreaFilled(false);
    downButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            getGenerator().moveSeries(getSeriesIndex(), false);
        }
    });
    downButton.setToolTipText("Draw this series lower in the series order");

    manipulators.add(removeButton);
    manipulators.add(upButton);
    manipulators.add(downButton);
}

From source file:cool.pandora.modeller.ui.jpanel.base.SaveBagFrame.java

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

    final TitlePane titlePane = new TitlePane();
    initStandardCommands();/*from  w  w w  . j  a va2  s .  c o m*/
    final JPanel pageControl = new JPanel(new BorderLayout());
    final 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);
    final JPanel contentPane = new JPanel();

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

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

    urlLabel = new JLabel(bagView.getPropertyMessage("baseURL.label"));
    urlLabel.setToolTipText(bagView.getPropertyMessage("baseURL.description"));
    urlField = new JTextField("");
    try {
        assert bag != null;
        urlField.setText(bag.getFetch().getBaseURL());
    } catch (Exception e) {
        log.error("Failed to set url label", e);
    }
    urlField.setEnabled(false);

    // TODO: Add format label
    final 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);
    final 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 = 2;
    if (bag != null) {
        mode = bag.getSerialMode();
    }
    if (mode == DefaultBag.NO_MODE) {
        this.noneButton.setEnabled(true);
    } else if (mode == DefaultBag.ZIP_MODE) {
        this.zipButton.setEnabled(true);
    } else {
        this.noneButton.setEnabled(true);
    }

    final ButtonGroup serializeGroup = new ButtonGroup();
    serializeGroup.add(noneButton);
    serializeGroup.add(zipButton);
    // serializeGroup.add(tarButton);
    // serializeGroup.add(tarGzButton);
    // serializeGroup.add(tarBz2Button);
    final JPanel 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"));

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

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

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

    final JLabel payAlgorithmLabel = new JLabel(bagView.getPropertyMessage("bag.label" + ".payalgorithm"));
    payAlgorithmLabel.setToolTipText(getMessage("bag.payalgorithm.help"));
    final JComboBox<String> payAlgorithmList = new JComboBox<String>(
            listModel.toArray(new String[listModel.size()]));
    payAlgorithmList.setName(getMessage("bag.payalgorithmlist"));
    payAlgorithmList.addActionListener(new PayAlgorithmListHandler());
    payAlgorithmList.setToolTipText(getMessage("bag.payalgorithmlist.help"));

    //only if bag is not null
    if (bag != null) {
        final String fileName = bag.getName();
        bagNameField = new JTextField(fileName);
        bagNameField.setCaretPosition(fileName.length());

        holeyCheckbox.setSelected(bag.isHoley());
        urlLabel.setEnabled(bag.isHoley());
        isTagCheckbox.setSelected(bag.isBuildTagManifest());
        tagAlgorithmList.setSelectedItem(bag.getTagManifestAlgorithm());
        isPayloadCheckbox.setSelected(bag.isBuildPayloadManifest());
        payAlgorithmList.setSelectedItem(bag.getPayloadManifestAlgorithm());
    }

    final GridBagLayout layout = new GridBagLayout();
    final GridBagConstraints glbc = new GridBagConstraints();
    final 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);
    final JComponent buttonBar = createButtonBar();
    pageControl.add(buttonBar, BorderLayout.SOUTH);

    this.pack();
    return pageControl;

}

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

void buildManipulators() {
    JButton removeButton = new JButton(I_CLOSE);
    removeButton.setPressedIcon(I_CLOSE_PRESSED);
    removeButton.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));//4,4,4,4));
    removeButton.setBorderPainted(false);
    removeButton.setContentAreaFilled(false);
    removeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (JOptionPane.showOptionDialog(null, "Remove the Series " + getSeriesName() + "?", "Confirm",
                    JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null,
                    new Object[] { "Remove", "Cancel" }, null) == 0) // remove
            {/*from  w  w w  .  j a  v  a  2 s .  c o m*/
                getGenerator().removeSeries(getSeriesIndex());
            }
        }
    });
    removeButton.setToolTipText("Remove this series");

    JButton upButton = new JButton(I_UP);
    upButton.setPressedIcon(I_UP_PRESSED);
    upButton.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));//4,4,4,4));
    upButton.setBorderPainted(false);
    upButton.setContentAreaFilled(false);
    upButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            getGenerator().moveSeries(getSeriesIndex(), true);
        }
    });
    upButton.setToolTipText("Draw this series higher in the series order");

    JButton downButton = new JButton(I_DOWN);
    downButton.setPressedIcon(I_DOWN_PRESSED);
    downButton.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));//4,4,4,4));
    downButton.setBorderPainted(false);
    downButton.setContentAreaFilled(false);
    downButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            getGenerator().moveSeries(getSeriesIndex(), false);
        }
    });
    downButton.setToolTipText("Draw this series lower in the series order");

    manipulators.add(removeButton);
    manipulators.add(upButton);
    manipulators.add(downButton);
}

From source file:com.willwinder.universalgcodesender.uielements.macros.MacroActionPanel.java

@Override
public void doLayout() {
    Settings s = backend.getSettings();//from   w ww.ja v  a2 s.  co m

    // Lookup macros.
    if (macrosDirty) {
        Integer lastMacroIndex = s.getLastMacroIndex() + 1;
        macros.clear();
        for (int i = 0; i < lastMacroIndex; i++) {
            Macro m = s.getMacro(i);
            if (StringUtils.isNotEmpty(m.getGcode())) {
                macros.add(s.getMacro(i));
            }
        }
    }

    // Cache the largest width amongst the buttons.
    int maxWidth = 0;
    int maxHeight = 0;

    // Create buttons.
    for (int i = 0; i < macros.size(); i++) {
        final int index = i;
        Macro macro = macros.get(i);
        JButton button;
        if (customGcodeButtons.size() <= i) {
            button = new JButton(i + "");
            button.setEnabled(false);
            customGcodeButtons.add(button);
            // Add action listener
            button.addActionListener((ActionEvent evt) -> {
                customGcodeButtonActionPerformed(index);
            });
        } else {
            button = customGcodeButtons.get(i);
        }

        if (!StringUtils.isEmpty(macro.getName())) {
            button.setText(macro.getName());
        } else if (!StringUtils.isEmpty(macro.getDescription())) {
            button.setText(macro.getDescription());
        }

        if (!StringUtils.isEmpty(macro.getDescription())) {
            button.setToolTipText(macro.getDescription());
        }

        if (button.getPreferredSize().width > maxWidth)
            maxWidth = button.getPreferredSize().width;
        if (button.getPreferredSize().height > maxHeight)
            maxHeight = button.getPreferredSize().height;
    }

    // If button count was reduced, clear out any extras.
    if (customGcodeButtons.size() > macros.size()) {
        this.macroPanel.removeAll();
        this.macroPanel.repaint();
        for (int i = customGcodeButtons.size(); i > macros.size(); i--) {
            JButton b = customGcodeButtons.remove(i - 1);
        }
    }

    // Calculate columns/rows which can fit in the space we have.
    int columns = (getWidth() - (2 * INSET)) / (maxWidth + PADDING);
    int rows = (getHeight() - (2 * INSET)) / (maxHeight + PADDING);

    // At least one column.
    columns = Math.max(columns, 1);

    // Update number of rows if more are needed.
    if (columns * rows < customGcodeButtons.size()) {
        rows = customGcodeButtons.size() / columns;
        if (customGcodeButtons.size() % columns != 0)
            rows++;
    }

    // Layout for buttons.
    StringBuilder columnConstraint = new StringBuilder();
    for (int i = 0; i < columns; i++) {
        if (i > 0) {
            columnConstraint.append("unrelated");
        }
        columnConstraint.append("[fill, sg 1]");
    }
    MigLayout layout = new MigLayout("fillx, wrap " + columns + ", inset " + INSET,
            columnConstraint.toString());
    macroPanel.setLayout(layout);

    // Put buttons in grid.
    int x = 0;
    int y = 0;
    for (JButton button : customGcodeButtons) {
        macroPanel.add(button, "cell " + x + " " + y);
        y++;
        if (y == rows) {
            x++;
            y = 0;
        }
    }

    super.doLayout();
}

From source file:com.opendoorlogistics.studio.appframe.AppFrame.java

@Override
public void launchScriptWizard(final int tableIds[], final ODLComponent component) {
    // final ODLTableDefinition dfn = (tableId != -1 && loaded != null) ? loaded.getDs().getTableByImmutableId(tableId) : null;

    // create button to launch the wizard
    ArrayList<JButton> buttons = new ArrayList<>();
    for (final ODLWizardTemplateConfig config : ScriptTemplatesImpl.getTemplates(getApi(), component)) {
        Action action = new AbstractAction(
                "Launch wizard \"" + config.getName() + "\" to configure new script") {

            @Override//from ww  w .j  a v a2 s .  co  m
            public void actionPerformed(ActionEvent e) {
                Script script = ScriptWizardActions.createScriptFromMasterComponent(getApi(), AppFrame.this,
                        component, config, loaded != null ? loaded.getDs() : null, tableIds);
                if (script != null) {
                    // ScriptEditor dlg = new ScriptEditorWizardGenerated(script, null, getScriptUIManager());
                    // AppFrame.this.addInternalFrame(dlg);
                    scriptManager.launchScriptEditor(script, null, null);
                }
            }
        };
        JButton button = new JButton(action);
        button.setToolTipText(config.getDescription());
        buttons.add(button);
    }

    // launch dialog to select the option
    if (buttons.size() > 1) {
        launchButtonsListDialog(component.getName(), "Choose \"" + component.getName() + "\" option:",
                component.getIcon(getApi(), ODLComponent.MODE_DEFAULT), buttons);
    } else {
        // pick the only option...
        buttons.get(0).doClick();
    }

}

From source file:lol.search.RankedStatsPage.java

private JScrollPane championSelectPanel() {
    JPanel mainPanel = new JPanel(new FlowLayout());
    //mainPanel.setBorder(BorderFactory.createLineBorder(Color.WHITE));
    mainPanel.setBackground(backgroundColor);
    for (int i = 0; i < this.objChampRankedList.size(); i++) {
        int position = counter;
        ImageIcon champImageIcon = this.OBJ_RANKED_STATS_BY_ID.getChampionIconOf(this.champKeyList.get(i));
        JButton champButton = new JButton();
        champButton.setIcon(champImageIcon);
        if (i == 0) {
            champButton.setIcon(this.profileIcon);
            champButton.setToolTipText("Overall Stats");
        }/*w w w  . j a va2s  .  c  om*/
        champButton.setPreferredSize(new Dimension(55, 55));
        champButton.setBackground(Color.BLACK);
        champButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) { //button pressed
                background.setIcon(OBJ_GAME_STATIC_DATA.getBackgroundImageIcon(champKeyList.get(position)));
                loadArtLabel.setIcon(OBJ_GAME_STATIC_DATA.initLoadingArt(champKeyList.get(position)));
                nameHeader.setText(OBJ_ALL_CHAMPS_BY_ID.getChampNameFromId(champIdList.get(position)));

                titleHeader.setText(" " + OBJ_ALL_CHAMPS_BY_ID.getChampTitleFromId(champIdList.get(position)));
                String sessionsWon = "";
                String sessionsLost = "";
                String winPercentString = "";
                try {
                    int won = objChampRankedList.get(position).getJSONObject("stats")
                            .getInt("totalSessionsWon");
                    sessionsWon = Integer.toString(won);
                    int lost = objChampRankedList.get(position).getJSONObject("stats")
                            .getInt("totalSessionsLost");
                    sessionsLost = Integer.toString(lost);
                    winPercentString = getWinPercentage(won, lost);
                    totalGamesInt = won + lost;
                    avgKillsLabelValue.setText(new DecimalFormat("##.##")
                            .format((double) objChampRankedList.get(position).getJSONObject("stats")
                                    .getInt("totalChampionKills") / (double) totalGamesInt));
                    avgAssistsLabelValue
                            .setText(new DecimalFormat("##.##").format((double) objChampRankedList.get(position)
                                    .getJSONObject("stats").getInt("totalAssists") / (double) totalGamesInt));
                    avgDeathsLabelValue.setText(new DecimalFormat("##.##")
                            .format((double) objChampRankedList.get(position).getJSONObject("stats")
                                    .getInt("totalDeathsPerSession") / (double) totalGamesInt));
                    avgMinionKillsLabelValue.setText(new DecimalFormat("##.##")
                            .format((double) objChampRankedList.get(position).getJSONObject("stats")
                                    .getInt("totalMinionKills") / (double) totalGamesInt));
                    avgDoubleKillsLabelValue.setText(new DecimalFormat("##.##")
                            .format((double) objChampRankedList.get(position).getJSONObject("stats")
                                    .getInt("totalDoubleKills") / (double) totalGamesInt));
                    avgTripleKillsLabelValue.setText(new DecimalFormat("##.##")
                            .format((double) objChampRankedList.get(position).getJSONObject("stats")
                                    .getInt("totalTripleKills") / (double) totalGamesInt));
                    avgQuadKillsLabelValue.setText(new DecimalFormat("##.##")
                            .format((double) objChampRankedList.get(position).getJSONObject("stats")
                                    .getInt("totalQuadraKills") / (double) totalGamesInt));
                    avgPentaKillsLabelValue.setText(new DecimalFormat("##.##")
                            .format((double) objChampRankedList.get(position).getJSONObject("stats")
                                    .getInt("totalPentaKills") / (double) totalGamesInt));
                    totalKillsLabelValue.setText(new DecimalFormat("#######").format((double) objChampRankedList
                            .get(position).getJSONObject("stats").getInt("totalChampionKills")));
                    totalDeathsLabelValue
                            .setText(new DecimalFormat("#######").format((double) objChampRankedList
                                    .get(position).getJSONObject("stats").getInt("totalDeathsPerSession")));
                    totalAssistsLabelValue
                            .setText(new DecimalFormat("#######").format((double) objChampRankedList
                                    .get(position).getJSONObject("stats").getInt("totalAssists")));
                    totalMinionsLabelValue
                            .setText(new DecimalFormat("#######").format((double) objChampRankedList
                                    .get(position).getJSONObject("stats").getInt("totalMinionKills")));
                    totalDoubleKillsLabelValue
                            .setText(new DecimalFormat("#######").format((double) objChampRankedList
                                    .get(position).getJSONObject("stats").getInt("totalDoubleKills")));
                    totalTripleKillsLabelValue
                            .setText(new DecimalFormat("#######").format((double) objChampRankedList
                                    .get(position).getJSONObject("stats").getInt("totalTripleKills")));
                    totalQuadKillsLabelValue
                            .setText(new DecimalFormat("#######").format((double) objChampRankedList
                                    .get(position).getJSONObject("stats").getInt("totalQuadraKills")));
                    totalPentaKillsLabelValue
                            .setText(new DecimalFormat("#######").format((double) objChampRankedList
                                    .get(position).getJSONObject("stats").getInt("totalPentaKills")));
                } catch (JSONException ex) {
                    Logger.getLogger(RankedStatsPage.class.getName()).log(Level.SEVERE, null, ex);
                }
                totalWins.setText(sessionsWon);
                totalLosses.setText(sessionsLost);
                winPercent.setText(winPercentString + "%");
                totalGamesPlayed.setText(String.valueOf(totalGamesInt));
                masterFrame.revalidate();
                masterFrame.repaint();
            }
        });
        champButton.setToolTipText(OBJ_ALL_CHAMPS_BY_ID.getChampNameFromId(champIdList.get(position)));
        champButtons.add(champButton);
        //champButton.setBorder(BorderFactory.createLineBorder(Color.BLACK));
        counter++;
    }
    for (int i = 0; i < champButtons.size(); i++) {
        mainPanel.add(champButtons.get(i));
        mainPanel.revalidate();
    }
    JScrollPane scrollPane = new JScrollPane(mainPanel);
    scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
    scrollPane.setPreferredSize(new Dimension(1200, 85));
    scrollPane.setBackground(new Color(0, 0, 0, 100));
    scrollPane.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    scrollPane.getHorizontalScrollBar().setUI(new BasicScrollBarUI() {
        @Override
        protected void configureScrollBarColors() {
            this.thumbColor = new Color(124, 124, 124, 255);
            this.trackColor = Color.BLACK;
        }
    });

    return scrollPane;
}

From source file:net.itransformers.topologyviewer.gui.GraphViewerPanel.java

private JButton createZoomInButton(final ScalingControl scaler) {
    JButton plus = new JButton("+");
    plus.setToolTipText("Zoom In");
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }//from ww w. j  av  a  2s .c o m
    });
    return plus;
}