Example usage for java.awt GridBagConstraints SOUTHWEST

List of usage examples for java.awt GridBagConstraints SOUTHWEST

Introduction

In this page you can find the example usage for java.awt GridBagConstraints SOUTHWEST.

Prototype

int SOUTHWEST

To view the source code for java.awt GridBagConstraints SOUTHWEST.

Click Source Link

Document

Put the component at the bottom-left corner of its display area.

Usage

From source file:GridBagWithAnchor.java

public static void main(String[] args) {
    JFrame f = new JFrame("Demonstrates the use of anchor constraints");
    JPanel p = new JPanel(new GridBagLayout());

    p.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(2, 2, 2, 2);
    c.weighty = 1.0;// w ww  .j  a  v a  2 s.  co m
    c.weightx = 1.0;
    c.gridx = 0;
    c.gridy = 0;
    c.gridheight = 2;
    c.anchor = GridBagConstraints.NORTH; // place component on the North
    p.add(new JButton("Java"), c);
    c.gridx = 1;
    c.gridheight = 1;
    c.gridwidth = 2;
    c.anchor = GridBagConstraints.SOUTHWEST;
    p.add(new JButton("Source"), c);
    c.gridy = 1;
    c.gridwidth = 1;
    c.anchor = GridBagConstraints.CENTER; // remember to rest to center
    p.add(new JButton("and"), c);
    c.gridx = 2;
    p.add(new JButton("Support !!!"), c);

    WindowListener wndCloser = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    f.addWindowListener(wndCloser);

    f.getContentPane().add(p);
    f.setSize(600, 200);
    f.show();
}

From source file:net.chaosserver.timelord.swingui.SummaryPanel.java

/**
 * Constructs the panel.// ww w. ja  v  a 2  s.  c o m
 */
protected void buildSummaryPanel() {
    GridBagLayout gridBagLayout = new GridBagLayout();
    GridBagConstraints gridBagConstraints = new GridBagConstraints();
    setLayout(gridBagLayout);

    if (isToday()) {
        JLabel remainderName = new JLabel("Remainder");
        gridBagConstraints.anchor = GridBagConstraints.SOUTHWEST;
        gridBagConstraints.weightx = LayoutConstants.HEAVY_WEIGHT;
        gridBagConstraints.insets = new Insets(0, LayoutConstants.SMALL_INSET, 0, LayoutConstants.BIG_INSET);
        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints.gridwidth = 1;
        gridBagLayout.addLayoutComponent(remainderName, gridBagConstraints);
        add(remainderName);

        timeLeftLabel = new JLabel();
        gridBagConstraints.anchor = GridBagConstraints.SOUTHEAST;
        gridBagConstraints.fill = GridBagConstraints.NONE;
        gridBagConstraints.weightx = 0;
        gridBagConstraints.insets = new Insets(0, LayoutConstants.BIG_INSET, 0, LayoutConstants.SMALL_INSET);
        gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
        gridBagLayout.addLayoutComponent(timeLeftLabel, gridBagConstraints);
        add(timeLeftLabel);
    }

    JLabel taskName = new JLabel("Total");
    gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
    gridBagConstraints.weightx = LayoutConstants.HEAVY_WEIGHT;
    gridBagConstraints.insets = new Insets(0, LayoutConstants.SMALL_INSET, 0, LayoutConstants.BIG_INSET);
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints.gridwidth = 1;
    gridBagLayout.addLayoutComponent(taskName, gridBagConstraints);
    add(taskName);

    totalTimeLabel = new JLabel();
    gridBagConstraints.anchor = GridBagConstraints.NORTHEAST;
    gridBagConstraints.fill = GridBagConstraints.NONE;
    gridBagConstraints.weightx = 0;
    gridBagConstraints.insets = new Insets(0, LayoutConstants.BIG_INSET, 0, LayoutConstants.SMALL_INSET);
    gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
    gridBagLayout.addLayoutComponent(totalTimeLabel, gridBagConstraints);
    add(totalTimeLabel);

    updateTotalTimeLabel();
    updateTimeLeftLabel();
}

From source file:com.limegroup.gnutella.gui.LicenseWindow.java

protected void createNotVerified() {
    GridBagConstraints c = new GridBagConstraints();
    JTextArea text = newTextArea(getNotVerifiedString());
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1;/*from w  ww .ja va 2s  .c  o  m*/
    c.weighty = 1;
    c.anchor = GridBagConstraints.NORTHWEST;
    DETAILS.add(text, c);

    JButton button = new JButton(getVerifyString());
    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            LICENSE.verify(LicenseWindow.this);
            buildDetails();
        }
    });
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0;
    c.weighty = 0;
    c.anchor = GridBagConstraints.SOUTHWEST;
    DETAILS.add(button, c);
}

From source file:de.juwimm.cms.gui.admin.PanUnitGroupPerUser.java

void jbInit() throws Exception {
    this.setLayout(new GridBagLayout());

    this.unitPickData = new PickListData();
    this.unitPickData.setLeftLabel(rb.getString("panel.admin.tab.units.assigned"));
    this.unitPickData.setRightLabel(rb.getString("panel.admin.tab.units.all"));
    this.groupPickData = new PickListData();
    this.groupPickData.setLeftLabel(rb.getString("panel.admin.tab.groups.assigned"));
    this.groupPickData.setRightLabel(rb.getString("panel.admin.tab.groups.all"));
    this.panUnitPick = new PickListPanel(this.unitPickData);
    this.panGroupPick = new PickListPanel(this.groupPickData);
    this.btnSave.setText(rb.getString("dialog.save"));
    this.lblUser.setText(rb.getString("panel.login.username"));

    this.btnSave.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            save();/*from  ww w .j a va 2s.c  om*/
        }
    });

    this.tblUser = new JTable();
    JScrollPane scrollUser = new NoResizeScrollPane(tblUser);

    this.add(lblUser, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST,
            GridBagConstraints.HORIZONTAL, new Insets(10, 10, 5, 0), 0, 0));
    this.add(scrollUser, new GridBagConstraints(0, 1, 1, 2, 1.0, 1.0, GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH, new Insets(0, 10, 0, 0), 0, 0));
    this.add(btnSave, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.SOUTHWEST,
            GridBagConstraints.NONE, new Insets(10, 10, 10, 0), 0, 0));
    this.add(this.panUnitPick, new GridBagConstraints(1, 0, 1, 2, 2.0, 1.0, GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH, new Insets(0, 10, 0, 10), 0, 0));
    this.add(this.panGroupPick, new GridBagConstraints(1, 2, 1, 1, 2.0, 1.0, GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH, new Insets(0, 10, 0, 10), 0, 0));
}

From source file:mekhq.gui.FinancesTab.java

