Search in sources :

Example 26 with DefaultComboBoxModel

use of javax.swing.DefaultComboBoxModel in project jgnash by ccavanaugh.

the class DynamicJasperReportPanel method initializeUI.

private void initializeUI() {
    GridBagConstraints gridBagConstraints;
    JToolBar toolBar = new JToolBar();
    firstButton = new JButton();
    previousButton = new JButton();
    nextButton = new JButton();
    lastButton = new JButton();
    actualSizeButton = new JToggleButton();
    fitPageButton = new JToggleButton();
    fitWidthButton = new JToggleButton();
    zoomInButton = new JButton();
    DefaultComboBoxModel<String> zoomModel = new DefaultComboBoxModel<>();
    for (int z : ZOOM) {
        zoomModel.addElement(z + "%");
    }
    zoomComboBox = new JComboBox<>(zoomModel);
    DefaultComboBoxModel<Integer> fontModel = new DefaultComboBoxModel<>();
    for (int i = 0; i <= 10; i++) {
        fontModel.addElement(5 + i);
    }
    fontSizeComboBox = new JComboBox<>(fontModel);
    fontSizeComboBox.setToolTipText(ResourceUtils.getString("ToolTip.FontSize"));
    fontSizeComboBox.setSelectedItem(report.getBaseFontSize());
    fontSizeComboBox.addActionListener(this);
    zoomOutButton = new JButton();
    mainPanel = new JPanel();
    JScrollPane scrollPane = new JScrollPane();
    scrollPanePanel = new JPanel();
    pageGluePanel = new JPanel();
    JPanel pagePanel = new JPanel();
    JPanel shadowPanel1 = new JPanel();
    JPanel shadowPanel2 = new JPanel();
    JPanel shadowPanel3 = new JPanel();
    JPanel shadowPanel4 = new JPanel();
    JPanel shadowPanel5 = new JPanel();
    setLayout(new BorderLayout());
    toolBar.setFloatable(false);
    toolBar.setRollover(true);
    saveButton = new JButton(new ImageIcon(getClass().getResource("/jgnash/resource/document-save-as.png")));
    saveButton.setToolTipText(resourceBundle.getString("save"));
    saveButton.setFocusable(false);
    saveButton.addActionListener(this);
    toolBar.add(saveButton);
    printButton = new JButton(new ImageIcon(getClass().getResource("/jgnash/resource/document-print.png")));
    printButton.setToolTipText(resourceBundle.getString("print"));
    printButton.setFocusable(false);
    printButton.addActionListener(this);
    toolBar.add(printButton);
    toolBar.add(new JToolBar.Separator());
    pageSetupButton = new JButton(new ImageIcon(getClass().getResource("/jgnash/resource/document-properties.png")));
    pageSetupButton.setToolTipText(ResourceUtils.getString("ToolTip.PageSetup"));
    pageSetupButton.setFocusable(false);
    pageSetupButton.addActionListener(this);
    toolBar.add(pageSetupButton);
    fontSizeComboBox.setMaximumSize(new Dimension(50, pageSetupButton.getMinimumSize().height));
    fontSizeComboBox.setMinimumSize(new Dimension(50, pageSetupButton.getMinimumSize().height));
    fontSizeComboBox.setPreferredSize(new Dimension(50, pageSetupButton.getPreferredSize().height));
    toolBar.add(fontSizeComboBox);
    toolBar.add(new JToolBar.Separator());
    firstButton.setIcon(new ImageIcon(getClass().getResource("/jgnash/resource/go-first.png")));
    firstButton.setToolTipText(resourceBundle.getString("first.page"));
    firstButton.setFocusable(false);
    firstButton.setEnabled(false);
    firstButton.addActionListener(this);
    toolBar.add(firstButton);
    previousButton.setIcon(new ImageIcon(getClass().getResource("/jgnash/resource/go-previous.png")));
    previousButton.setToolTipText(resourceBundle.getString("previous.page"));
    previousButton.setFocusable(false);
    previousButton.setEnabled(false);
    previousButton.addActionListener(this);
    toolBar.add(previousButton);
    nextButton.setIcon(new ImageIcon(getClass().getResource("/jgnash/resource/go-next.png")));
    nextButton.setToolTipText(resourceBundle.getString("next.page"));
    nextButton.setFocusable(false);
    nextButton.setEnabled(false);
    nextButton.addActionListener(this);
    toolBar.add(nextButton);
    lastButton.setIcon(new ImageIcon(getClass().getResource("/jgnash/resource/go-last.png")));
    lastButton.setToolTipText(resourceBundle.getString("last.page"));
    lastButton.setFocusable(false);
    lastButton.setEnabled(false);
    lastButton.addActionListener(this);
    toolBar.add(lastButton);
    toolBar.add(new JToolBar.Separator());
    actualSizeButton.setIcon(new ImageIcon(getClass().getResource("/net/sf/jasperreports/view/images/actualsize.GIF")));
    actualSizeButton.setToolTipText(resourceBundle.getString("actual.size"));
    actualSizeButton.setFocusable(false);
    actualSizeButton.addActionListener(this);
    toolBar.add(actualSizeButton);
    fitPageButton.setIcon(new ImageIcon(getClass().getResource("/net/sf/jasperreports/view/images/fitpage.GIF")));
    fitPageButton.setToolTipText(resourceBundle.getString("fit.page"));
    fitPageButton.setFocusable(false);
    fitPageButton.addActionListener(this);
    toolBar.add(fitPageButton);
    fitWidthButton.setIcon(new ImageIcon(getClass().getResource("/net/sf/jasperreports/view/images/fitwidth.GIF")));
    fitWidthButton.setToolTipText(resourceBundle.getString("fit.width"));
    fitWidthButton.setFocusable(false);
    fitWidthButton.addActionListener(this);
    toolBar.add(fitWidthButton);
    toolBar.add(new JToolBar.Separator());
    zoomInButton.setIcon(new ImageIcon(getClass().getResource("/jgnash/resource/zoom-in.png")));
    zoomInButton.setToolTipText(resourceBundle.getString("zoom.in"));
    zoomInButton.setFocusable(false);
    zoomInButton.addActionListener(this);
    toolBar.add(zoomInButton);
    zoomComboBox.setEditable(true);
    zoomComboBox.setToolTipText(resourceBundle.getString("zoom.ratio"));
    zoomComboBox.setMaximumSize(new Dimension(90, zoomInButton.getMinimumSize().height));
    zoomComboBox.setMinimumSize(new Dimension(90, zoomInButton.getMinimumSize().height));
    zoomComboBox.setPreferredSize(new Dimension(90, zoomInButton.getPreferredSize().height));
    zoomComboBox.addItemListener(evt -> zoomStateChange());
    zoomComboBox.addActionListener(this);
    toolBar.add(zoomComboBox);
    zoomOutButton.setIcon(new ImageIcon(getClass().getResource("/jgnash/resource/zoom-out.png")));
    zoomOutButton.setToolTipText(resourceBundle.getString("zoom.out"));
    zoomOutButton.setFocusable(false);
    zoomOutButton.addActionListener(this);
    toolBar.add(zoomOutButton);
    JPanel reportController = report.getReportController();
    if (reportController != null) {
        JPanel panel = new JPanel(new BorderLayout());
        panel.add(toolBar, BorderLayout.NORTH);
        panel.add(reportController, BorderLayout.CENTER);
        add(panel, BorderLayout.NORTH);
    } else {
        add(toolBar, BorderLayout.NORTH);
    }
    mainPanel.addComponentListener(new ComponentAdapter() {

        @Override
        public void componentResized(final ComponentEvent evt) {
            pnlMainComponentResized();
        }
    });
    mainPanel.setLayout(new BorderLayout());
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPanePanel.setLayout(new GridBagLayout());
    pageGluePanel.setLayout(new BorderLayout());
    pagePanel.setLayout(new GridBagLayout());
    spaceHoldPanel = new JPanel();
    spaceHoldPanel.setMinimumSize(new Dimension(5, 5));
    spaceHoldPanel.setOpaque(false);
    spaceHoldPanel.setPreferredSize(new Dimension(5, 5));
    spaceHoldPanel.setLayout(null);
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.gridheight = 2;
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    pagePanel.add(spaceHoldPanel, gridBagConstraints);
    shadowPanel1.setBackground(java.awt.Color.gray);
    shadowPanel1.setMinimumSize(new Dimension(5, 5));
    shadowPanel1.setPreferredSize(new Dimension(5, 5));
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = GridBagConstraints.VERTICAL;
    pagePanel.add(shadowPanel1, gridBagConstraints);
    shadowPanel2.setMinimumSize(new Dimension(5, 5));
    shadowPanel2.setPreferredSize(new Dimension(5, 5));
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 2;
    pagePanel.add(shadowPanel2, gridBagConstraints);
    shadowPanel3.setBackground(Color.gray);
    shadowPanel3.setMinimumSize(new Dimension(5, 5));
    shadowPanel3.setPreferredSize(new Dimension(5, 5));
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    pagePanel.add(shadowPanel3, gridBagConstraints);
    shadowPanel4.setBackground(Color.gray);
    shadowPanel4.setMinimumSize(new Dimension(5, 5));
    shadowPanel4.setPreferredSize(new Dimension(5, 5));
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 2;
    pagePanel.add(shadowPanel4, gridBagConstraints);
    shadowPanel5.setMinimumSize(new Dimension(5, 5));
    shadowPanel5.setPreferredSize(new Dimension(5, 5));
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 0;
    pagePanel.add(shadowPanel5, gridBagConstraints);
    pageRenderer = new PageRenderer(this);
    pageRenderer.setBackground(Color.white);
    pageRenderer.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0)));
    pageRenderer.setOpaque(true);
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.gridheight = 2;
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    pagePanel.add(pageRenderer, gridBagConstraints);
    pageGluePanel.add(pagePanel, BorderLayout.CENTER);
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.insets = new Insets(5, 5, 5, 5);
    scrollPanePanel.add(pageGluePanel, gridBagConstraints);
    scrollPane.setViewportView(scrollPanePanel);
    mainPanel.add(scrollPane, BorderLayout.CENTER);
    add(mainPanel, BorderLayout.CENTER);
    zoomComboBox.setSelectedIndex(DEFAULT_ZOOM_INDEX);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) ImageIcon(javax.swing.ImageIcon) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) Color(java.awt.Color) JButton(javax.swing.JButton) JToolBar(javax.swing.JToolBar) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) Dimension(java.awt.Dimension) JasperPrint(net.sf.jasperreports.engine.JasperPrint) JToggleButton(javax.swing.JToggleButton) BorderLayout(java.awt.BorderLayout) ComponentEvent(java.awt.event.ComponentEvent) ComponentAdapter(java.awt.event.ComponentAdapter)

