Example usage for javax.swing SwingConstants LEFT

List of usage examples for javax.swing SwingConstants LEFT

Introduction

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

Prototype

int LEFT

To view the source code for javax.swing SwingConstants LEFT.

Click Source Link

Document

Box-orientation constant used to specify the left side of a box.

Usage

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

/**
 * @param dataClass/*from w w w  .j  av  a2 s.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:be.ugent.maf.cellmissy.gui.controller.analysis.singlecell.filtering.SingleCutOffFilteringController.java

/**
 * Initialize the main view./* w  w  w .j  ava  2s.  c o m*/
 */
private void initMainView() {
    // make a new view
    singleCutOffPanel = new SingleCutOffPanel();
    singleCutOffPanel.getMedianDisplList().setModel(new DefaultListModel());
    // action listeners
    singleCutOffPanel.getApplyCutOffButton().addActionListener((ActionEvent e) -> {
        // try to read the user-inserted values for up and down limit
        // check for number format exception
        try {
            cutOff = Double.parseDouble(singleCutOffPanel.getCutOffTextField().getText());
            FilterSwingWorker filterSwingWorker = new FilterSwingWorker();
            filterSwingWorker.execute();
        } catch (NumberFormatException ex) {
            // warn the user and log the error for info
            filteringController.showMessage(
                    "Please insert a valid number for the cut-off!" + "\n " + ex.getMessage(),
                    "number format exception", JOptionPane.ERROR_MESSAGE);
            LOG.error(ex.getMessage());
        }
    });

    AlignedTableRenderer alignedTableRenderer = new AlignedTableRenderer(SwingConstants.LEFT);
    for (int i = 0; i < singleCutOffPanel.getSummaryTable().getColumnModel().getColumnCount(); i++) {
        singleCutOffPanel.getSummaryTable().getColumnModel().getColumn(i).setCellRenderer(alignedTableRenderer);
    }
    singleCutOffPanel.getSummaryTable().getTableHeader()
            .setDefaultRenderer(new TableHeaderRenderer(SwingConstants.LEFT));

    // add view to parent container
    filteringController.getFilteringPanel().getSingleCutOffParentPanel().add(singleCutOffPanel,
            gridBagConstraints);
}

From source file:edu.ku.brc.ui.GradiantButton.java

/**
 * Paints the text of the control/* w  ww  . j  a  v  a  2 s . c  om*/
 * @param g2 the graphics to be painted into
 * @param w the width of the control
 * @param h the height of the control
 * @param text the string
 */
protected void drawText(Graphics2D g2, int w, int h, String text) {
    // calculate the width and height
    int fw = g2.getFontMetrics().stringWidth(text);
    int fh = g2.getFontMetrics().getAscent() - g2.getFontMetrics().getDescent();

    int textx = this.getHorizontalAlignment() == SwingConstants.LEFT ? Math.max(getInsets().left, 2)
            : (w - fw) / 2;
    int texty = h / 2 + fh / 2;

    // draw the text
    g2.setColor(textColorShadow);
    g2.drawString(text, textx, texty);
    g2.setColor(textColor);
    g2.drawString(text, textx, texty);

}

From source file:com.digitalgeneralists.assurance.ui.components.SettingsPanel.java