@Override
public void initTab() {
    resourceMap = ResourceBundle.getBundle("mekhq.resources.FinancesTab", new EncodeControl()); //$NON-NLS-1$

    GridBagConstraints gridBagConstraints;

    setLayout(new GridBagLayout());
    ChartPanel financeAmountPanel = (ChartPanel) createGraphPanel(GraphType.BALANCE_AMOUNT);
    ChartPanel financeMonthlyPanel = (ChartPanel) createGraphPanel(GraphType.MONTHLY_FINANCES);

    financeModel = new FinanceTableModel();
    financeTable = new JTable(financeModel);
    financeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    financeTable.addMouseListener(new FinanceTableMouseAdapter(getCampaignGui(), financeTable, financeModel));
    financeTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    TableColumn column = null;/*from w  ww  .ja  va 2  s .co m*/
    for (int i = 0; i < FinanceTableModel.N_COL; i++) {
        column = financeTable.getColumnModel().getColumn(i);
        column.setPreferredWidth(financeModel.getColumnWidth(i));
        column.setCellRenderer(financeModel.getRenderer());
    }
    financeTable.setIntercellSpacing(new Dimension(0, 0));
    financeTable.setShowGrid(false);

    loanModel = new LoanTableModel();
    loanTable = new JTable(loanModel);
    loanTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    loanTable.addMouseListener(new LoanTableMouseAdapter(getCampaignGui(), loanTable, loanModel));
    loanTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    column = null;
    for (int i = 0; i < LoanTableModel.N_COL; i++) {
        column = loanTable.getColumnModel().getColumn(i);
        column.setPreferredWidth(loanModel.getColumnWidth(i));
        column.setCellRenderer(loanModel.getRenderer());
    }
    loanTable.setIntercellSpacing(new Dimension(0, 0));
    loanTable.setShowGrid(false);
    JScrollPane scrollLoanTable = new JScrollPane(loanTable);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    JPanel panBalance = new JPanel(new GridBagLayout());
    panBalance.add(new JScrollPane(financeTable), gridBagConstraints);
    panBalance.setMinimumSize(new java.awt.Dimension(350, 100));
    panBalance.setBorder(BorderFactory.createTitledBorder("Balance Sheet"));
    JPanel panLoan = new JPanel(new GridBagLayout());
    panLoan.add(scrollLoanTable, gridBagConstraints);

    JTabbedPane financeTab = new JTabbedPane();
    financeTab.setMinimumSize(new java.awt.Dimension(450, 300));
    financeTab.setPreferredSize(new java.awt.Dimension(450, 300));

    JSplitPane splitFinances = new JSplitPane(JSplitPane.VERTICAL_SPLIT, panBalance, financeTab);
    splitFinances.setOneTouchExpandable(true);
    splitFinances.setContinuousLayout(true);
    splitFinances.setResizeWeight(1.0);
    splitFinances.setName("splitFinances");

    financeTab.addTab(resourceMap.getString("activeLoans.text"), panLoan);
    financeTab.addTab(resourceMap.getString("cbillsBalanceTime.text"), financeAmountPanel);
    financeTab.addTab(resourceMap.getString("monthlyRevenueExpenditures.text"), financeMonthlyPanel);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    add(splitFinances, gridBagConstraints);

    JPanel panelFinanceRight = new JPanel(new BorderLayout());

    JPanel pnlFinanceBtns = new JPanel(new GridLayout(2, 2));
    btnAddFunds = new JButton("Add Funds (GM)");
    btnAddFunds.addActionListener(ev -> addFundsActionPerformed());
    btnAddFunds.setEnabled(getCampaign().isGM());
    pnlFinanceBtns.add(btnAddFunds);
    JButton btnGetLoan = new JButton("Get Loan");
    btnGetLoan.addActionListener(e -> showNewLoanDialog());
    pnlFinanceBtns.add(btnGetLoan);

    btnManageAssets = new JButton("Manage Assets (GM)");
    btnManageAssets.addActionListener(e -> manageAssets());
    btnManageAssets.setEnabled(getCampaign().isGM());
    pnlFinanceBtns.add(btnManageAssets);

    panelFinanceRight.add(pnlFinanceBtns, BorderLayout.NORTH);

    areaNetWorth = new JTextArea();
    areaNetWorth.setLineWrap(true);
    areaNetWorth.setWrapStyleWord(true);
    areaNetWorth.setFont(new Font("Courier New", Font.PLAIN, 12));
    areaNetWorth.setText(getCampaign().getFinancialReport());
    areaNetWorth.setEditable(false);

    JScrollPane descriptionScroll = new JScrollPane(areaNetWorth);
    panelFinanceRight.add(descriptionScroll, BorderLayout.CENTER);
    areaNetWorth.setCaretPosition(0);
    descriptionScroll.setMinimumSize(new Dimension(300, 200));

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridheight = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.weightx = 0.0;
    gridBagConstraints.weighty = 1.0;
    add(panelFinanceRight, gridBagConstraints);
}

From source file:edu.harvard.mcz.imagecapture.VerbatimClassifyDialog.java