Example 27 with DefaultComboBoxModel

use of javax.swing.DefaultComboBoxModel in project jgnash by ccavanaugh.

the class CheckDesignDialog method initComponents.

private void initComponents() {
    toolBar = new JToolBar();
    toolBar.setRollover(true);
    openButton = new RollOverButton(rb.getString("Menu.Open.Name").replace("_", ""), IconUtils.getIcon("/jgnash/resource/document-open.png"));
    saveButton = new RollOverButton(rb.getString("Menu.Save.Name").replace("_", ""), IconUtils.getIcon("/jgnash/resource/document-save.png"));
    toolBar.add(openButton);
    toolBar.add(saveButton);
    checkLayout = new CheckLayout();
    layout = new PrintableCheckLayout(checkLayout);
    countField = getIntegerField();
    xPosField = getFloatField();
    yPosField = getFloatField();
    heightField = getFloatField();
    previewPanel = new PrintPreviewPanel(layout, layout.getPageFormat());
    objectList = new JList<>();
    //objectList.setPrototypeCellValue("Some dummy text");
    setupButton = new JButton(rb.getString("Button.PageSetup"));
    addButton = new JButton(rb.getString("Button.Add"));
    removeButton = new JButton(rb.getString("Button.Remove"));
    clearButton = new JButton(rb.getString("Button.Clear"));
    applyButton = new JButton(rb.getString("Button.Apply"));
    printButton = new JButton(rb.getString("Button.PrintSample"));
    closeButton = new JButton(rb.getString("Button.Close"));
    nameField = new JTextFieldEx();
    typeCombo = new JComboBox<>();
    DefaultComboBoxModel<CheckObjectType> comboModel = new DefaultComboBoxModel<>(CheckObjectType.values());
    typeCombo.setModel(comboModel);
    model = new DefaultListModel<>();
    objectList.setModel(model);
    objectList.addListSelectionListener(this);
    addButton.addActionListener(this);
    applyButton.addActionListener(this);
    closeButton.addActionListener(this);
    clearButton.addActionListener(this);
    countField.addActionListener(this);
    removeButton.addActionListener(this);
    setupButton.addActionListener(this);
    heightField.addActionListener(this);
    saveButton.addActionListener(this);
    openButton.addActionListener(this);
    printButton.addActionListener(this);
    heightField.addFocusListener(this);
    countField.addFocusListener(this);
}
Also used : RollOverButton(jgnash.ui.components.RollOverButton) JButton(javax.swing.JButton) JToolBar(javax.swing.JToolBar) JTextFieldEx(jgnash.ui.components.JTextFieldEx) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) CheckObjectType(jgnash.engine.checks.CheckObject.CheckObjectType) CheckLayout(jgnash.engine.checks.CheckLayout)