@Override
protected void initializeComponent() {
    if (!this.initialized) {
        this.dialogTitle = Application.applicationShortName + " Settings";

        // NOTE:  There is no notion of add-mode in this dialog.  There should
        // always be a single instance of the application configuration.
        if (this.configuration == null) {
            this.configuration = ApplicationConfiguration.createDefaultConfiguration();
        }//from   w w  w  .  j  a v  a 2 s.  c o m
        this.mode = AssuranceDialogMode.EDIT;

        GridBagLayout gridbag = new GridBagLayout();
        this.setLayout(gridbag);

        final JPanel scanSettingsPanel = new JPanel();
        scanSettingsPanel.setLayout(new GridBagLayout());

        Border scanSettingsPanelBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
        scanSettingsPanelBorder = BorderFactory.createTitledBorder(scanSettingsPanelBorder, "Scan Settings",
                TitledBorder.CENTER, TitledBorder.TOP);

        GridBagConstraints scanSettingsPanelConstraints = new GridBagConstraints();
        scanSettingsPanelConstraints.anchor = GridBagConstraints.NORTH;
        scanSettingsPanelConstraints.fill = GridBagConstraints.HORIZONTAL;
        scanSettingsPanelConstraints.gridx = 0;
        scanSettingsPanelConstraints.gridy = 0;
        scanSettingsPanelConstraints.weightx = 1.0;
        scanSettingsPanelConstraints.weighty = 1.0;
        scanSettingsPanelConstraints.gridheight = 1;
        scanSettingsPanelConstraints.gridwidth = 2;
        scanSettingsPanelConstraints.insets = new Insets(5, 5, 5, 5);

        scanSettingsPanel.setBorder(scanSettingsPanelBorder);
        this.add(scanSettingsPanel, scanSettingsPanelConstraints);

        GridBagConstraints ignoredFileNamesLabelConstraints = new GridBagConstraints();
        ignoredFileNamesLabelConstraints.anchor = GridBagConstraints.NORTHWEST;
        ignoredFileNamesLabelConstraints.fill = GridBagConstraints.NONE;
        ignoredFileNamesLabelConstraints.gridx = 0;
        ignoredFileNamesLabelConstraints.gridy = 0;
        ignoredFileNamesLabelConstraints.weightx = 1.0;
        ignoredFileNamesLabelConstraints.weighty = 1.0;
        ignoredFileNamesLabelConstraints.gridheight = 1;
        ignoredFileNamesLabelConstraints.gridwidth = 1;
        ignoredFileNamesLabelConstraints.insets = new Insets(5, 10, 0, 5);

        final JLabel ignoredFileNamesLabel = new JLabel("Ignored Files", SwingConstants.LEFT);
        scanSettingsPanel.add(ignoredFileNamesLabel, ignoredFileNamesLabelConstraints);

        GridBagConstraints ignoredFileNamesTextFieldConstraints = new GridBagConstraints();
        ignoredFileNamesTextFieldConstraints.anchor = GridBagConstraints.NORTH;
        ignoredFileNamesTextFieldConstraints.fill = GridBagConstraints.HORIZONTAL;
        ignoredFileNamesTextFieldConstraints.gridx = 0;
        ignoredFileNamesTextFieldConstraints.gridy = 1;
        ignoredFileNamesTextFieldConstraints.weightx = 1.0;
        ignoredFileNamesTextFieldConstraints.weighty = 1.0;
        ignoredFileNamesTextFieldConstraints.gridheight = 1;
        ignoredFileNamesTextFieldConstraints.gridwidth = 2;
        ignoredFileNamesTextFieldConstraints.insets = new Insets(2, 5, 5, 5);

        GridBagConstraints ignoredFileExtensionsLabelConstraints = new GridBagConstraints();
        ignoredFileExtensionsLabelConstraints.anchor = GridBagConstraints.NORTHWEST;
        ignoredFileExtensionsLabelConstraints.fill = GridBagConstraints.NONE;
        ignoredFileExtensionsLabelConstraints.gridx = 0;
        ignoredFileExtensionsLabelConstraints.gridy = 2;
        ignoredFileExtensionsLabelConstraints.weightx = 1.0;
        ignoredFileExtensionsLabelConstraints.weighty = 1.0;
        ignoredFileExtensionsLabelConstraints.gridheight = 1;
        ignoredFileExtensionsLabelConstraints.gridwidth = 1;
        ignoredFileExtensionsLabelConstraints.insets = new Insets(5, 10, 0, 5);

        final JLabel ignoredFileExtensionsLabel = new JLabel("Ignored File Extensions", SwingConstants.LEFT);
        scanSettingsPanel.add(ignoredFileExtensionsLabel, ignoredFileExtensionsLabelConstraints);

        GridBagConstraints ignoredFileExtensionsTextFieldConstraints = new GridBagConstraints();
        ignoredFileExtensionsTextFieldConstraints.anchor = GridBagConstraints.NORTH;
        ignoredFileExtensionsTextFieldConstraints.fill = GridBagConstraints.HORIZONTAL;
        ignoredFileExtensionsTextFieldConstraints.gridx = 0;
        ignoredFileExtensionsTextFieldConstraints.gridy = 3;
        ignoredFileExtensionsTextFieldConstraints.weightx = 1.0;
        ignoredFileExtensionsTextFieldConstraints.weighty = 1.0;
        ignoredFileExtensionsTextFieldConstraints.gridheight = 1;
        ignoredFileExtensionsTextFieldConstraints.gridwidth = 2;
        ignoredFileExtensionsTextFieldConstraints.insets = new Insets(2, 5, 5, 5);

        scanSettingsPanel.add(this.ignoredFileNamesTextField, ignoredFileNamesTextFieldConstraints);
        this.ignoredFileNamesTextField.getDocument().addDocumentListener(this.textPropertyValidationListener);
        scanSettingsPanel.add(this.ignoredFileExtensionsTextField, ignoredFileExtensionsTextFieldConstraints);
        this.ignoredFileExtensionsTextField.getDocument()
                .addDocumentListener(this.textPropertyValidationListener);

        GridBagConstraints numberScanThreadsLabelConstraints = new GridBagConstraints();
        numberScanThreadsLabelConstraints.anchor = GridBagConstraints.NORTH;
        numberScanThreadsLabelConstraints.fill = GridBagConstraints.NONE;
        numberScanThreadsLabelConstraints.gridx = 0;
        numberScanThreadsLabelConstraints.gridy = 4;
        numberScanThreadsLabelConstraints.weightx = 1.0;
        numberScanThreadsLabelConstraints.weighty = 1.0;
        numberScanThreadsLabelConstraints.gridheight = 1;
        numberScanThreadsLabelConstraints.gridwidth = 1;
        numberScanThreadsLabelConstraints.insets = new Insets(10, 5, 0, 5);

        final JLabel numberOfThreadsLabel = new JLabel("Number of Threads", SwingConstants.RIGHT);
        scanSettingsPanel.add(numberOfThreadsLabel, numberScanThreadsLabelConstraints);

        GridBagConstraints numberScanThreadsSpinnerConstraints = new GridBagConstraints();
        numberScanThreadsSpinnerConstraints.anchor = GridBagConstraints.NORTHWEST;
        numberScanThreadsSpinnerConstraints.fill = GridBagConstraints.NONE;
        numberScanThreadsSpinnerConstraints.gridx = 1;
        numberScanThreadsSpinnerConstraints.gridy = 4;
        numberScanThreadsSpinnerConstraints.weightx = 1.0;
        numberScanThreadsSpinnerConstraints.weighty = 1.0;
        numberScanThreadsSpinnerConstraints.gridheight = 1;
        numberScanThreadsSpinnerConstraints.gridwidth = 1;
        numberScanThreadsSpinnerConstraints.insets = new Insets(5, 5, 5, 5);

        scanSettingsPanel.add(this.numberScanThreadsSpinner, numberScanThreadsSpinnerConstraints);

        if (this.configuration != null) {
            this.ignoredFileNamesTextField.setText(this.configuration.getIgnoredFileNames());
            this.ignoredFileExtensionsTextField.setText(this.configuration.getIgnoredFileExtensions());
            this.numberScanThreadsSpinner.setValue(this.configuration.getNumberOfScanThreads());
        }

        this.initialized = true;
    }
}

