Example usage for javax.swing ScrollPaneConstants VERTICAL_SCROLLBAR_AS_NEEDED

List of usage examples for javax.swing ScrollPaneConstants VERTICAL_SCROLLBAR_AS_NEEDED

Introduction

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

Prototype

int VERTICAL_SCROLLBAR_AS_NEEDED

To view the source code for javax.swing ScrollPaneConstants VERTICAL_SCROLLBAR_AS_NEEDED.

Click Source Link

Document

Used to set the vertical scroll bar policy so that vertical scrollbars are displayed only when needed.

Usage

From source file:de.tud.kom.p2psim.impl.skynet.visualization.SkyNetVisualization.java

private SkyNetVisualization() {
    super("Metric-Visualization");
    createLookAndFeel();/*  w w  w .  j av  a2  s . co  m*/
    displayedMetrics = new HashMap<String, MetricsPlot>();
    setLayout(new GridLayout(1, 1));
    addWindowListener(this);
    graphix = new JPanel(new GridBagLayout());
    graphix.setLayout(new BoxLayout(graphix, BoxLayout.PAGE_AXIS));
    mb = new JMenuBar();
    JScrollPane scroller = new JScrollPane(graphix, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    // calculating the size of the application-window as well as of all
    // components, that depend on the size of the window
    Toolkit kit = Toolkit.getDefaultToolkit();
    int appWidth = kit.getScreenSize().width * 3 / 4;
    int appHeight = kit.getScreenSize().height * 3 / 4;
    scroller.setPreferredSize(new Dimension(appWidth, appHeight));
    getContentPane().add(scroller);
    maxPlotsPerRow = 1;
    while ((maxPlotsPerRow + 1) * PLOT_WIDTH < appWidth) {
        maxPlotsPerRow++;
    }
    log.warn("Creating the visualization...");
    mb.add(new JMenu("File"));
    JMenu met = new JMenu("Available Metrics");
    met.setEnabled(false);
    mb.add(met);
    setJMenuBar(mb);
}

From source file:edu.ku.brc.af.ui.forms.CarryForwardConfigDlg.java

@Override
public void createUI() {
    super.createUI();

    buildTableModel(mvParent);//w  w w .java 2s.com

    model = new CFTableModel();
    table = new JTable(model) {
        //  Returning the Class of each column will allow different
        //  renderers to be used based on Class
        public Class<?> getColumnClass(int column) {
            return getValueAt(0, column).getClass();
        }

        public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
            Component c = super.prepareRenderer(renderer, row, column);
            if (!c.getBackground().equals(getSelectionBackground())) {
                CFWItem item = items.get(row);
                c.setBackground(item.getColor());
            }
            return c;
        }
    };

    UIHelper.makeTableHeadersCentered(table, false);

    //((DefaultTableCellRenderer)table.getColumnModel().getColumn(1).getCellRenderer()).setHorizontalAlignment(SwingConstants.CENTER);

    JScrollPane sp = new JScrollPane(table, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    contentPanel = sp;//new JPanel(new BorderLayout()));
    mainPanel.add(contentPanel, BorderLayout.CENTER);
}

From source file:org.peerfact.impl.service.aggregation.skyeye.visualization.SkyNetVisualization.java

private SkyNetVisualization() {
    super("Metric-Visualization");
    createLookAndFeel();/* w  w w .java 2s .  c o  m*/
    displayedMetrics = new LinkedHashMap<String, MetricsPlot>();
    setLayout(new GridLayout(1, 1));
    addWindowListener(this);
    graphix = new JPanel(new GridBagLayout());
    graphix.setLayout(new BoxLayout(graphix, BoxLayout.PAGE_AXIS));
    mb = new JMenuBar();
    JScrollPane scroller = new JScrollPane(graphix, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    // calculating the size of the application-window as well as of all
    // components, that depend on the size of the window
    Toolkit kit = Toolkit.getDefaultToolkit();
    int appWidth = kit.getScreenSize().width * 3 / 4;
    int appHeight = kit.getScreenSize().height * 3 / 4;
    scroller.setPreferredSize(new Dimension(appWidth, appHeight));
    getContentPane().add(scroller);
    maxPlotsPerRow = 1;
    while ((maxPlotsPerRow + 1) * PLOT_WIDTH < appWidth) {
        maxPlotsPerRow++;
    }
    log.warn("Creating the visualization...");
    mb.add(new JMenu("File"));
    JMenu met = new JMenu("Available Metrics");
    met.setEnabled(false);
    mb.add(met);
    setJMenuBar(mb);
}

From source file:captureplugin.drivers.DeviceCreatorDialog.java

/**
 * Create the GUI/*from   w w w  .  j  a  v  a  2  s .com*/
 */
private void createGUI() {
    UiUtilities.registerForClosing(this);

    DriverIf[] drivers = DriverFactory.getInstance().getDrivers();

    mDriverCombo = new JComboBox(drivers);
    mDriverCombo.setRenderer(new DefaultListCellRenderer() {
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
                boolean cellHasFocus) {

            if (value instanceof DriverIf) {
                value = ((DriverIf) value).getDriverName();
            }

            return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
        }
    });

    JPanel panel = (JPanel) getContentPane();

    panel.setLayout(new GridBagLayout());

    GridBagConstraints label = new GridBagConstraints();

    label.insets = new Insets(5, 5, 5, 5);
    label.anchor = GridBagConstraints.NORTHWEST;

    GridBagConstraints input = new GridBagConstraints();

    input.fill = GridBagConstraints.HORIZONTAL;
    input.weightx = 1.0;
    input.gridwidth = GridBagConstraints.REMAINDER;
    input.insets = new Insets(5, 5, 5, 5);

    panel.add(new JLabel(mLocalizer.msg("Name", "Name")), label);

    mName = new JTextField();
    panel.add(mName, input);

    panel.add(new JLabel(mLocalizer.msg("Driver", "Driver")), label);
    panel.add(mDriverCombo, input);

    mDesc = UiUtilities.createHtmlHelpTextArea("");
    mDesc.setEditable(false);

    panel.add(new JLabel(mLocalizer.msg("Description", "Description")), input);

    GridBagConstraints descC = new GridBagConstraints();
    descC.weightx = 1.0;
    descC.weighty = 1.0;
    descC.fill = GridBagConstraints.BOTH;
    descC.gridwidth = GridBagConstraints.REMAINDER;
    descC.insets = new Insets(5, 5, 5, 5);

    panel.add(new JScrollPane(mDesc, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER), descC);

    final Font font = new JLabel().getFont();

    String desc = ((DriverIf) mDriverCombo.getSelectedItem()).getDriverDesc();
    desc = "<html><div style=\"color:#000000;font-family:" + font.getName() + "; font-size:" + font.getSize()
            + ";\">" + desc + "</div></html>";
    mDesc.setText(desc);
    mDesc.setFont(font);

    mDriverCombo.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            String description = ((DriverIf) mDriverCombo.getSelectedItem()).getDriverDesc();
            description = "<html><div style=\"color:#000000;font-family:" + font.getName() + "; font-size:"
                    + font.getSize() + ";\">" + description + "</div></html>";
            mDesc.setText(description);
            mDesc.setFont(font);
        }

    });

    final JButton ok = new JButton(Localizer.getLocalization(Localizer.I18N_OK));
    ok.setEnabled(false);
    final JButton cancel = new JButton(Localizer.getLocalization(Localizer.I18N_CANCEL));
    ok.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            okPressed();
        }
    });

    cancel.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            setVisible(false);
        }
    });

    mName.getDocument().addDocumentListener(new DocumentListener() {
        @Override
        public void removeUpdate(DocumentEvent e) {
            updateButtons();
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            updateButtons();
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            updateButtons();
        }

        private void updateButtons() {
            ok.setEnabled(!mName.getText().trim().isEmpty());
        }
    });

    ButtonBarBuilder2 builder = new ButtonBarBuilder2();
    builder.addGlue();
    builder.addButton(new JButton[] { ok, cancel });

    getRootPane().setDefaultButton(ok);

    input.insets = new Insets(5, 5, 5, 5);

    panel.add(builder.getPanel(), input);

    setSize(400, 300);

}