Example 28 with DefaultComboBoxModel

use of javax.swing.DefaultComboBoxModel in project processdash by dtuma.

the class AssignedToComboBox method setInitialsList.

public void setInitialsList(List<String> acceptableInitials) {
    String fullText = getFullText();
    DefaultComboBoxModel model = (DefaultComboBoxModel) getModel();
    model.removeAllElements();
    for (String initial : acceptableInitials) model.addElement(initial);
    setFullText(fullText);
}
Also used : DefaultComboBoxModel(javax.swing.DefaultComboBoxModel)

Example 29 with DefaultComboBoxModel

use of javax.swing.DefaultComboBoxModel in project gephi by gephi.

the class EdgeTypePanel method setup.

public void setup(final EdgeTypeBuilder.EdgeTypeFilter filter) {
    this.filter = filter;
    DefaultComboBoxModel comboBoxModel = new DefaultComboBoxModel();
    for (Object o : filter.getEdgeTypeLabels()) {
        comboBoxModel.addElement(o);
    }
    comboBox.setModel(comboBoxModel);
    if (comboBoxModel.getSize() > 0) {
        filter.setEdgeTypeLabel(comboBoxModel.getSelectedItem());
    }
}
Also used : DefaultComboBoxModel(javax.swing.DefaultComboBoxModel)