protected void init() {
    setTitle("Interpret verbatim data into fields.");
    setBounds(100, 100, 1203, 899);//from  www  . j  ava 2  s.co m
    getContentPane().setLayout(new BorderLayout());
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.Y_AXIS));
    {
        JPanel panelVerbatimValues = new JPanel();
        contentPanel.add(panelVerbatimValues);
        GridBagLayout gbl_panelVerbatimValues = new GridBagLayout();
        gbl_panelVerbatimValues.columnWidths = new int[] { 70, 0, 0, 0, 35, 0, 58, 0, 0, 0 };
        gbl_panelVerbatimValues.rowHeights = new int[] { 15, 0, 0, 0, 0, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                83, 0 };
        gbl_panelVerbatimValues.columnWeights = new double[] { 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0,
                1.0 };
        gbl_panelVerbatimValues.rowWeights = new double[] { 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE };
        panelVerbatimValues.setLayout(gbl_panelVerbatimValues);
        {
            lblCount = new JLabel("New label");
            GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
            gbc_lblNewLabel.gridwidth = 2;
            gbc_lblNewLabel.insets = new Insets(0, 0, 5, 5);
            gbc_lblNewLabel.anchor = GridBagConstraints.SOUTHWEST;
            gbc_lblNewLabel.gridx = 0;
            gbc_lblNewLabel.gridy = 0;
            panelVerbatimValues.add(lblCount, gbc_lblNewLabel);
        }

        JButton buttonFillFromLast = new JButton("Fill From Last");
        GridBagConstraints gbc_buttonFillFromLast = new GridBagConstraints();
        gbc_buttonFillFromLast.anchor = GridBagConstraints.SOUTH;
        gbc_buttonFillFromLast.insets = new Insets(0, 0, 5, 5);
        gbc_buttonFillFromLast.gridx = 3;
        gbc_buttonFillFromLast.gridy = 0;
        panelVerbatimValues.add(buttonFillFromLast, gbc_buttonFillFromLast);
        {
            JLabel lblNewLabel_1 = new JLabel("Field values to apply to all records.");
            GridBagConstraints gbc_lblNewLabel_1 = new GridBagConstraints();
            gbc_lblNewLabel_1.anchor = GridBagConstraints.SOUTHEAST;
            gbc_lblNewLabel_1.gridwidth = 4;
            gbc_lblNewLabel_1.insets = new Insets(0, 0, 5, 5);
            gbc_lblNewLabel_1.gridx = 4;
            gbc_lblNewLabel_1.gridy = 0;
            panelVerbatimValues.add(lblNewLabel_1, gbc_lblNewLabel_1);
        }
        {
            JLabel lblNewLabel_2 = new JLabel("Verbatim Locality");
            GridBagConstraints gbc_lblNewLabel_2 = new GridBagConstraints();
            gbc_lblNewLabel_2.anchor = GridBagConstraints.EAST;
            gbc_lblNewLabel_2.insets = new Insets(0, 0, 5, 5);
            gbc_lblNewLabel_2.gridx = 0;
            gbc_lblNewLabel_2.gridy = 1;
            panelVerbatimValues.add(lblNewLabel_2, gbc_lblNewLabel_2);
        }
        {
            textFieldVerbLocality = new JTextArea();
            textFieldVerbLocality.setEditable(false);
            textFieldVerbLocality.setRows(5);
            GridBagConstraints gbc_textField = new GridBagConstraints();
            gbc_textField.gridheight = 3;
            gbc_textField.insets = new Insets(0, 0, 5, 5);
            gbc_textField.fill = GridBagConstraints.BOTH;
            gbc_textField.gridx = 1;
            gbc_textField.gridy = 1;
            panelVerbatimValues.add(textFieldVerbLocality, gbc_textField);
            textFieldVerbLocality.setColumns(30);
        }

        JLabel lblNewLabel = new JLabel("HigherGeography");
        GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
        gbc_lblNewLabel.anchor = GridBagConstraints.EAST;
        gbc_lblNewLabel.insets = new Insets(0, 0, 5, 5);
        gbc_lblNewLabel.gridx = 3;
        gbc_lblNewLabel.gridy = 1;
        panelVerbatimValues.add(lblNewLabel, gbc_lblNewLabel);

        GridBagConstraints gbc_textFieldHigherGeography = new GridBagConstraints();
        gbc_textFieldHigherGeography.fill = GridBagConstraints.HORIZONTAL;
        gbc_textFieldHigherGeography.gridwidth = 5;
        gbc_textFieldHigherGeography.insets = new Insets(0, 0, 5, 5);
        gbc_textFieldHigherGeography.gridx = 4;
        gbc_textFieldHigherGeography.gridy = 1;
        panelVerbatimValues.add(getComboBoxHighGeog(), gbc_textFieldHigherGeography);

        JButton btnCopyLocality = new JButton(">");
        btnCopyLocality.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                if (textFieldSpecificLocality.getText().isEmpty()) {
                    textFieldSpecificLocality.setText(textFieldVerbLocality.getText().replace("\n", "").trim());
                }
            }
        });
        GridBagConstraints gbc_btnCopyLocality = new GridBagConstraints();
        gbc_btnCopyLocality.insets = new Insets(0, 0, 5, 5);
        gbc_btnCopyLocality.gridx = 2;
        gbc_btnCopyLocality.gridy = 2;
        panelVerbatimValues.add(btnCopyLocality, gbc_btnCopyLocality);

        JLabel lblSpecificLocality = new JLabel("Specific Locality");
        GridBagConstraints gbc_lblSpecificLocality = new GridBagConstraints();
        gbc_lblSpecificLocality.anchor = GridBagConstraints.EAST;
        gbc_lblSpecificLocality.insets = new Insets(0, 0, 5, 5);
        gbc_lblSpecificLocality.gridx = 3;
        gbc_lblSpecificLocality.gridy = 2;
        panelVerbatimValues.add(lblSpecificLocality, gbc_lblSpecificLocality);

        JLabel lblElevation = new JLabel("Elevation");
        GridBagConstraints gbc_lblElevation = new GridBagConstraints();
        gbc_lblElevation.anchor = GridBagConstraints.EAST;
        gbc_lblElevation.insets = new Insets(0, 0, 5, 5);
        gbc_lblElevation.gridx = 3;
        gbc_lblElevation.gridy = 3;
        panelVerbatimValues.add(lblElevation, gbc_lblElevation);

        textFieldMinElevation = new JTextField();
        textFieldMinElevation.setMinimumSize(new Dimension(60, 19));
        GridBagConstraints gbc_textFieldMinElevation = new GridBagConstraints();
        gbc_textFieldMinElevation.insets = new Insets(0, 0, 5, 5);
        gbc_textFieldMinElevation.fill = GridBagConstraints.HORIZONTAL;
        gbc_textFieldMinElevation.gridx = 4;
        gbc_textFieldMinElevation.gridy = 3;
        panelVerbatimValues.add(textFieldMinElevation, gbc_textFieldMinElevation);
        textFieldMinElevation.setColumns(4);

        JLabel lblTo = new JLabel("to");
        GridBagConstraints gbc_lblTo = new GridBagConstraints();
        gbc_lblTo.anchor = GridBagConstraints.EAST;
        gbc_lblTo.insets = new Insets(0, 0, 5, 5);
        gbc_lblTo.gridx = 5;
        gbc_lblTo.gridy = 3;
        panelVerbatimValues.add(lblTo, gbc_lblTo);

        textFieldMaxElevation = new JTextField();
        textFieldMaxElevation.setMinimumSize(new Dimension(60, 19));
        GridBagConstraints gbc_textFieldMaxElevation = new GridBagConstraints();
        gbc_textFieldMaxElevation.anchor = GridBagConstraints.WEST;
        gbc_textFieldMaxElevation.insets = new Insets(0, 0, 5, 5);
        gbc_textFieldMaxElevation.gridx = 6;
        gbc_textFieldMaxElevation.gridy = 3;
        panelVerbatimValues.add(textFieldMaxElevation, gbc_textFieldMaxElevation);
        textFieldMaxElevation.setColumns(5);

        comboBoxElevUnits = new JComboBox();
        GridBagConstraints gbc_comboBoxElevUnits = new GridBagConstraints();
        gbc_comboBoxElevUnits.insets = new Insets(0, 0, 5, 5);
        gbc_comboBoxElevUnits.fill = GridBagConstraints.HORIZONTAL;
        gbc_comboBoxElevUnits.gridx = 7;
        gbc_comboBoxElevUnits.gridy = 3;
        panelVerbatimValues.add(comboBoxElevUnits, gbc_comboBoxElevUnits);
        {
            JLabel lblVerbatimdate = new JLabel("VerbatimDate");
            GridBagConstraints gbc_lblVerbatimdate = new GridBagConstraints();
            gbc_lblVerbatimdate.anchor = GridBagConstraints.EAST;
            gbc_lblVerbatimdate.insets = new Insets(0, 0, 5, 5);
            gbc_lblVerbatimdate.gridx = 0;
            gbc_lblVerbatimdate.gridy = 4;
            panelVerbatimValues.add(lblVerbatimdate, gbc_lblVerbatimdate);
        }

        textFieldVerbDate = new JTextField();
        GridBagConstraints gbc_textFieldVerbDate = new GridBagConstraints();
        gbc_textFieldVerbDate.insets = new Insets(0, 0, 5, 5);
        gbc_textFieldVerbDate.fill = GridBagConstraints.HORIZONTAL;
        gbc_textFieldVerbDate.gridx = 1;
        gbc_textFieldVerbDate.gridy = 4;
        panelVerbatimValues.add(textFieldVerbDate, gbc_textFieldVerbDate);
        textFieldVerbDate.setColumns(30);

        JButton btnCopyDate = new JButton(">");
        btnCopyDate.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                if (textFieldISODate.getText().isEmpty()) {
                    Map<String, String> extractResult = DateUtils
                            .extractDateFromVerbatim(textFieldVerbDate.getText().trim());
                    if (extractResult.containsKey("result")) {
                        textFieldISODate.setText(extractResult.get("result"));
                    }
                    if (extractResult.containsKey("resultState")) {
                        // TODO: Report suspect etc
                    }
                }
            }
        });
        GridBagConstraints gbc_btnCopyDate = new GridBagConstraints();
        gbc_btnCopyDate.insets = new Insets(0, 0, 5, 5);
        gbc_btnCopyDate.gridx = 2;
        gbc_btnCopyDate.gridy = 4;
        panelVerbatimValues.add(btnCopyDate, gbc_btnCopyDate);

        JLabel lblNewLabel_3 = new JLabel("ISO Date");
        GridBagConstraints gbc_lblNewLabel_3 = new GridBagConstraints();
        gbc_lblNewLabel_3.anchor = GridBagConstraints.EAST;
        gbc_lblNewLabel_3.insets = new Insets(0, 0, 5, 5);
        gbc_lblNewLabel_3.gridx = 3;
        gbc_lblNewLabel_3.gridy = 4;
        panelVerbatimValues.add(lblNewLabel_3, gbc_lblNewLabel_3);

        textFieldISODate = new JTextField();
        textFieldISODate.setInputVerifier(
                MetadataRetriever.getInputVerifier(Specimen.class, "ISODate", textFieldISODate));
        textFieldISODate.setToolTipText(MetadataRetriever.getFieldHelp(Specimen.class, "ISODate"));
        GridBagConstraints gbc_textFieldISODate = new GridBagConstraints();
        gbc_textFieldISODate.fill = GridBagConstraints.HORIZONTAL;
        gbc_textFieldISODate.gridwidth = 5;
        gbc_textFieldISODate.insets = new Insets(0, 0, 5, 5);
        gbc_textFieldISODate.gridx = 4;
        gbc_textFieldISODate.gridy = 4;
        panelVerbatimValues.add(textFieldISODate, gbc_textFieldISODate);
        textFieldISODate.setColumns(10);

        textFieldSpecificLocality = new JTextField();
        GridBagConstraints gbc_textFieldSpecificLocality = new GridBagConstraints();
        gbc_textFieldSpecificLocality.gridwidth = 5;
        gbc_textFieldSpecificLocality.fill = GridBagConstraints.HORIZONTAL;
        gbc_textFieldSpecificLocality.insets = new Insets(0, 0, 5, 5);
        gbc_textFieldSpecificLocality.gridx = 4;
        gbc_textFieldSpecificLocality.gridy = 2;
        panelVerbatimValues.add(textFieldSpecificLocality, gbc_textFieldSpecificLocality);
        textFieldSpecificLocality.setColumns(25);
        {
            JLabel lblVerbatimCollector = new JLabel("Verbatim Collector");
            GridBagConstraints gbc_lblVerbatimCollector = new GridBagConstraints();
            gbc_lblVerbatimCollector.anchor = GridBagConstraints.EAST;
            gbc_lblVerbatimCollector.insets = new Insets(0, 0, 5, 5);
            gbc_lblVerbatimCollector.gridx = 0;
            gbc_lblVerbatimCollector.gridy = 6;
            panelVerbatimValues.add(lblVerbatimCollector, gbc_lblVerbatimCollector);
        }

        textFieldVerbCollector = new JTextArea();
        textFieldVerbCollector.setEditable(false);
        textFieldVerbCollector.setRows(3);
        GridBagConstraints gbc_textFieldVerbCollector = new GridBagConstraints();
        gbc_textFieldVerbCollector.gridheight = 2;
        gbc_textFieldVerbCollector.insets = new Insets(0, 0, 5, 5);
        gbc_textFieldVerbCollector.fill = GridBagConstraints.BOTH;
        gbc_textFieldVerbCollector.gridx = 1;
        gbc_textFieldVerbCollector.gridy = 6;
        panelVerbatimValues.add(textFieldVerbCollector, gbc_textFieldVerbCollector);
        textFieldVerbCollector.setColumns(30);

        JLabel lblCollectors = new JLabel("Collector(s)");
        GridBagConstraints gbc_lblCollectors = new GridBagConstraints();
        gbc_lblCollectors.anchor = GridBagConstraints.EAST;
        gbc_lblCollectors.insets = new Insets(0, 0, 5, 5);
        gbc_lblCollectors.gridx = 3;
        gbc_lblCollectors.gridy = 6;
        panelVerbatimValues.add(lblCollectors, gbc_lblCollectors);

        JButton btnAddCollector = new JButton("+");
        btnAddCollector.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent e) {
                ((CollectorTableModel) jTableCollectors.getModel()).addCollector(new Collector(null, ""));
            }
        });
        GridBagConstraints gbc_btnAddCollector = new GridBagConstraints();
        gbc_btnAddCollector.anchor = GridBagConstraints.EAST;
        gbc_btnAddCollector.insets = new Insets(0, 0, 5, 5);
        gbc_btnAddCollector.gridx = 3;
        gbc_btnAddCollector.gridy = 7;
        panelVerbatimValues.add(btnAddCollector, gbc_btnAddCollector);

        GridBagConstraints gbc_collectorTable = new GridBagConstraints();
        gbc_collectorTable.insets = new Insets(0, 0, 5, 5);
        gbc_collectorTable.fill = GridBagConstraints.BOTH;
        gbc_collectorTable.gridx = 4;
        gbc_collectorTable.gridy = 6;
        gbc_collectorTable.gridheight = 2;
        gbc_collectorTable.gridwidth = 5;
        panelVerbatimValues.add(getJScrollPaneCollectors(), gbc_collectorTable);

        JLabel lblVerbatimCollection = new JLabel("Verbatim Collection");
        GridBagConstraints gbc_lblVerbatimCollection = new GridBagConstraints();
        gbc_lblVerbatimCollection.anchor = GridBagConstraints.EAST;
        gbc_lblVerbatimCollection.insets = new Insets(0, 0, 5, 5);
        gbc_lblVerbatimCollection.gridx = 0;
        gbc_lblVerbatimCollection.gridy = 8;
        panelVerbatimValues.add(lblVerbatimCollection, gbc_lblVerbatimCollection);

        textFieldVerbCollection = new JTextArea();
        textFieldVerbCollection.setEditable(false);
        textFieldVerbCollection.setRows(3);
        GridBagConstraints gbc_textFieldVerbCollection = new GridBagConstraints();
        gbc_textFieldVerbCollection.gridheight = 2;
        gbc_textFieldVerbCollection.insets = new Insets(0, 0, 5, 5);
        gbc_textFieldVerbCollection.fill = GridBagConstraints.BOTH;
        gbc_textFieldVerbCollection.gridx = 1;
        gbc_textFieldVerbCollection.gridy = 8;
        panelVerbatimValues.add(textFieldVerbCollection, gbc_textFieldVerbCollection);
        textFieldVerbCollection.setColumns(30);

        JLabel lblCollection = new JLabel("Collection");
        GridBagConstraints gbc_lblCollection = new GridBagConstraints();
        gbc_lblCollection.anchor = GridBagConstraints.EAST;
        gbc_lblCollection.insets = new Insets(0, 0, 5, 5);
        gbc_lblCollection.gridx = 3;
        gbc_lblCollection.gridy = 8;
        panelVerbatimValues.add(lblCollection, gbc_lblCollection);

        GridBagConstraints gbc_textFieldCollection = new GridBagConstraints();
        gbc_textFieldCollection.fill = GridBagConstraints.HORIZONTAL;
        gbc_textFieldCollection.gridwidth = 5;
        gbc_textFieldCollection.insets = new Insets(0, 0, 5, 5);
        gbc_textFieldCollection.gridx = 4;
        gbc_textFieldCollection.gridy = 8;
        panelVerbatimValues.add(getJComboBoxCollection(), gbc_textFieldCollection);

        JLabel lblVerbatimNumbers = new JLabel("Verbatim Numbers");
        GridBagConstraints gbc_lblVerbatimNumbers = new GridBagConstraints();
        gbc_lblVerbatimNumbers.anchor = GridBagConstraints.EAST;
        gbc_lblVerbatimNumbers.insets = new Insets(0, 0, 5, 5);
        gbc_lblVerbatimNumbers.gridx = 0;
        gbc_lblVerbatimNumbers.gridy = 10;
        panelVerbatimValues.add(lblVerbatimNumbers, gbc_lblVerbatimNumbers);

        textFieldVerbNumbers = new JTextArea();
        textFieldVerbNumbers.setRows(3);
        textFieldVerbNumbers.setEditable(false);
        GridBagConstraints gbc_textFieldVerbNumbers = new GridBagConstraints();
        gbc_textFieldVerbNumbers.gridheight = 2;
        gbc_textFieldVerbNumbers.insets = new Insets(0, 0, 5, 5);
        gbc_textFieldVerbNumbers.fill = GridBagConstraints.BOTH;
        gbc_textFieldVerbNumbers.gridx = 1;
        gbc_textFieldVerbNumbers.gridy = 10;
        panelVerbatimValues.add(textFieldVerbNumbers, gbc_textFieldVerbNumbers);
        textFieldVerbNumbers.setColumns(30);

        JLabel lblNumbers = new JLabel("Numbers");
        GridBagConstraints gbc_lblNumbers = new GridBagConstraints();
        gbc_lblNumbers.anchor = GridBagConstraints.EAST;
        gbc_lblNumbers.insets = new Insets(0, 0, 5, 5);
        gbc_lblNumbers.gridx = 3;
        gbc_lblNumbers.gridy = 10;
        panelVerbatimValues.add(lblNumbers, gbc_lblNumbers);

        JButton btnAddNumber = new JButton("+");
        btnAddNumber.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent e) {
                ((NumberTableModel) jTableNumbers.getModel())
                        .addNumber(new edu.harvard.mcz.imagecapture.data.Number(null, "", ""));
            }
        });
        GridBagConstraints gbc_btnAddNumber = new GridBagConstraints();
        gbc_btnAddNumber.anchor = GridBagConstraints.EAST;
        gbc_btnAddNumber.insets = new Insets(0, 0, 5, 5);
        gbc_btnAddNumber.gridx = 3;
        gbc_btnAddNumber.gridy = 11;
        panelVerbatimValues.add(btnAddNumber, gbc_btnAddNumber);

        GridBagConstraints gbc_numberTable = new GridBagConstraints();
        gbc_numberTable.insets = new Insets(0, 0, 5, 5);
        gbc_numberTable.fill = GridBagConstraints.BOTH;
        gbc_numberTable.gridx = 4;
        gbc_numberTable.gridy = 10;
        gbc_numberTable.gridheight = 2;
        gbc_numberTable.gridwidth = 5;
        panelVerbatimValues.add(this.getJScrollPaneNumbers(), gbc_numberTable);

        JLabel lblVerbatimOtherText = new JLabel("Verbatim Other Text");
        GridBagConstraints gbc_lblVerbatimOtherText = new GridBagConstraints();
        gbc_lblVerbatimOtherText.anchor = GridBagConstraints.EAST;
        gbc_lblVerbatimOtherText.insets = new Insets(0, 0, 5, 5);
        gbc_lblVerbatimOtherText.gridx = 0;
        gbc_lblVerbatimOtherText.gridy = 12;
        panelVerbatimValues.add(lblVerbatimOtherText, gbc_lblVerbatimOtherText);

        textFieldVerbUnclassifiedText = new JTextArea();
        textFieldVerbUnclassifiedText.setEditable(false);
        textFieldVerbUnclassifiedText.setRows(5);
        GridBagConstraints gbc_textFieldVerbUnclassifiedText = new GridBagConstraints();
        gbc_textFieldVerbUnclassifiedText.gridheight = 3;
        gbc_textFieldVerbUnclassifiedText.insets = new Insets(0, 0, 5, 5);
        gbc_textFieldVerbUnclassifiedText.fill = GridBagConstraints.BOTH;
        gbc_textFieldVerbUnclassifiedText.gridx = 1;
        gbc_textFieldVerbUnclassifiedText.gridy = 12;
        panelVerbatimValues.add(textFieldVerbUnclassifiedText, gbc_textFieldVerbUnclassifiedText);
        textFieldVerbUnclassifiedText.setColumns(30);

        JLabel lblHabitat = new JLabel("Habitat");
        GridBagConstraints gbc_lblHabitat = new GridBagConstraints();
        gbc_lblHabitat.anchor = GridBagConstraints.EAST;
        gbc_lblHabitat.insets = new Insets(0, 0, 5, 5);
        gbc_lblHabitat.gridx = 3;
        gbc_lblHabitat.gridy = 12;
        panelVerbatimValues.add(lblHabitat, gbc_lblHabitat);

        textFieldHabitat = new JTextField();
        GridBagConstraints gbc_textFieldHabitat = new GridBagConstraints();
        gbc_textFieldHabitat.fill = GridBagConstraints.HORIZONTAL;
        gbc_textFieldHabitat.gridwidth = 4;
        gbc_textFieldHabitat.insets = new Insets(0, 0, 5, 5);
        gbc_textFieldHabitat.gridx = 4;
        gbc_textFieldHabitat.gridy = 12;
        panelVerbatimValues.add(textFieldHabitat, gbc_textFieldHabitat);
        textFieldHabitat.setColumns(10);

        JLabel lblMicrohabitat = new JLabel("Microhabitat");
        GridBagConstraints gbc_lblMicrohabitat = new GridBagConstraints();
        gbc_lblMicrohabitat.anchor = GridBagConstraints.EAST;
        gbc_lblMicrohabitat.insets = new Insets(0, 0, 5, 5);
        gbc_lblMicrohabitat.gridx = 3;
        gbc_lblMicrohabitat.gridy = 13;
        panelVerbatimValues.add(lblMicrohabitat, gbc_lblMicrohabitat);

        textFieldMicrohabitat = new JTextField();
        GridBagConstraints gbc_textFieldMicrohabitat = new GridBagConstraints();
        gbc_textFieldMicrohabitat.fill = GridBagConstraints.HORIZONTAL;
        gbc_textFieldMicrohabitat.gridwidth = 4;
        gbc_textFieldMicrohabitat.insets = new Insets(0, 0, 5, 5);
        gbc_textFieldMicrohabitat.gridx = 4;
        gbc_textFieldMicrohabitat.gridy = 13;
        panelVerbatimValues.add(textFieldMicrohabitat, gbc_textFieldMicrohabitat);
        textFieldMicrohabitat.setColumns(10);

        JLabel lblNewLabel_4 = new JLabel("Workflow Status");
        GridBagConstraints gbc_lblNewLabel_4 = new GridBagConstraints();
        gbc_lblNewLabel_4.insets = new Insets(0, 0, 5, 5);
        gbc_lblNewLabel_4.gridx = 3;
        gbc_lblNewLabel_4.gridy = 15;
        panelVerbatimValues.add(lblNewLabel_4, gbc_lblNewLabel_4);

        comboBoxWorkflowStatus = new JComboBox(WorkFlowStatus.getVerbatimClassifiedWorkFlowStatusValues());
        comboBoxWorkflowStatus.setSelectedItem(WorkFlowStatus.STAGE_CLASSIFIED);
        GridBagConstraints gbc_comboBoxWorkflowStatus = new GridBagConstraints();
        gbc_comboBoxWorkflowStatus.gridwidth = 4;
        gbc_comboBoxWorkflowStatus.fill = GridBagConstraints.HORIZONTAL;
        gbc_comboBoxWorkflowStatus.insets = new Insets(0, 0, 5, 5);
        gbc_comboBoxWorkflowStatus.gridx = 4;
        gbc_comboBoxWorkflowStatus.gridy = 15;
        panelVerbatimValues.add(comboBoxWorkflowStatus, gbc_comboBoxWorkflowStatus);

        JButton btnApplyToAll = new JButton("Apply To All Records");
        GridBagConstraints gbc_btnApplyToAll = new GridBagConstraints();
        gbc_btnApplyToAll.gridwidth = 4;
        gbc_btnApplyToAll.insets = new Insets(0, 0, 5, 5);
        gbc_btnApplyToAll.gridx = 4;
        gbc_btnApplyToAll.gridy = 16;
        panelVerbatimValues.add(btnApplyToAll, gbc_btnApplyToAll);
        btnApplyToAll.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                saveChanges();
            }
        });
    }
    {
        JPanel panelRelatedData = new JPanel();
        contentPanel.add(panelRelatedData);
        GridBagLayout gbl_panelRelatedData = new GridBagLayout();
        gbl_panelRelatedData.maximumLayoutSize(panelRelatedData);
        gbl_panelRelatedData.columnWidths = new int[] { 20, 33, 1, 0 };
        gbl_panelRelatedData.rowHeights = new int[] { 25, 0 };
        gbl_panelRelatedData.columnWeights = new double[] { 0.0, 1.0, 0.0, Double.MIN_VALUE };
        gbl_panelRelatedData.rowWeights = new double[] { 1.0, Double.MIN_VALUE };
        panelRelatedData.setLayout(gbl_panelRelatedData);
        {
            JLabel lblTaxa = new JLabel("Taxa");
            GridBagConstraints gbc_lblTaxa = new GridBagConstraints();
            gbc_lblTaxa.anchor = GridBagConstraints.NORTHEAST;
            gbc_lblTaxa.insets = new Insets(0, 0, 0, 5);
            gbc_lblTaxa.gridx = 0;
            gbc_lblTaxa.gridy = 0;
            panelRelatedData.add(lblTaxa, gbc_lblTaxa);
        }

        JScrollPane scrollPane = new JScrollPane();
        // scrollPane.setPreferredSize(new Dimension(1000,100));
        GridBagConstraints gbc_scrollPane = new GridBagConstraints();
        gbc_scrollPane.anchor = GridBagConstraints.NORTH;
        gbc_scrollPane.insets = new Insets(0, 0, 0, 5);
        gbc_scrollPane.fill = GridBagConstraints.BOTH;
        gbc_scrollPane.gridx = 1;
        gbc_scrollPane.gridy = 0;
        panelRelatedData.add(scrollPane, gbc_scrollPane);

        tableTaxa = new JTable();
        SpecimenLifeCycle sls = new SpecimenLifeCycle();
        tableTaxa.setModel(new CountValueTableModel(sls.findTaxaFromVerbatim(this.verbatimData),
                "Current Idenfifications for these verbatim values."));
        scrollPane.setViewportView(tableTaxa);
    }
    {
        JPanel buttonPane = new JPanel();
        buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
        getContentPane().add(buttonPane, BorderLayout.SOUTH);
        {
            JButton cancelButton = new JButton("Close");
            cancelButton.setActionCommand("Close");
            cancelButton.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    setVisible(false);
                }
            });
            buttonPane.add(cancelButton);
        }
    }
}