From source file:au.org.ala.delta.intkey.ui.DefineButtonDialog.java

public DefineButtonDialog(Frame owner, boolean modal) {
    super(owner, modal);
    setPreferredSize(new Dimension(500, 430));

    ResourceMap resourceMap = Application.getInstance().getContext().getResourceMap(DefineButtonDialog.class);
    resourceMap.injectFields(this);
    ActionMap actionMap = Application.getInstance().getContext().getActionMap(DefineButtonDialog.class, this);

    setTitle(title);/*from w  w  w .j a va2s. c o m*/

    _okButtonPressed = false;

    _pnlButtons = new JPanel();
    getContentPane().add(_pnlButtons, BorderLayout.SOUTH);

    _btnOk = new JButton();
    _btnOk.setAction(actionMap.get("DefineButtonDialog_OK"));
    _pnlButtons.add(_btnOk);

    _btnCancel = new JButton();
    _btnCancel.setAction(actionMap.get("DefineButtonDialog_Cancel"));
    _pnlButtons.add(_btnCancel);

    _btnHelp = new JButton();
    _btnHelp.setAction(actionMap.get("DefineButtonDialog_Help"));
    _btnHelp.setEnabled(false);
    _pnlButtons.add(_btnHelp);

    _pnlMain = new JPanel();
    getContentPane().add(_pnlMain, BorderLayout.CENTER);
    _pnlMain.setLayout(new BorderLayout(5, 0));

    _pnlButtonProperties = new JPanel();
    _pnlButtonProperties.setBorder(new CompoundBorder(new EmptyBorder(5, 5, 5, 5), new CompoundBorder(
            new EtchedBorder(EtchedBorder.LOWERED, null, null), new EmptyBorder(5, 5, 5, 5))));
    _pnlMain.add(_pnlButtonProperties, BorderLayout.NORTH);
    GridBagLayout gbl__pnlButtonProperties = new GridBagLayout();
    gbl__pnlButtonProperties.columnWidths = new int[] { 475, 0 };
    gbl__pnlButtonProperties.rowHeights = new int[] { 14, 23, 14, 20, 14, 20, 14, 0, 23, 23, 23, 23, 0 };
    gbl__pnlButtonProperties.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
    gbl__pnlButtonProperties.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
            0.0, Double.MIN_VALUE };
    _pnlButtonProperties.setLayout(gbl__pnlButtonProperties);

    _lblEnterNameOf = new JLabel(enterFileNameCaption);
    _lblEnterNameOf.setHorizontalAlignment(SwingConstants.LEFT);
    GridBagConstraints gbc__lblEnterNameOf = new GridBagConstraints();
    gbc__lblEnterNameOf.anchor = GridBagConstraints.WEST;
    gbc__lblEnterNameOf.insets = new Insets(0, 0, 5, 0);
    gbc__lblEnterNameOf.gridx = 0;
    gbc__lblEnterNameOf.gridy = 0;
    _pnlButtonProperties.add(_lblEnterNameOf, gbc__lblEnterNameOf);

    _pnlFile = new JPanel();
    GridBagConstraints gbc__pnlFile = new GridBagConstraints();
    gbc__pnlFile.fill = GridBagConstraints.HORIZONTAL;
    gbc__pnlFile.insets = new Insets(0, 0, 5, 0);
    gbc__pnlFile.gridx = 0;
    gbc__pnlFile.gridy = 1;
    _pnlButtonProperties.add(_pnlFile, gbc__pnlFile);
    _pnlFile.setLayout(new BorderLayout(0, 0));

    _txtFldFileName = new JTextField();
    _pnlFile.add(_txtFldFileName, BorderLayout.CENTER);
    _txtFldFileName.setColumns(10);

    _btnBrowse = new JButton();
    _btnBrowse.setAction(actionMap.get("DefineButtonDialog_Browse"));
    _pnlFile.add(_btnBrowse, BorderLayout.EAST);

    _lblEnterTheCommands = new JLabel(enterCommandsCaption);
    _lblEnterTheCommands.setHorizontalAlignment(SwingConstants.LEFT);
    GridBagConstraints gbc__lblEnterTheCommands = new GridBagConstraints();
    gbc__lblEnterTheCommands.anchor = GridBagConstraints.WEST;
    gbc__lblEnterTheCommands.insets = new Insets(0, 0, 5, 0);
    gbc__lblEnterTheCommands.gridx = 0;
    gbc__lblEnterTheCommands.gridy = 2;
    _pnlButtonProperties.add(_lblEnterTheCommands, gbc__lblEnterTheCommands);

    _txtFldCommands = new JTextField();
    GridBagConstraints gbc__txtFldCommands = new GridBagConstraints();
    gbc__txtFldCommands.fill = GridBagConstraints.HORIZONTAL;
    gbc__txtFldCommands.insets = new Insets(0, 0, 5, 0);
    gbc__txtFldCommands.gridx = 0;
    gbc__txtFldCommands.gridy = 3;
    _pnlButtonProperties.add(_txtFldCommands, gbc__txtFldCommands);
    _txtFldCommands.setColumns(10);

    _lblEnterBriefHelp = new JLabel(enterBriefHelpCaption);
    _lblEnterBriefHelp.setAlignmentY(Component.TOP_ALIGNMENT);
    GridBagConstraints gbc__lblEnterBriefHelp = new GridBagConstraints();
    gbc__lblEnterBriefHelp.anchor = GridBagConstraints.NORTHWEST;
    gbc__lblEnterBriefHelp.insets = new Insets(0, 0, 5, 0);
    gbc__lblEnterBriefHelp.gridx = 0;
    gbc__lblEnterBriefHelp.gridy = 4;
    _pnlButtonProperties.add(_lblEnterBriefHelp, gbc__lblEnterBriefHelp);

    _txtFldBriefHelp = new JTextField();
    GridBagConstraints gbc__txtFldBriefHelp = new GridBagConstraints();
    gbc__txtFldBriefHelp.fill = GridBagConstraints.HORIZONTAL;
    gbc__txtFldBriefHelp.insets = new Insets(0, 0, 5, 0);
    gbc__txtFldBriefHelp.gridx = 0;
    gbc__txtFldBriefHelp.gridy = 5;
    _pnlButtonProperties.add(_txtFldBriefHelp, gbc__txtFldBriefHelp);
    _txtFldBriefHelp.setColumns(10);

    _lblEnterMoreDetailed = new JLabel(enterDetailedHelpCaption);
    GridBagConstraints gbc__lblEnterMoreDetailed = new GridBagConstraints();
    gbc__lblEnterMoreDetailed.anchor = GridBagConstraints.WEST;
    gbc__lblEnterMoreDetailed.insets = new Insets(0, 0, 5, 0);
    gbc__lblEnterMoreDetailed.gridx = 0;
    gbc__lblEnterMoreDetailed.gridy = 6;
    _pnlButtonProperties.add(_lblEnterMoreDetailed, gbc__lblEnterMoreDetailed);

    _txtFldDetailedHelp = new JTextField();
    GridBagConstraints gbc__txtFldDetailedHelp = new GridBagConstraints();
    gbc__txtFldDetailedHelp.insets = new Insets(0, 0, 5, 0);
    gbc__txtFldDetailedHelp.fill = GridBagConstraints.HORIZONTAL;
    gbc__txtFldDetailedHelp.gridx = 0;
    gbc__txtFldDetailedHelp.gridy = 7;
    _pnlButtonProperties.add(_txtFldDetailedHelp, gbc__txtFldDetailedHelp);
    _txtFldDetailedHelp.setColumns(10);

    _chckbxEnableOnlyIfUsedCharacters = new JCheckBox(enableOnlyIfUsedCaption);
    GridBagConstraints gbc__chckbxEnableOnlyIf = new GridBagConstraints();
    gbc__chckbxEnableOnlyIf.anchor = GridBagConstraints.WEST;
    gbc__chckbxEnableOnlyIf.insets = new Insets(0, 0, 5, 0);
    gbc__chckbxEnableOnlyIf.gridx = 0;
    gbc__chckbxEnableOnlyIf.gridy = 8;
    _pnlButtonProperties.add(_chckbxEnableOnlyIfUsedCharacters, gbc__chckbxEnableOnlyIf);

    _rdbtnEnableInAll = new JRadioButton(enableInAllModesCaption);
    GridBagConstraints gbc__rdbtnEnableInAll = new GridBagConstraints();
    gbc__rdbtnEnableInAll.anchor = GridBagConstraints.WEST;
    gbc__rdbtnEnableInAll.insets = new Insets(0, 0, 5, 0);
    gbc__rdbtnEnableInAll.gridx = 0;
    gbc__rdbtnEnableInAll.gridy = 9;
    _pnlButtonProperties.add(_rdbtnEnableInAll, gbc__rdbtnEnableInAll);

    _rdbtnEnableInNormal = new JRadioButton(enableInNormalModeCaption);
    GridBagConstraints gbc__rdbtnEnableInNormal = new GridBagConstraints();
    gbc__rdbtnEnableInNormal.anchor = GridBagConstraints.WEST;
    gbc__rdbtnEnableInNormal.insets = new Insets(0, 0, 5, 0);
    gbc__rdbtnEnableInNormal.gridx = 0;
    gbc__rdbtnEnableInNormal.gridy = 10;
    _pnlButtonProperties.add(_rdbtnEnableInNormal, gbc__rdbtnEnableInNormal);

    _rdbtnEnableInAdvanced = new JRadioButton(enableInAdvancedModeCaption);
    GridBagConstraints gbc__rdbtnEnableInAdvanced = new GridBagConstraints();
    gbc__rdbtnEnableInAdvanced.anchor = GridBagConstraints.WEST;
    gbc__rdbtnEnableInAdvanced.gridx = 0;
    gbc__rdbtnEnableInAdvanced.gridy = 11;
    _pnlButtonProperties.add(_rdbtnEnableInAdvanced, gbc__rdbtnEnableInAdvanced);

    _pnlSpaceRemoveAll = new JPanel();
    _pnlSpaceRemoveAll.setBorder(new EmptyBorder(0, 10, 0, 0));
    _pnlMain.add(_pnlSpaceRemoveAll, BorderLayout.SOUTH);
    _pnlSpaceRemoveAll.setLayout(new BoxLayout(_pnlSpaceRemoveAll, BoxLayout.Y_AXIS));

    _chckbxInsertASpace = new JCheckBox(insertSpaceCaption);
    _chckbxInsertASpace.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            _insertSpace = !_insertSpace;

            if (_insertSpace) {
                _removeAllButtons = false;
                _chckbxRemoveAllButtons.setSelected(false);
            }

            updateButtonPropertyControls();
        }
    });
    _pnlSpaceRemoveAll.add(_chckbxInsertASpace);

    _chckbxRemoveAllButtons = new JCheckBox(removeAllCaption);
    _chckbxRemoveAllButtons.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            _removeAllButtons = !_removeAllButtons;

            if (_removeAllButtons) {
                _insertSpace = false;
                _chckbxInsertASpace.setSelected(false);
            }

            updateButtonPropertyControls();
        }
    });
    _pnlSpaceRemoveAll.add(_chckbxRemoveAllButtons);

    _pnlButtonProperties.setEnabled(false);

    ButtonGroup btnGroup = new ButtonGroup();
    btnGroup.add(_rdbtnEnableInAll);
    btnGroup.add(_rdbtnEnableInNormal);
    btnGroup.add(_rdbtnEnableInAdvanced);

    _rdbtnEnableInAll.setSelected(true);
}

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