From source file:dk.dma.epd.common.prototype.gui.voct.VOCTAdditionalInfoPanel.java

/**
 * Constructor/*  w  w  w .java  2 s  .  com*/
 * 
 * @param compactLayout
 *            if false, there will be message type selectors in the panel
 */
public VOCTAdditionalInfoPanel(boolean compactLayout) {
    super(new BorderLayout());

    EPD.getInstance().getVoctHandler().addVoctSarInfoListener(this);

    // Prepare the title header
    titleHeader.setBackground(getBackground().darker());
    titleHeader.setOpaque(true);
    titleHeader.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    titleHeader.setHorizontalAlignment(SwingConstants.CENTER);
    add(titleHeader, BorderLayout.NORTH);

    // Add messages panel
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    messagesPanel.setBackground(UIManager.getColor("List.background"));
    messagesPanel.setOpaque(false);
    messagesPanel.setLayout(new GridBagLayout());
    messagesPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    add(scrollPane, BorderLayout.CENTER);

    JPanel sendPanel = new JPanel(new GridBagLayout());
    add(sendPanel, BorderLayout.SOUTH);
    Insets insets = new Insets(2, 2, 2, 2);

    // Add text area
    // if (false) {
    // messageText = new JTextField();
    // ((JTextField) messageText).addActionListener(this);
    // sendPanel.add(messageText, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, NORTH, BOTH, insets, 0, 0));
    //
    // } else {
    messageText = new JTextArea();
    JScrollPane scrollPane2 = new JScrollPane(messageText);
    scrollPane2.setPreferredSize(new Dimension(100, 50));
    scrollPane2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane2.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    sendPanel.add(scrollPane2, new GridBagConstraints(0, 0, 1, 2, 1.0, 1.0, NORTH, BOTH, insets, 0, 0));
    // }

    // Add buttons
    // ButtonGroup group = new ButtonGroup();

    if (!compactLayout) {
        JToolBar msgTypePanel = new JToolBar();
        msgTypePanel.setBorderPainted(false);
        msgTypePanel.setOpaque(true);
        msgTypePanel.setFloatable(false);
        sendPanel.add(msgTypePanel, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, NORTH, NONE, insets, 0, 0));

    }

    if (compactLayout) {
        addBtn = new JButton("Add to Log");
        sendPanel.add(addBtn, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, NORTH, NONE, insets, 0, 0));
    }
    // addBtn.setEnabled(false);
    // messageText.setEditable(false);
    addBtn.addActionListener(this);
}