From source file:me.childintime.childintime.ui.window.tool.BmiToolDialog.java

/**
 * Build the student body states panel./*from   ww  w.j av  a2 s  .  com*/
 *
 * @return Student body states panel.
 */
private JPanel buildUiStudentBodyStatesPanel() {
    // Create a new grid bag constraints configuration instance
    GridBagConstraints c = new GridBagConstraints();

    // Create the panel
    final JPanel studentBodyStatePanel = new JPanel(new GridBagLayout());

    // Add the label
    c.fill = GridBagConstraints.NONE;
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 0;
    c.weighty = 0;
    c.insets = new Insets(8, 2, 2, 0);
    c.anchor = GridBagConstraints.SOUTHWEST;
    studentBodyStatePanel.add(new JLabel("Student's body states:"), c);

    // Create a list for the students body states
    this.studentBodyStates = new EntityViewComponent(Core.getInstance().getBodyStateManager());

    // Add the list
    c.fill = GridBagConstraints.BOTH;
    c.gridx = 0;
    c.gridy = 1;
    c.weightx = 1;
    c.weighty = 1;
    c.insets = new Insets(0, 0, 0, 0);
    c.anchor = GridBagConstraints.CENTER;
    studentBodyStatePanel.add(this.studentBodyStates, c);

    // Update the student body state list when the selected student is changed
    this.studentList.addSelectionChangeListenerListener(this::updateStudentBodyStateList);

    // Set the minimum preferred size of the body states list
    this.studentBodyStates.setPreferredSize(new Dimension(200, 100));

    // Return the panel
    return studentBodyStatePanel;
}