/**
 * @param p/*w  w w  . j av a2s.c  o m*/
 * @param r
 * @param font
 * @param y
 * @param all
 * @return
 */
public JComponent build(final PanelBuilder p, final DBRelationshipInfo r, final Font font, final int y,
        boolean all) {
    String type = r.getType().toString().toLowerCase();
    type = getResourceString(type);

    CellConstraints cc = new CellConstraints();
    p.add(ERDVisualizer.mkLabel(font, StringUtils.substringAfterLast(r.getClassName(), "."),
            SwingConstants.LEFT), cc.xy(1, y));
    p.add(ERDVisualizer.mkLabel(font, StringUtils.capitalize(r.getTitle()), SwingConstants.LEFT), cc.xy(3, y));
    JComponent comp = ERDVisualizer.mkLabel(font, type, SwingConstants.CENTER);
    p.add(comp, cc.xy(5, y));
    if (all) {
        comp = ERDVisualizer.mkLabel(font, r.isRequired() ? yesStr : "", SwingConstants.CENTER);
        p.add(comp, cc.xy(7, y));
    }
    return comp;
}

From source file:geneticalgorithm.gui.view.VExperiment.java

public VExperiment() {
    setLayout(new BorderLayout());
    setSize(900, 700);/*  w w  w .  j a  va  2 s . c  o m*/
    setLocationRelativeTo(this);
    setResizable(false);
    buttons = new ArrayList<JButton>();

    // CENTER

    pnlCentral = new JPanel();
    pnlCentral.setLayout(new MigLayout());
    add(pnlCentral, BorderLayout.CENTER);

    lblLocale = new JLabel();
    cmbModelSelectLocale = new DefaultComboBoxModel<String>();
    cmbSelectLocale = new JComboBox<String>(cmbModelSelectLocale);

    lblLimLow = new JLabel();
    spiLow = new JSpinner();
    spiLow.setModel(new SpinnerNumberModel(-10., -100000., 100000., .5));

    lblLimUp = new JLabel();
    spiUp = new JSpinner();
    spiUp.setModel(new SpinnerNumberModel(10., -100000., 100000., .5));

    lblChromosome = new JLabel();
    spiChromosome = new JSpinner();
    spiChromosome.setModel(new SpinnerNumberModel(10, 0, 63, 1));

    lblPopulation = new JLabel();
    spiPopulation = new JSpinner();
    spiPopulation.setModel(new SpinnerNumberModel(10, 0, 100000, 1));

    lblGenerations = new JLabel();
    spiGenerations = new JSpinner();
    spiGenerations.setModel(new SpinnerNumberModel(100, 0, 100000, 1));

    lblProbCrossover = new JLabel();
    txtProbCrossover = new JTextField("0.5");

    lblProbMutation = new JLabel();
    txtProbMutation = new JTextField("0.001");

    lblIndividual = new JLabel();
    cmbModelIndividual = new DefaultComboBoxModel<ClassWrapper>();
    cmbIndividual = new JComboBox<ClassWrapper>(cmbModelIndividual);

    lblCrossover = new JLabel();
    cmbModelCrossover = new DefaultComboBoxModel<ClassWrapper>();
    cmbCrossover = new JComboBox<ClassWrapper>(cmbModelCrossover);

    lblMutation = new JLabel();
    cmbModelMutation = new DefaultComboBoxModel<ClassWrapper>();
    cmbMutation = new JComboBox<ClassWrapper>(cmbModelMutation);

    lblSelection = new JLabel();
    cmbModelSelection = new DefaultComboBoxModel<ClassWrapper>();
    cmbSelection = new JComboBox<ClassWrapper>(cmbModelSelection);

    lblFitness = new JLabel();
    cmbModelFitness = new DefaultComboBoxModel<ClassWrapper>();
    cmbFitness = new JComboBox<ClassWrapper>(cmbModelFitness);

    lblPathOutput = new JLabel();
    txtPathOutput = new JTextField();
    btnPathOutput = new JButton("...");

    lblName = new JLabel();
    txtName = new JTextField();

    lblAverage = new JLabel("");
    lblAverage.setHorizontalTextPosition(SwingConstants.LEFT);
    lblAverageTitle = new JLabel("Average: ");

    lblOffline = new JLabel("");
    lblOffline.setHorizontalTextPosition(SwingConstants.LEFT);
    lblOfflineTitle = new JLabel("Offline: ");

    lblOnline = new JLabel("");
    lblOnline.setHorizontalTextPosition(SwingConstants.LEFT);
    lblOnlineTitle = new JLabel("Online: ");

    lblElite = new JLabel("");
    lblElite.setHorizontalTextPosition(SwingConstants.LEFT);
    lblEliteTitle = new JLabel("Elite: ");

    average = new XYSeries("Average");
    offline = new XYSeries("Offline");
    online = new XYSeries("Online");
    elite = new XYSeries("Elite");

    dataset = new XYSeriesCollection();
    dataset.addSeries(average);
    dataset.addSeries(online);
    dataset.addSeries(elite);
    dataset.addSeries(offline);

    chart = ChartFactory.createXYLineChart("title", "xLabel", "yLabel", dataset, PlotOrientation.VERTICAL, true,
            true, false);
    chartPanel = new ChartPanel(chart);

    pnlCentral.add(lblLocale, "width 120, height 25");
    pnlCentral.add(cmbSelectLocale, "width 120, height 25, wrap");

    pnlCentral.add(lblLimLow, "width 120, height 25");
    pnlCentral.add(spiLow, "width 120, height 25");
    pnlCentral.add(lblIndividual, "width 80, height 25");
    pnlCentral.add(cmbIndividual, "growx, height 25, span 2, wrap");

    pnlCentral.add(lblLimUp, "width 120, height 25");
    pnlCentral.add(spiUp, "width 120, height 25");
    pnlCentral.add(lblCrossover, "width 80, height 25");
    pnlCentral.add(cmbCrossover, "growx, height 25, span 2, wrap");

    pnlCentral.add(lblChromosome, "width 120, height 25");
    pnlCentral.add(spiChromosome, "width 120, height 25");
    pnlCentral.add(lblMutation, "width 80, height 25");
    pnlCentral.add(cmbMutation, "growx, height 25, span 2, wrap");

    pnlCentral.add(lblPopulation, "width 120, height 25");
    pnlCentral.add(spiPopulation, "width 120, height 25");
    pnlCentral.add(lblSelection, "width 80, height 25");
    pnlCentral.add(cmbSelection, "growx, height 25, span 2");
    pnlCentral.add(lblAverageTitle, "width 70, height 25");
    pnlCentral.add(lblAverage, "width 200, height 25, wrap");

    pnlCentral.add(lblGenerations, "width 120, height 25");
    pnlCentral.add(spiGenerations, "width 120, height 25");
    pnlCentral.add(lblFitness, "width 80, height 25");
    pnlCentral.add(cmbFitness, "growx, height 25, span 2");
    pnlCentral.add(lblOnlineTitle, "growx, height 25");
    pnlCentral.add(lblOnline, "growx, height 25, wrap");

    pnlCentral.add(lblProbCrossover, "width 120, height 25");
    pnlCentral.add(txtProbCrossover, "width 120, height 25");
    pnlCentral.add(lblPathOutput, "width 80, height 25");
    pnlCentral.add(txtPathOutput, "width 280, height 25");
    pnlCentral.add(btnPathOutput, "width 20, height 25");
    pnlCentral.add(lblEliteTitle, "growx, height 25");
    pnlCentral.add(lblElite, "growx, height 25, wrap");

    pnlCentral.add(lblProbMutation, "width 120, height 25");
    pnlCentral.add(txtProbMutation, "width 120, height 25");
    pnlCentral.add(lblName, "width 80, height 25");
    pnlCentral.add(txtName, "growx, height 25, span 2");
    pnlCentral.add(lblOfflineTitle, "growx, height 25");
    pnlCentral.add(lblOffline, "growx, height 25, wrap");

    pnlCentral.add(chartPanel, "growx, span 7");

    // SOUTH
    pnlSouth = new JPanel();
    add(pnlSouth, BorderLayout.SOUTH);

    btnRun = new JButton();
    btnStop = new JButton();
    btnClose = new JButton();

    pnlSouth.add(btnRun);
    pnlSouth.add(btnStop);
    pnlSouth.add(btnClose);

    // ADD BUTTONS
    buttons.add(btnClose);
    buttons.add(btnStop);
    buttons.add(btnPathOutput);
    buttons.add(btnRun);
}