From source file:net.sf.jabref.gui.PreviewPanel.java

/**
 *
 * @param panel//from   ww  w.  j a  v a2  s  .  co m
 *            (may be null) If not given no toolbar is shown on the right
 *            hand side.
 * @param databaseContext
 *            (may be null) Used for resolving pdf directories for links.
 * @param layoutFile
 *            (must be given) Used for layout
 */
public PreviewPanel(BasePanel panel, BibDatabaseContext databaseContext, String layoutFile) {
    super(new BorderLayout(), true);

    this.databaseContext = Optional.ofNullable(databaseContext);
    this.layoutFile = Objects.requireNonNull(layoutFile);
    updateLayout();

    this.closeAction = new CloseAction();
    this.printAction = new PrintAction();
    this.copyPreviewAction = new CopyPreviewAction();

    this.basePanel = Optional.ofNullable(panel);

    createPreviewPane();

    if (panel != null) {
        // dropped files handler only created for main window
        // not for Windows as like the search results window
        this.previewPane.setTransferHandler(
                new PreviewPanelTransferHandler(panel.frame(), this, this.previewPane.getTransferHandler()));
    }

    // Set up scroll pane for preview pane
    scrollPane = new JScrollPane(previewPane, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setBorder(null);

    /*
     * If we have been given a panel and the preference option
     * previewPrintButton is set, show the tool bar
     */
    if (this.basePanel.isPresent()
            && JabRefPreferences.getInstance().getBoolean(JabRefPreferences.PREVIEW_PRINT_BUTTON)) {
        add(createToolBar(), BorderLayout.LINE_START);
    }

    add(scrollPane, BorderLayout.CENTER);

    this.createKeyBindings();
}

From source file:edu.ku.brc.specify.config.init.TreeDefSetupPanel.java

/**
 * @param classType the class of the TreeDef
 * @param classTitle the already localized title of the actual tree
 * @param panelName the name of the panel
 * @param descKey L10N key to label description above the table
 * @param nextBtn the next button//from   ww  w .j av  a  2  s.  c  om
 * @param dbPanel the 
 */
public TreeDefSetupPanel(final Class<?> classType, final String classTitle, final String panelName,
        final String helpContext, final String descKey, final JButton nextBtn, final JButton prevBtn,
        final DisciplinePanel disciplinePanel) {
    super(panelName, helpContext, nextBtn, prevBtn);

    this.classType = classType;
    this.classTitle = classTitle;
    this.disciplinePanel = disciplinePanel;

    if (classType == TaxonTreeDef.class || classType == GeographyTreeDef.class
            || classType == StorageTreeDef.class) {
        model = new TreeDefTableModel();
        if (classType != TaxonTreeDef.class) {
            loadTree(disciplinePanel != null && disciplinePanel.getDisciplineType() != null
                    ? disciplinePanel.getDisciplineType().getDisciplineType()
                    : null);
        }

        table = new JTable(model);
        directionCBX = UIHelper
                .createComboBox(new String[] { getResourceString("FORWARD"), getResourceString("REVERSE") });
        fullnameDisplayTxt = new JEditorPane();
        fullnameDisplayTxt.setBackground(Color.WHITE);
        fullnameDisplayTxt.setOpaque(true);
        fullnameDisplayTxt.setContentType("text/html");
        fullnameDisplayTxt.setEditable(false);

        table.setRowSelectionAllowed(false);
        table.setColumnSelectionAllowed(false);
        //table.setDefaultRenderer(String.class, new BiColorTableCellRenderer(false));

        model.addTableModelListener(new TableModelListener() {
            @Override
            public void tableChanged(TableModelEvent e) {
                updateBtnUI();
            }
        });

        JScrollPane spex = new JScrollPane(fullnameDisplayTxt, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
        CellConstraints cc = new CellConstraints();
        PanelBuilder pb = new PanelBuilder(
                new FormLayout("p,2px,p,250px,f:p:g", "p,4px,min(p;250px),4px,p,4px,65px,2px,p"), this);

        JScrollPane sp = createScrollPane(table);
        sp.getViewport().setBackground(Color.WHITE);

        String lbl = getLocalizedMessage(descKey, classTitle);
        pb.add(createLabel(lbl, SwingConstants.CENTER), cc.xyw(1, 1, 4));
        pb.add(sp, cc.xyw(1, 3, 5));

        pb.add(createI18NFormLabel("DIRECTION"), cc.xy(1, 5));
        pb.add(directionCBX, cc.xy(3, 5));

        pb.add(createI18NFormLabel("EXAMPLE"), cc.xy(1, 7));
        pb.add(spex, cc.xywh(3, 7, 2, 3));

        makeTableHeadersCentered(table, true);

        directionCBX.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                updateBtnUI();
            }
        });

        table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
            @Override
            public void valueChanged(ListSelectionEvent e) {
                if (!e.getValueIsAdjusting()) {
                    updateBtnUI();

                    int inx = table.getSelectedColumn();
                    if (inx > -1) {
                        TreeDefRow row = treeDefList.get(table.getSelectedRow());
                        String msgKey = null;

                        if (row.isRequired() && (inx == 1 || inx == 3)) {
                            msgKey = inx == 1 ? "NO_CHANGE_INCL" : "NO_CHANGE_REQ";

                        } else if (inx == 4 && !row.isIncluded()) {
                            msgKey = "NO_CHANGE_INFN";
                        }

                        if (msgKey != null) {
                            final String mk = msgKey;
                            SwingUtilities.invokeLater(new Runnable() {
                                @Override
                                public void run() {
                                    showLocalizedMsg(mk);
                                }
                            });
                        }
                    }
                }
            }
        });

        updateBtnUI();
    }
}