From source file:fxts.stations.ui.SideLayout.java

/**
 * Adjusts the x, y, width, and height fields to the correct
 * values depending on the constraint geometry and pads.
 *
 * @param aConstraints the constraints to be applied
 * @param aRectangle   the <code>Rectangle</code> to be adjusted
 *///from  w  w  w.j  a v  a  2 s .  c om
protected void adjustForGravity(SideConstraints aConstraints, Rectangle aRectangle) {
    int diffx, diffy;
    if (!mRightToLeft) {
        aRectangle.x += aConstraints.insets.left;
    } else {
        aRectangle.x -= aRectangle.width - aConstraints.insets.right;
    }
    aRectangle.width -= aConstraints.insets.left + aConstraints.insets.right;
    aRectangle.y += aConstraints.insets.top;
    aRectangle.height -= aConstraints.insets.top + aConstraints.insets.bottom;
    diffx = 0;
    if (aConstraints.fill != SideConstraints.HORIZONTAL && aConstraints.fill != SideConstraints.BOTH
            && aRectangle.width > aConstraints.minWidth + aConstraints.ipadx) {
        diffx = aRectangle.width - (aConstraints.minWidth + aConstraints.ipadx);
        aRectangle.width = aConstraints.minWidth + aConstraints.ipadx;
    }
    diffy = 0;
    if (aConstraints.fill != SideConstraints.VERTICAL && aConstraints.fill != SideConstraints.BOTH
            && aRectangle.height > aConstraints.minHeight + aConstraints.ipady) {
        diffy = aRectangle.height - (aConstraints.minHeight + aConstraints.ipady);
        aRectangle.height = aConstraints.minHeight + aConstraints.ipady;
    }
    switch (aConstraints.anchor) {
    case GridBagConstraints.CENTER:
        aRectangle.x += diffx / 2;
        aRectangle.y += diffy / 2;
        break;
    case SideConstraints.PAGE_START:
    case GridBagConstraints.NORTH:
        aRectangle.x += diffx / 2;
        break;
    case GridBagConstraints.NORTHEAST:
        aRectangle.x += diffx;
        break;
    case GridBagConstraints.EAST:
        aRectangle.x += diffx;
        aRectangle.y += diffy / 2;
        break;
    case GridBagConstraints.SOUTHEAST:
        aRectangle.x += diffx;
        aRectangle.y += diffy;
        break;
    case SideConstraints.PAGE_END:
    case GridBagConstraints.SOUTH:
        aRectangle.x += diffx / 2;
        aRectangle.y += diffy;
        break;
    case GridBagConstraints.SOUTHWEST:
        aRectangle.y += diffy;
        break;
    case GridBagConstraints.WEST:
        aRectangle.y += diffy / 2;
        break;
    case GridBagConstraints.NORTHWEST:
        break;
    case SideConstraints.LINE_START:
        if (mRightToLeft) {
            aRectangle.x += diffx;
        }
        aRectangle.y += diffy / 2;
        break;
    case SideConstraints.LINE_END:
        if (!mRightToLeft) {
            aRectangle.x += diffx;
        }
        aRectangle.y += diffy / 2;
        break;
    case SideConstraints.FIRST_LINE_START:
        if (mRightToLeft) {
            aRectangle.x += diffx;
        }
        break;
    case SideConstraints.FIRST_LINE_END:
        if (!mRightToLeft) {
            aRectangle.x += diffx;
        }
        break;
    case SideConstraints.LAST_LINE_START:
        if (mRightToLeft) {
            aRectangle.x += diffx;
        }
        aRectangle.y += diffy;
        break;
    case SideConstraints.LAST_LINE_END:
        if (!mRightToLeft) {
            aRectangle.x += diffx;
        }
        aRectangle.y += diffy;
        break;
    default:
        throw new IllegalArgumentException("illegal anchor value");
    }
}