From source file:com.simplexrepaginator.RepaginateFrame.java

protected JButton createRepaginateButton() {
    JButton b = new JButton("<html><center>Click to<br>repaginate", REPAGINATE_ICON);

    b.setHorizontalTextPosition(SwingConstants.LEFT);
    b.setIconTextGap(25);//  www. ja  v a  2  s.  c o m

    b.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                int[] documentsPages = repaginator.repaginate();
                JOptionPane.showMessageDialog(RepaginateFrame.this,
                        "Repaginated " + documentsPages[0] + " documents with " + documentsPages[1] + " pages.",
                        "Repagination Complete", JOptionPane.INFORMATION_MESSAGE);
            } catch (Exception ex) {
                ex.printStackTrace();
                JOptionPane.showMessageDialog(RepaginateFrame.this, ex.toString(), "Error During Repagination",
                        JOptionPane.ERROR_MESSAGE);
            }
        }
    });

    return b;
}

From source file:au.com.jwatmuff.eventmanager.util.GUIUtils.java

public static void leftAlignTable(JTable table) {
    Enumeration<TableColumn> cols = table.getColumnModel().getColumns();
    while (cols.hasMoreElements()) {
        TableColumn col = cols.nextElement();
        final TableCellRenderer oldRenderer = col.getCellRenderer();
        if (oldRenderer == null) {
            col.setCellRenderer(new DefaultTableCellRenderer() {
                @Override//from  w  w w.  j  av  a 2s.c o m
                public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                        boolean hasFocus, int row, int column) {
                    Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row,
                            column);
                    if (c instanceof JLabel) {
                        ((JLabel) c).setHorizontalAlignment(SwingConstants.LEFT);
                    }
                    return c;
                }
            });
        } else {
            col.setCellRenderer(new TableCellRenderer() {
                @Override
                public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                        boolean hasFocus, int row, int column) {
                    Component c = oldRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus,
                            row, column);
                    if (c instanceof JLabel) {
                        ((JLabel) c).setHorizontalAlignment(SwingConstants.LEFT);
                    }
                    return c;
                }
            });
        }
    }
}

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