From source file:edu.ku.brc.specify.plugins.TaxonLabelFormatting.java

@Override
public void initialize(Properties propertiesArg, boolean isViewModeArg) {
    super.initialize(propertiesArg, isViewModeArg);

    String plName = "TaxonLabelFormatter";
    PickListDBAdapterIFace adapter = PickListDBAdapterFactory.getInstance().create(plName, false);
    if (adapter == null || adapter.getPickList() == null) {
        throw new RuntimeException("PickList Adapter [" + plName + "] cannot be null!");
    }//from   w  ww  . j  a  va 2 s.  co m
    formatCBX = new ValComboBox(adapter);
    formatCBX.getComboBox().addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            doFormatting();
        }
    });
    formatCBX.getComboBox().addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            doFormatting();
        }
    });

    newAgentBtn = createButton(""); // Label set when new Resource Bundle is installed (below)
    searchPanel = new DBObjSearchPanel("Search", "AgentNameSearch", "AgentNameSearch",
            "edu.ku.brc.specify.datamodel.Agent", "agentId", SwingConstants.BOTTOM);
    searchPanel.getScrollPane().setMinimumSize(new Dimension(100, 200));
    searchPanel.getScrollPane().setPreferredSize(new Dimension(100, 150));
    ((FormViewObj) searchPanel.getForm()).getPanel().setBorder(null);

    try {
        UIRegistry.loadAndPushResourceBundle("specify_plugins");

        newAgentBtn.setText(getResourceString("NewAgent"));

        authorsList = new JList(new DefaultListModel());
        authorsList.setVisibleRowCount(10);
        authorsList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
                if (!e.getValueIsAdjusting()) {
                    Object selObj = authorsList.getSelectedValue();
                    if (selObj != null) {

                    }
                    updateEnabledState();
                }
            }
        });
        JScrollPane scrollPane = new JScrollPane(authorsList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

        mapToBtn = createIconBtn("Map", "ADD_AUTHOR_NAME_TT", new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                Object agent = searchPanel.getSelectedObject();
                ((DefaultListModel) authorsList.getModel()).addElement(agent);
                doFormatting();
            }
        });
        unmapBtn = createIconBtn("Unmap", "REMOVE_AUTHOR_NAME_TT", new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                int index = authorsList.getSelectedIndex();
                if (index > -1) {
                    DefaultListModel model = (DefaultListModel) authorsList.getModel();
                    model.remove(index);
                    updateEnabledState();
                    doFormatting();
                }
            }
        });

        upBtn = createIconBtn("ReorderUp", "MOVE_AUTHOR_NAME_UP", new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                DefaultListModel model = (DefaultListModel) authorsList.getModel();
                int index = authorsList.getSelectedIndex();
                Object item = authorsList.getSelectedValue();
                model.remove(index);
                model.insertElementAt(item, index - 1);
                authorsList.setSelectedIndex(index - 1);
                updateEnabledState();
            }
        });
        downBtn = createIconBtn("ReorderDown", "MOVE_AUTHOR_NAME_DOWN", new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                DefaultListModel model = (DefaultListModel) authorsList.getModel();
                int index = authorsList.getSelectedIndex();
                Object item = authorsList.getSelectedValue();
                model.remove(index);
                model.insertElementAt(item, index + 1);
                authorsList.setSelectedIndex(index + 1);
                updateEnabledState();
            }
        });

        PanelBuilder bldr = new PanelBuilder(new FormLayout("p, 5px, p, 5px, f:p:g, 2px, p",
                "p, 4px, p, 2px, f:p:g, 4px, p, 4px, p, 2px, p, 2px, p, 2px, p"), this);
        CellConstraints cc = new CellConstraints();

        PanelBuilder upDownPanel = new PanelBuilder(new FormLayout("p", "p, 2px, p, f:p:g"));
        upDownPanel.add(upBtn, cc.xy(1, 1));
        upDownPanel.add(downBtn, cc.xy(1, 3));

        PanelBuilder middlePanel = new PanelBuilder(new FormLayout("c:p:g", "f:p:g, p, 2px, p, f:p:g"));
        middlePanel.add(mapToBtn, cc.xy(1, 2));
        middlePanel.add(unmapBtn, cc.xy(1, 4));

        PanelBuilder rwPanel = new PanelBuilder(new FormLayout("p, 2px, f:p:g", "p"));
        refWorkLabel = createLabel(getResourceString("NONE"));
        rwPanel.add(createI18NFormLabel("REFERENCEWORK"), cc.xy(1, 1));
        rwPanel.add(refWorkLabel, cc.xy(3, 1));

        int y = 1;

        bldr.add(rwPanel.getPanel(), cc.xywh(1, y, 7, 1));
        y += 2;

        bldr.add(searchPanel, cc.xywh(1, y, 1, 3));
        bldr.addSeparator(getResourceString("Authors"), cc.xy(5, y));
        y += 2;

        bldr.add(middlePanel.getPanel(), cc.xy(3, y));
        bldr.add(scrollPane, cc.xywh(5, y, 1, 3));
        bldr.add(upDownPanel.getPanel(), cc.xy(7, y));
        y += 2;

        PanelBuilder newAgentPanel = new PanelBuilder(new FormLayout("f:p:g,p", "p"));
        newAgentPanel.add(newAgentBtn, cc.xy(2, 1));

        bldr.add(newAgentPanel.getPanel(), cc.xy(1, y));
        y += 2;

        JLabel fmtLabel = createLabel(getResourceString("LABELFORMAT"));
        bldr.add(fmtLabel, cc.xy(1, y));
        y += 2;
        bldr.add(formatCBX, cc.xywh(1, y, 7, 1));
        y += 2;

        Font plain = fmtLabel.getFont();
        specialLabel = new SpecialLabel(plain, new Font(plain.getName(), Font.ITALIC, plain.getSize()));
        specialLabel.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
        bldr.add(createLabel(getResourceString("SAMPLEOUTPUT") + ":"), cc.xywh(1, y, 7, 1));
        y += 2;
        bldr.add(specialLabel, cc.xywh(1, y, 7, 1));

        searchPanel.setOKBtn(mapToBtn);
    } catch (Exception ex) {
        edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
        edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(TaxonLabelFormatting.class, ex);
        log.error(ex);
        ex.printStackTrace();
    }
    UIRegistry.popResourceBundle();
}