Example 30 with DefaultComboBoxModel

use of javax.swing.DefaultComboBoxModel in project gephi by gephi.

the class DataTableTopComponent method refreshFilterColumns.

private void refreshFilterColumns() {
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            ArrayList columns = new ArrayList();
            if (isShowingNodesTable()) {
                DefaultComboBoxModel model = new DefaultComboBoxModel();
                for (int i = 0; i < nodeTable.getTable().getColumnCount(); i++) {
                    if (nodeTable.getTable().getColumnExt(i).isVisible()) {
                        model.addElement(nodeTable.getTable().getColumnExt(i).getTitle());
                        columns.add(nodeTable.getTable().getColumnExt(i).getTitle());
                    }
                }
                columnComboBox.setModel(model);
                Integer previousNodeColumnsFilterIndex = filterColumnIndexByDisplayTable.get(DisplayTable.NODE);
                if (columns.equals(previousNodeFilterColumns) && previousNodeColumnsFilterIndex != null && previousNodeColumnsFilterIndex < columnComboBox.getItemCount()) {
                    //Preserve user selected column when the columns list does not change
                    columnComboBox.setSelectedIndex(previousNodeColumnsFilterIndex);
                }
                previousNodeFilterColumns = columns;
            } else if (isShowingEdgesTable()) {
                DefaultComboBoxModel model = new DefaultComboBoxModel();
                for (int i = 0; i < edgeTable.getTable().getColumnCount(); i++) {
                    if (edgeTable.getTable().getColumnExt(i).isVisible()) {
                        model.addElement(edgeTable.getTable().getColumnExt(i).getTitle());
                        columns.add(edgeTable.getTable().getColumnExt(i).getTitle());
                    }
                }
                columnComboBox.setModel(model);
                Integer previousEdgeColumnsFilterIndex = filterColumnIndexByDisplayTable.get(DisplayTable.EDGE);
                if (columns.equals(previousEdgeFilterColumns) && previousEdgeColumnsFilterIndex != null && previousEdgeColumnsFilterIndex < columnComboBox.getItemCount()) {
                    //Preserve user selected column when the columns list does not change
                    columnComboBox.setSelectedIndex(previousEdgeColumnsFilterIndex);
                }
                previousEdgeFilterColumns = columns;
            }
        }
    });
}
Also used : ArrayList(java.util.ArrayList) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel)

Aggregations

DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)63 JPanel (javax.swing.JPanel)16 JLabel (javax.swing.JLabel)13 JButton (javax.swing.JButton)12 ActionEvent (java.awt.event.ActionEvent)11 ActionListener (java.awt.event.ActionListener)11 JComboBox (javax.swing.JComboBox)11 Insets (java.awt.Insets)10 GridBagConstraints (java.awt.GridBagConstraints)9 GridBagLayout (java.awt.GridBagLayout)8 JScrollPane (javax.swing.JScrollPane)8 JTextField (javax.swing.JTextField)7 BorderLayout (java.awt.BorderLayout)5 Dimension (java.awt.Dimension)5 ItemEvent (java.awt.event.ItemEvent)5 ItemListener (java.awt.event.ItemListener)5 ArrayList (java.util.ArrayList)5 Vector (java.util.Vector)5 JCheckBox (javax.swing.JCheckBox)5 FlowLayout (java.awt.FlowLayout)4