protected void buildUI() {
    CellConstraints cc = new CellConstraints();

    JLabel currentFieldsLbl = createI18NLabel("DOF_DISPLAY_FORMAT");
    formatEditor = new JTextPane();
    // to make sure the component shrinks with the dialog
    formatEditor.setMinimumSize(new Dimension(200, 50));
    formatEditor.setPreferredSize(new Dimension(350, 100));

    formatEditor.getDocument().addDocumentListener(new DocumentAdaptor() {
        @Override//w w  w.  j a  v  a2  s .  c  o m
        public void changed(DocumentEvent e) {
            updateUIEnabled();
        }
    });

    PanelBuilder addFieldPB = new PanelBuilder(new FormLayout("p,2px,p,f:p:g,r:m", "p,2px,p"));
    sepText = createTextField(4);
    addFieldBtn = createButton(getResourceString("DOF_ADD_FIELD"));
    sepLbl = createI18NFormLabel("DOF_SEP_TXT");

    addFieldPB.add(sepLbl, cc.xy(1, 1));
    addFieldPB.add(sepText, cc.xy(3, 1));
    addFieldPB.add(addFieldBtn, cc.xy(5, 1));

    sepText.setDocument(new FilteredDoc());

    addFieldBtn.setEnabled(false);
    sepLbl.setEnabled(false);
    sepText.setEnabled(false);

    // For when it is standalone
    if (AppPreferences.hasRemotePrefs()) {
        sepText.setText(AppPreferences.getRemote().get("DOF_SEP", ", "));

    } else {
        sepText.setText(", ");
    }

    PanelBuilder pb = new PanelBuilder(new FormLayout("f:d:g", "10px," + // empty space on top of panel 
            "p,f:p:g," + // Label & format text editor
            "2px,p," + // separator & add field
            "10px,p," + // separator & label
            "f:250px:g," // list box for available fields 
    ), this);

    // layout components on main panel        
    int y = 2; // leave first row blank

    pb.add(currentFieldsLbl, cc.xy(1, y));
    y += 1;
    pb.add(UIHelper.createScrollPane(formatEditor), cc.xy(1, y));
    y += 2;

    pb.add(addFieldPB.getPanel(), cc.xy(1, y));
    y += 2;

    JLabel availableFieldsLbl = createI18NFormLabel("DOF_AVAILABLE_FIELDS", SwingConstants.LEFT);
    pb.add(availableFieldsLbl, cc.xy(1, y));
    y += 1;

    // create field tree that will be re-used in all instances of single switch formatter editing panel
    availableFieldsComp = new AvailableFieldsComponent(tableInfo, dataObjFieldFormatMgrCache,
            uiFieldFormatterMgrCache);

    pb.add(UIHelper.createScrollPane(availableFieldsComp.getTree()), cc.xy(1, y));
    y += 2;

    availableFieldsComp.getTree().addTreeSelectionListener(new TreeSelectionListener() {
        @Override
        public void valueChanged(TreeSelectionEvent e) {
            boolean enable = availableFieldsComp.getTree().getSelectionCount() > 0;
            addFieldBtn.setEnabled(enable);
            sepText.setEnabled(enable);
            sepLbl.setEnabled(enable);
        }
    });

    this.mainPanelBuilder = pb;

    fillWithObjFormatter(formatContainer.getSelectedFormatter());

    addFormatTextListeners();

    // must be called after list of available fields has been created
    addFieldListeners();
}