From source file:edu.ku.brc.specify.utilapps.DataModelClassGenerator.java

/**
 * @param dataClass/*w w w  .j  a  v a2s .c  o  m*/
 * @param tableId
 */
public DataModelClassGenerator(final Class<?> dataClass) {
    this.dataClass = dataClass;

    Class<?>[] baseClasses = { Boolean.class, Integer.class, Double.class, String.class, Float.class,
            Character.class, Short.class, Byte.class, BigDecimal.class, Date.class, Calendar.class };
    for (Class<?> cls : baseClasses) {
        baseClassHash.put(cls.getSimpleName(), true);
    }

    int cnt = 0;
    for (Field field : dataClass.getDeclaredFields()) {
        if (field.getType() == String.class || Collection.class.isAssignableFrom(field.getType())) {
            cnt++;
        }
    }
    Font font = new Font("Courier", Font.PLAIN, 10);

    logArea = new JTextArea();
    logArea.setFont(font);

    tableIdTxt = new JTextField(10);
    devTxt = new JTextField(10);

    PanelBuilder outer = new PanelBuilder(new FormLayout("p,2px,p,2px,f:p:g", "200px:g,4px,f:300px:g,4px,p"));

    PanelBuilder pb = new PanelBuilder(new FormLayout("p,2px,p,2px,l:p:g,2px,l:p",
            UIHelper.createDuplicateJGoodiesDef("p", "2px", cnt + 2)));
    CellConstraints cc = new CellConstraints();

    pb.add(new JLabel("Table Id"), cc.xy(1, 1));
    pb.add(tableIdTxt, cc.xywh(3, 1, 3, 1));

    pb.add(new JLabel("Dev"), cc.xy(1, 3));
    pb.add(devTxt, cc.xywh(3, 3, 3, 1));

    int y = 5;
    for (Field field : dataClass.getDeclaredFields()) {
        if (field.getType() == String.class) {
            UIRow row = new UIRow(DataType.String, field);
            pb.add(new JLabel(field.getName()), cc.xy(1, y));
            pb.add(row.getSizetxt(), cc.xywh(3, y, 1, 1));
            y += 2;
            rows.add(row);
            fieldRowhash.put(field, row);
        }

        if (Collection.class.isAssignableFrom(field.getType())) {
            UIRow row = new UIRow(DataType.Set, field);
            pb.add(new JLabel(field.getName()), cc.xy(1, y));
            pb.add(row.getSizetxt(), cc.xywh(3, y, 3, 1));
            pb.add(new JLabel("(Set)", SwingConstants.LEFT), cc.xy(7, y));
            y += 2;
            rows.add(row);
            fieldRowhash.put(field, row);
        }
    }

    JButton processBtn = UIHelper.createButton("Process");
    JButton cancelBtn = UIHelper.createButton("Cancel");

    processBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            process();
        }
    });

    cancelBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setVisible(false);
        }
    });
    pb.getPanel().setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));

    JPanel panel = ButtonBarFactory.buildGrowingBar(new JButton[] { processBtn, cancelBtn });

    outer.add(new JScrollPane(pb.getPanel(), ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED), cc.xywh(1, 1, 5, 1));
    outer.add(new JScrollPane(logArea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED), cc.xywh(1, 3, 5, 1));
    outer.add(panel, cc.xy(5, 5));
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    JPanel p = new JPanel(new BorderLayout());
    p.add(outer.getPanel(), BorderLayout.CENTER);
    setContentPane(p);
    //setSize(500,500);
    pack();
    setSize(500, getSize().height);
}