From source file:me.childintime.childintime.ui.window.tool.BmiToolDialog.java

/**
 * Build the UI student panel.//from ww  w.  j  av a 2  s.  co m
 *
 * @return Student panel.
 */
private JPanel buildUiStudentPanel() {
    // Create a grid bag constraints configuration
    GridBagConstraints c = new GridBagConstraints();

    // Create a panel for the student selector
    final JPanel studentPanel = new JPanel(new GridBagLayout());

    // Create a group filter property field
    this.groupFilterField = new EntityPropertyField(Core.getInstance().getGroupManager(), true);
    this.groupFilterField.setNull(true);

    // Add the student label
    c.fill = GridBagConstraints.NONE;
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 0;
    c.weighty = 0;
    c.insets = new Insets(0, 2, 2, 0);
    c.anchor = GridBagConstraints.SOUTHWEST;
    studentPanel.add(new JLabel("Student group filter:"), c);

    // Add the group filter
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.gridy = 1;
    c.weightx = 1;
    c.weighty = 0;
    c.insets = new Insets(0, 0, 8, 0);
    c.anchor = GridBagConstraints.CENTER;
    studentPanel.add(this.groupFilterField, c);

    // Create a student selector list
    this.studentList = new EntityListSelectorComponent(Core.getInstance().getStudentManager());

    // Create a listener to set the student list filter when the group changes
    this.groupFilterField.addValueChangeListenerListener(newValue -> {
        // Set or clear the filter
        if (newValue != null)
            this.studentList.setFilter(StudentFields.GROUP_ID, newValue);
        else
            this.studentList.clearFilter();
    });

    // Add the student label
    c.fill = GridBagConstraints.NONE;
    c.gridx = 0;
    c.gridy = 2;
    c.weightx = 0;
    c.weighty = 0;
    c.insets = new Insets(8, 2, 2, 0);
    c.anchor = GridBagConstraints.SOUTHWEST;
    studentPanel.add(new JLabel("Student:"), c);

    // Add the student list
    c.fill = GridBagConstraints.BOTH;
    c.gridx = 0;
    c.gridy = 3;
    c.weightx = 1;
    c.weighty = 1;
    c.insets = new Insets(0, 0, 0, 0);
    c.anchor = GridBagConstraints.CENTER;
    studentPanel.add(this.studentList, c);

    // Set the minimum preferred size
    studentPanel.setPreferredSize(new Dimension(200, 200));

    // Return the student panel
    return studentPanel;
}