From source file:dk.dma.epd.common.prototype.gui.notification.ChatServicePanel.java

/**
 * Constructor//  w  ww. j  a v  a2 s.  c  o  m
 * 
 * @param compactLayout
 *            if false, there will be message type selectors in the panel
 */
public ChatServicePanel(boolean compactLayout) {
    super(new BorderLayout());

    // Prepare the title header
    titleHeader.setBackground(getBackground().darker());
    titleHeader.setOpaque(true);
    titleHeader.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    titleHeader.setHorizontalAlignment(SwingConstants.CENTER);
    add(titleHeader, BorderLayout.NORTH);

    // Add messages panel
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    messagesPanel.setBackground(UIManager.getColor("List.background"));
    messagesPanel.setOpaque(false);
    messagesPanel.setLayout(new GridBagLayout());
    messagesPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    add(scrollPane, BorderLayout.CENTER);

    JPanel sendPanel = new JPanel(new GridBagLayout());
    add(sendPanel, BorderLayout.SOUTH);
    Insets insets = new Insets(2, 2, 2, 2);

    // Add text area
    if (compactLayout) {
        messageText = new JTextField();
        ((JTextField) messageText).addActionListener(this);
        sendPanel.add(messageText, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, NORTH, BOTH, insets, 0, 0));

    } else {
        messageText = new JTextArea();
        JScrollPane scrollPane2 = new JScrollPane(messageText);
        scrollPane2.setPreferredSize(new Dimension(100, 50));
        scrollPane2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        scrollPane2.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
        sendPanel.add(scrollPane2, new GridBagConstraints(0, 0, 1, 2, 1.0, 1.0, NORTH, BOTH, insets, 0, 0));
    }

    // Add buttons
    ButtonGroup group = new ButtonGroup();
    messageTypeBtn = createMessageTypeButton("Send messages", ICON_MESSAGE, true, group);
    warningTypeBtn = createMessageTypeButton("Send warnings", ICON_WARNING, false, group);
    alertTypeBtn = createMessageTypeButton("Send alerts", ICON_ALERT, false, group);

    if (!compactLayout) {
        JToolBar msgTypePanel = new JToolBar();
        msgTypePanel.setBorderPainted(false);
        msgTypePanel.setOpaque(true);
        msgTypePanel.setFloatable(false);
        sendPanel.add(msgTypePanel, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, NORTH, NONE, insets, 0, 0));
        msgTypePanel.add(messageTypeBtn);
        msgTypePanel.add(warningTypeBtn);
        msgTypePanel.add(alertTypeBtn);
    }

    if (compactLayout) {
        sendBtn = new JButton("Send");
        sendPanel.add(sendBtn, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, NORTH, NONE, insets, 0, 0));
    } else {
        sendBtn = new JButton("Send", ICON_MESSAGE);
        sendBtn.setPreferredSize(new Dimension(100, sendBtn.getPreferredSize().height));
        sendPanel.add(sendBtn, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, NORTH, NONE, insets, 0, 0));
    }
    sendBtn.setEnabled(false);
    messageText.setEditable(false);
    sendBtn.addActionListener(this);
}