From source file:FontChooser.java

/** This method is called from within the constructor to
* initialize the form.// ww  w .  j a  va  2 s  . com
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the FormEditor.
*/
private void initComponents() {
    jPanel3 = new javax.swing.JPanel();
    jFont = new javax.swing.JTextField();
    jScrollPane1 = new javax.swing.JScrollPane();
    jFontList = new javax.swing.JList();
    jPanel4 = new javax.swing.JPanel();
    jStyle = new javax.swing.JTextField();
    jScrollPane2 = new javax.swing.JScrollPane();
    jStyleList = new javax.swing.JList();
    jPanel5 = new javax.swing.JPanel();
    jSize = new javax.swing.JTextField();
    jScrollPane3 = new javax.swing.JScrollPane();
    jSizeList = new javax.swing.JList();
    jPanel1 = new javax.swing.JPanel();
    jScrollPane4 = new javax.swing.JScrollPane();
    jSample = new javax.swing.JTextArea();
    jButtons = new javax.swing.JPanel();
    jOk = new javax.swing.JButton();
    jCancel = new javax.swing.JButton();
    jLabel6 = new javax.swing.JLabel();
    getContentPane().setLayout(new java.awt.GridBagLayout());
    java.awt.GridBagConstraints gridBagConstraints1;
    setTitle("Font Chooser");
    addWindowListener(new java.awt.event.WindowAdapter() {
        public void windowClosing(java.awt.event.WindowEvent evt) {
            closeDialog(evt);
        }
    });

    jPanel3.setLayout(new java.awt.GridBagLayout());
    java.awt.GridBagConstraints gridBagConstraints2;
    jPanel3.setBorder(new javax.swing.border.TitledBorder(new javax.swing.border.EtchedBorder(), " Font "));

    jFont.setColumns(24);
    jFont.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jFontActionPerformed(evt);
        }
    });
    gridBagConstraints2 = new java.awt.GridBagConstraints();
    gridBagConstraints2.gridwidth = 0;
    gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints2.insets = new java.awt.Insets(0, 3, 0, 3);
    gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints2.weightx = 1.0;
    jPanel3.add(jFont, gridBagConstraints2);

    jFontList.setModel(new DefaultListModel());
    jFontList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
    jFontList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
        public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
            jFontListValueChanged(evt);
        }
    });
    jScrollPane1.setViewportView(jFontList);

    gridBagConstraints2 = new java.awt.GridBagConstraints();
    gridBagConstraints2.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints2.insets = new java.awt.Insets(3, 3, 3, 3);
    gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints2.weightx = 1.0;
    gridBagConstraints2.weighty = 1.0;
    jPanel3.add(jScrollPane1, gridBagConstraints2);

    gridBagConstraints1 = new java.awt.GridBagConstraints();
    gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints1.insets = new java.awt.Insets(5, 5, 0, 0);
    gridBagConstraints1.weightx = 0.5;
    gridBagConstraints1.weighty = 1.0;
    getContentPane().add(jPanel3, gridBagConstraints1);

    jPanel4.setLayout(new java.awt.GridBagLayout());
    java.awt.GridBagConstraints gridBagConstraints3;
    jPanel4.setBorder(new javax.swing.border.TitledBorder(new javax.swing.border.EtchedBorder(), " Style "));

    jStyle.setColumns(18);
    jStyle.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jStyleActionPerformed(evt);
        }
    });
    gridBagConstraints3 = new java.awt.GridBagConstraints();
    gridBagConstraints3.gridwidth = 0;
    gridBagConstraints3.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints3.insets = new java.awt.Insets(0, 3, 0, 3);
    gridBagConstraints3.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints3.weightx = 1.0;
    jPanel4.add(jStyle, gridBagConstraints3);

    jStyleList.setModel(new DefaultListModel());
    jStyleList.setVisibleRowCount(4);
    jStyleList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
        public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
            jStyleListValueChanged(evt);
        }
    });
    jScrollPane2.setViewportView(jStyleList);

    gridBagConstraints3 = new java.awt.GridBagConstraints();
    gridBagConstraints3.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints3.insets = new java.awt.Insets(3, 3, 3, 3);
    gridBagConstraints3.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints3.weightx = 0.5;
    gridBagConstraints3.weighty = 1.0;
    jPanel4.add(jScrollPane2, gridBagConstraints3);

    gridBagConstraints1 = new java.awt.GridBagConstraints();
    gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints1.insets = new java.awt.Insets(5, 5, 0, 0);
    gridBagConstraints1.weightx = 0.375;
    gridBagConstraints1.weighty = 1.0;
    getContentPane().add(jPanel4, gridBagConstraints1);

    jPanel5.setLayout(new java.awt.GridBagLayout());
    java.awt.GridBagConstraints gridBagConstraints4;
    jPanel5.setBorder(new javax.swing.border.TitledBorder(new javax.swing.border.EtchedBorder(), " Size "));

    jSize.setColumns(6);
    jSize.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jSizeActionPerformed(evt);
        }
    });
    gridBagConstraints4 = new java.awt.GridBagConstraints();
    gridBagConstraints4.gridwidth = 0;
    gridBagConstraints4.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints4.insets = new java.awt.Insets(0, 3, 0, 3);
    gridBagConstraints4.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints4.weightx = 1.0;
    jPanel5.add(jSize, gridBagConstraints4);

    jSizeList.setModel(new DefaultListModel());
    jSizeList.setVisibleRowCount(4);
    jSizeList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
    jSizeList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
        public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
            jSizeListValueChanged(evt);
        }
    });
    jScrollPane3.setViewportView(jSizeList);

    gridBagConstraints4 = new java.awt.GridBagConstraints();
    gridBagConstraints4.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints4.insets = new java.awt.Insets(3, 3, 3, 3);
    gridBagConstraints4.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints4.weightx = 0.25;
    gridBagConstraints4.weighty = 1.0;
    jPanel5.add(jScrollPane3, gridBagConstraints4);

    gridBagConstraints1 = new java.awt.GridBagConstraints();
    gridBagConstraints1.gridwidth = 0;
    gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints1.insets = new java.awt.Insets(5, 5, 0, 5);
    gridBagConstraints1.weightx = 0.125;
    gridBagConstraints1.weighty = 1.0;
    getContentPane().add(jPanel5, gridBagConstraints1);

    jPanel1.setLayout(new java.awt.GridBagLayout());
    java.awt.GridBagConstraints gridBagConstraints5;
    jPanel1.setBorder(new javax.swing.border.TitledBorder(new javax.swing.border.EtchedBorder(), " Sample "));

    jSample.setWrapStyleWord(true);
    jSample.setLineWrap(true);
    jSample.setColumns(20);
    jSample.setRows(3);
    jSample.setText("The quick brown fox jumped over the lazy dog.");
    jScrollPane4.setViewportView(jSample);

    gridBagConstraints5 = new java.awt.GridBagConstraints();
    gridBagConstraints5.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints5.insets = new java.awt.Insets(0, 3, 3, 3);
    gridBagConstraints5.weightx = 1.0;
    gridBagConstraints5.weighty = 1.0;
    jPanel1.add(jScrollPane4, gridBagConstraints5);

    gridBagConstraints1 = new java.awt.GridBagConstraints();
    gridBagConstraints1.gridwidth = 0;
    gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints1.insets = new java.awt.Insets(0, 5, 0, 5);
    gridBagConstraints1.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints1.weightx = 1.0;
    getContentPane().add(jPanel1, gridBagConstraints1);

    jButtons.setLayout(new java.awt.GridBagLayout());
    java.awt.GridBagConstraints gridBagConstraints6;

    jOk.setMnemonic(KeyEvent.VK_O);
    jOk.setText("OK");
    jOk.setRequestFocusEnabled(false);
    jOk.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jOkActionPerformed(evt);
        }
    });
    gridBagConstraints6 = new java.awt.GridBagConstraints();
    gridBagConstraints6.insets = new java.awt.Insets(5, 5, 5, 0);
    gridBagConstraints6.anchor = java.awt.GridBagConstraints.WEST;
    jButtons.add(jOk, gridBagConstraints6);

    jCancel.setMnemonic(KeyEvent.VK_C);
    jCancel.setText("Cancel");
    jCancel.setRequestFocusEnabled(false);
    jCancel.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jCancelActionPerformed(evt);
        }
    });
    gridBagConstraints6 = new java.awt.GridBagConstraints();
    gridBagConstraints6.gridwidth = 0;
    gridBagConstraints6.insets = new java.awt.Insets(5, 5, 5, 5);
    gridBagConstraints6.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints6.weightx = 1.0;
    jButtons.add(jCancel, gridBagConstraints6);

    gridBagConstraints6 = new java.awt.GridBagConstraints();
    gridBagConstraints6.weightx = 1.0;
    jButtons.add(jLabel6, gridBagConstraints6);

    gridBagConstraints1 = new java.awt.GridBagConstraints();
    gridBagConstraints1.gridwidth = 0;
    gridBagConstraints1.anchor = java.awt.GridBagConstraints.SOUTHWEST;
    gridBagConstraints1.weightx = 1.0;
    getContentPane().add(jButtons, gridBagConstraints1);
}