Example usage for java.awt GridBagConstraints EAST

List of usage examples for java.awt GridBagConstraints EAST

Introduction

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

Prototype

int EAST

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

Click Source Link

Document

Put the component on the right side of its display area, centered vertically.

Usage

From source file:com.xmage.launcher.XMageLauncher.java

private XMageLauncher() {
    locale = Locale.getDefault();
    //locale = new Locale("it", "IT");
    messages = ResourceBundle.getBundle("MessagesBundle", locale);
    localize();/*from w  w w.j  a  v a 2  s.  c o  m*/

    serverConsole = new XMageConsole("XMage Server console");
    clientConsole = new XMageConsole("XMage Client console");

    frame = new JFrame(messages.getString("frameTitle") + " " + Config.getVersion());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setPreferredSize(new Dimension(800, 500));
    frame.setResizable(false);

    createToolbar();

    ImageIcon icon = new ImageIcon(XMageLauncher.class.getResource("/icon-mage-flashed.png"));
    frame.setIconImage(icon.getImage());

    Random r = new Random();
    int imageNum = 1 + r.nextInt(17);
    ImageIcon background = new ImageIcon(new ImageIcon(
            XMageLauncher.class.getResource("/backgrounds/" + Integer.toString(imageNum) + ".jpg")).getImage()
                    .getScaledInstance(800, 480, Image.SCALE_SMOOTH));
    mainPanel = new JLabel(background) {
        @Override
        public Dimension getPreferredSize() {
            Dimension size = super.getPreferredSize();
            Dimension lmPrefSize = getLayout().preferredLayoutSize(this);
            size.width = Math.max(size.width, lmPrefSize.width);
            size.height = Math.max(size.height, lmPrefSize.height);
            return size;
        }
    };
    mainPanel.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            grabPoint = e.getPoint();
            mainPanel.getComponentAt(grabPoint);
        }
    });
    mainPanel.addMouseMotionListener(new MouseMotionAdapter() {
        @Override
        public void mouseDragged(MouseEvent e) {

            // get location of Window
            int thisX = frame.getLocation().x;
            int thisY = frame.getLocation().y;

            // Determine how much the mouse moved since the initial click
            int xMoved = (thisX + e.getX()) - (thisX + grabPoint.x);
            int yMoved = (thisY + e.getY()) - (thisY + grabPoint.y);

            // Move window to this position
            int X = thisX + xMoved;
            int Y = thisY + yMoved;
            frame.setLocation(X, Y);
        }
    });
    mainPanel.setLayout(new GridBagLayout());

    GridBagConstraints constraints = new GridBagConstraints();
    constraints.insets = new Insets(10, 10, 10, 10);

    Font font16 = new Font("Arial", Font.BOLD, 16);
    Font font12 = new Font("Arial", Font.PLAIN, 12);
    Font font12b = new Font("Arial", Font.BOLD, 12);

    mainPanel.add(Box.createRigidArea(new Dimension(250, 50)));

    ImageIcon logo = new ImageIcon(new ImageIcon(XMageLauncher.class.getResource("/label-xmage.png")).getImage()
            .getScaledInstance(150, 75, Image.SCALE_SMOOTH));
    xmageLogo = new JLabel(logo);
    constraints.gridx = 3;
    constraints.gridy = 0;
    constraints.gridheight = 1;
    constraints.gridwidth = GridBagConstraints.REMAINDER;
    constraints.anchor = GridBagConstraints.EAST;
    mainPanel.add(xmageLogo, constraints);

    textArea = new JTextArea(5, 40);
    textArea.setEditable(false);
    textArea.setForeground(Color.WHITE);
    textArea.setBackground(Color.BLACK);
    DefaultCaret caret = (DefaultCaret) textArea.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    scrollPane = new JScrollPane(textArea);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    constraints.gridx = 2;
    constraints.gridy = 1;
    constraints.weightx = 1.0;
    constraints.weighty = 1.0;
    constraints.fill = GridBagConstraints.BOTH;
    mainPanel.add(scrollPane, constraints);

    labelProgress = new JLabel(messages.getString("progress"));
    labelProgress.setFont(font12);
    labelProgress.setForeground(Color.WHITE);
    constraints.gridy = 2;
    constraints.weightx = 0.0;
    constraints.weighty = 0.0;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.WEST;
    mainPanel.add(labelProgress, constraints);

    progressBar = new JProgressBar(0, 100);
    constraints.gridx = 3;
    constraints.weightx = 1.0;
    constraints.gridwidth = GridBagConstraints.REMAINDER;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    mainPanel.add(progressBar, constraints);

    JPanel pnlButtons = new JPanel();
    pnlButtons.setLayout(new GridBagLayout());
    pnlButtons.setOpaque(false);
    constraints.gridx = 0;
    constraints.gridy = 3;
    constraints.gridheight = GridBagConstraints.REMAINDER;
    constraints.fill = GridBagConstraints.BOTH;
    mainPanel.add(pnlButtons, constraints);

    btnLaunchClient = new JButton(messages.getString("launchClient"));
    btnLaunchClient.setToolTipText(messages.getString("launchClient.tooltip"));
    btnLaunchClient.setFont(font16);
    btnLaunchClient.setForeground(Color.GRAY);
    btnLaunchClient.setEnabled(false);
    btnLaunchClient.setPreferredSize(new Dimension(180, 60));
    btnLaunchClient.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            handleClient();
        }
    });

    constraints.gridx = GridBagConstraints.RELATIVE;
    constraints.gridy = 0;
    constraints.gridwidth = 1;
    constraints.fill = GridBagConstraints.BOTH;
    pnlButtons.add(btnLaunchClient, constraints);

    btnLaunchClientServer = new JButton(messages.getString("launchClientServer"));
    btnLaunchClientServer.setToolTipText(messages.getString("launchClientServer.tooltip"));
    btnLaunchClientServer.setFont(font12b);
    btnLaunchClientServer.setEnabled(false);
    btnLaunchClientServer.setForeground(Color.GRAY);
    btnLaunchClientServer.setPreferredSize(new Dimension(80, 40));
    btnLaunchClientServer.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            handleServer();
            handleClient();
        }
    });

    constraints.fill = GridBagConstraints.HORIZONTAL;
    pnlButtons.add(btnLaunchClientServer, constraints);

    btnLaunchServer = new JButton(messages.getString("launchServer"));
    btnLaunchServer.setToolTipText(messages.getString("launchServer.tooltip"));
    btnLaunchServer.setFont(font12b);
    btnLaunchServer.setEnabled(false);
    btnLaunchServer.setForeground(Color.GRAY);
    btnLaunchServer.setPreferredSize(new Dimension(80, 40));
    btnLaunchServer.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            handleServer();
        }
    });

    pnlButtons.add(btnLaunchServer, constraints);

    btnUpdate = new JButton(messages.getString("update.xmage"));
    btnUpdate.setToolTipText(messages.getString("update.xmage.tooltip"));
    btnUpdate.setFont(font12b);
    btnUpdate.setForeground(Color.BLACK);
    btnUpdate.setPreferredSize(new Dimension(80, 40));
    btnUpdate.setEnabled(true);

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

    pnlButtons.add(btnUpdate, constraints);

    btnCheck = new JButton(messages.getString("check.xmage"));
    btnCheck.setToolTipText(messages.getString("check.xmage.tooltip"));
    btnCheck.setFont(font12b);
    btnCheck.setForeground(Color.BLACK);
    btnCheck.setPreferredSize(new Dimension(80, 40));
    btnCheck.setEnabled(true);

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

    pnlButtons.add(btnCheck, constraints);

    frame.add(mainPanel);
    frame.pack();
    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setLocation(dim.width / 2 - frame.getSize().width / 2, dim.height / 2 - frame.getSize().height / 2);
}

From source file:gov.loc.repository.bagger.ui.NewBagFrame.java

private void layoutProfileSelection(JPanel contentPane, int row) {
    // content//from   ww  w .j  a v a 2  s  . c o m
    // profile selection
    JLabel bagProfileLabel = new JLabel(bagView.getPropertyMessage("Select Profile:"));
    bagProfileLabel.setToolTipText(bagView.getPropertyMessage("bag.projectlist.help"));

    profileList = new JComboBox(bagView.getProfileStore().getProfileNames());
    profileList.setName(bagView.getPropertyMessage("bag.label.projectlist"));
    profileList.setSelectedItem(bagView.getPropertyMessage("bag.project.noproject"));
    profileList.setToolTipText(bagView.getPropertyMessage("bag.projectlist.help"));

    GridBagConstraints glbc = new GridBagConstraints();

    JLabel spacerLabel = new JLabel();
    glbc = LayoutUtil.buildGridBagConstraints(0, row, 1, 1, 5, 50, GridBagConstraints.HORIZONTAL,
            GridBagConstraints.WEST);
    contentPane.add(bagProfileLabel, glbc);
    glbc = LayoutUtil.buildGridBagConstraints(1, row, 1, 1, 40, 50, GridBagConstraints.HORIZONTAL,
            GridBagConstraints.CENTER);
    contentPane.add(profileList, glbc);
    glbc = LayoutUtil.buildGridBagConstraints(2, row, 1, 1, 40, 50, GridBagConstraints.NONE,
            GridBagConstraints.EAST);
    contentPane.add(spacerLabel, glbc);
}

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

/**
 * This method initializes jPanel   /*from   ww  w . ja v a 2s .  c  o m*/
 *    
 * @return javax.swing.JPanel   
 */
private JPanel getJPanel() {
    if (jPanel == null) {
        GridBagConstraints gridBagConstraints9 = new GridBagConstraints();
        gridBagConstraints9.fill = GridBagConstraints.BOTH;
        gridBagConstraints9.gridy = 4;
        gridBagConstraints9.weightx = 1.0;
        gridBagConstraints9.anchor = GridBagConstraints.WEST;
        gridBagConstraints9.gridx = 1;
        GridBagConstraints gridBagConstraints8 = new GridBagConstraints();
        gridBagConstraints8.gridx = 0;
        gridBagConstraints8.anchor = GridBagConstraints.EAST;
        gridBagConstraints8.gridy = 4;
        jLabel4 = new JLabel();
        jLabel4.setText("Image Of:");
        GridBagConstraints gridBagConstraints7 = new GridBagConstraints();
        gridBagConstraints7.gridx = 1;
        gridBagConstraints7.weighty = 1.0;
        gridBagConstraints7.gridy = 6;
        GridBagConstraints gridBagConstraints6 = new GridBagConstraints();
        gridBagConstraints6.gridx = 1;
        gridBagConstraints6.gridy = 5;
        GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
        gridBagConstraints5.fill = GridBagConstraints.BOTH;
        gridBagConstraints5.gridy = 3;
        gridBagConstraints5.weightx = 1.0;
        gridBagConstraints5.anchor = GridBagConstraints.WEST;
        gridBagConstraints5.gridx = 1;
        GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
        gridBagConstraints4.gridx = 0;
        gridBagConstraints4.anchor = GridBagConstraints.EAST;
        gridBagConstraints4.weighty = 0.0;
        gridBagConstraints4.gridy = 3;
        jLabel3 = new JLabel();
        jLabel3.setText("DrawerNumber:");
        GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
        gridBagConstraints3.gridwidth = 2;
        gridBagConstraints3.weighty = 0.0;
        gridBagConstraints3.anchor = GridBagConstraints.NORTH;
        GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
        gridBagConstraints2.fill = GridBagConstraints.BOTH;
        gridBagConstraints2.gridy = 2;
        gridBagConstraints2.weightx = 1.0;
        gridBagConstraints2.anchor = GridBagConstraints.WEST;
        gridBagConstraints2.gridx = 1;
        GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
        gridBagConstraints1.gridx = 0;
        gridBagConstraints1.anchor = GridBagConstraints.EAST;
        gridBagConstraints1.weighty = 0.0;
        gridBagConstraints1.gridy = 2;
        jLabel2 = new JLabel();
        jLabel2.setText("Barcode:");
        GridBagConstraints gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.insets = new Insets(0, 0, 5, 0);
        gridBagConstraints.weighty = 0.0;
        gridBagConstraints.gridy = 1;
        jLabel1 = new JLabel();
        jLabel1.setText("Please Identify this Image.");
        jLabel = new JLabel();
        jLabel.setText("No Barcode or drawer number found.");
        jPanel = new JPanel();
        jPanel.setLayout(new GridBagLayout());
        jPanel.add(jLabel, gridBagConstraints3);
        jPanel.add(jLabel1, gridBagConstraints);
        jPanel.add(jLabel2, gridBagConstraints1);
        jPanel.add(getJTextFieldBarcode(), gridBagConstraints2);
        jPanel.add(jLabel3, gridBagConstraints4);
        jPanel.add(getJTextFieldDrawerNumber(), gridBagConstraints5);
        jPanel.add(getJButton(), gridBagConstraints6);
        jPanel.add(getJPanel2(), gridBagConstraints7);
        jPanel.add(jLabel4, gridBagConstraints8);
        jPanel.add(getJComboBox(), gridBagConstraints9);
    }
    return jPanel;
}

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

/**
 * Build the UI.//  www .jav  a  2  s  . co  m
 */
private void buildUi() {
    // Set the layout
    setLayout(new BorderLayout());

    // Create a grid bag constraints configuration
    GridBagConstraints c = new GridBagConstraints();

    // Create the container and body state panel
    final JPanel container = new JPanel(new GridBagLayout());
    container.setBorder(BorderFactory.createEmptyBorder(16, 16, 16, 16));

    // Add the close button
    c.fill = GridBagConstraints.NONE;
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 0;
    c.weighty = 0;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(0, 0, 0, 0);
    container.add(new JLabel("Select a student to see their details."), c);

    // Add the body state panel to the container
    c.fill = GridBagConstraints.BOTH;
    c.gridx = 0;
    c.gridy = 1;
    c.weightx = 1;
    c.weighty = 1;
    c.anchor = GridBagConstraints.CENTER;
    c.insets = new Insets(16, 0, 0, 0);
    container.add(buildUiBodyStatePanel(), c);

    // Create the close button
    final JButton closeButton = new JButton("Close");
    closeButton.addActionListener(e -> dispose());

    // Add the close button
    c.fill = GridBagConstraints.NONE;
    c.gridx = 0;
    c.gridy = 2;
    c.weightx = 0;
    c.weighty = 0;
    c.anchor = GridBagConstraints.EAST;
    c.insets = new Insets(8, 0, 0, 0);
    container.add(closeButton, c);

    // Add the container
    add(container, BorderLayout.CENTER);
}

From source file:com.db4o.sync4o.ui.Db4oSyncSourceConfigPanel.java

private void setupControls() {

    // Layout and setup UI components...

    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    add(_namePanel);/*from w  w  w .  j ava  2  s  . co  m*/
    _namePanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    add(_fieldsPanel);
    _fieldsPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    add(_classConfigsTree);
    _classConfigsTree.setAlignmentX(Component.LEFT_ALIGNMENT);
    _classConfigsTree.setPreferredSize(new Dimension(300, 300));
    add(_buttonsPanel);
    _buttonsPanel.setAlignmentX(Component.LEFT_ALIGNMENT);

    JLabel l;

    // Admin UI Management Panels use a title
    // (in a particular "title font") to identify themselves
    l = new JLabel("Edit Db4oSyncSource Configuration", SwingConstants.CENTER);
    l.setBorder(new TitledBorder(""));
    l.setFont(titlePanelFont);
    _namePanel.add(l);

    GridBagConstraints labelConstraints = new GridBagConstraints();
    labelConstraints.gridwidth = 1;
    labelConstraints.fill = GridBagConstraints.NONE;
    labelConstraints.weightx = 0.0;
    labelConstraints.gridx = 0;
    labelConstraints.gridy = 0;
    labelConstraints.anchor = GridBagConstraints.EAST;

    GridBagConstraints fieldConstraints = new GridBagConstraints();
    fieldConstraints.gridwidth = 2;
    fieldConstraints.fill = GridBagConstraints.HORIZONTAL;
    fieldConstraints.weightx = 1.0;
    fieldConstraints.gridx = 1;
    fieldConstraints.gridy = 0;

    _fieldsPanel.add(new JLabel("Source URI: "), labelConstraints);
    _fieldsPanel.add(_sourceUriValue, fieldConstraints);

    labelConstraints.gridy = GridBagConstraints.RELATIVE;
    fieldConstraints.gridy = GridBagConstraints.RELATIVE;

    _fieldsPanel.add(new JLabel("Name: "), labelConstraints);
    _fieldsPanel.add(_nameValue, fieldConstraints);

    fieldConstraints.gridwidth = 1;

    _fieldsPanel.add(new JLabel("db4o File: "), labelConstraints);
    _fieldsPanel.add(_dbFileValue, fieldConstraints);

    _dbFileValue.setEditable(false);

    fieldConstraints.gridwidth = 2;

    GridBagConstraints buttonConstraints = new GridBagConstraints();
    buttonConstraints.gridwidth = 1;
    buttonConstraints.fill = GridBagConstraints.NONE;
    buttonConstraints.gridx = 2;
    buttonConstraints.gridy = 3;
    _dbFileLocateButton.setText("...");
    _fieldsPanel.add(_dbFileLocateButton, buttonConstraints);

    buttonConstraints.gridwidth = 3;
    buttonConstraints.fill = GridBagConstraints.NONE;
    buttonConstraints.gridx = 0;
    buttonConstraints.gridy = GridBagConstraints.RELATIVE;
    buttonConstraints.anchor = GridBagConstraints.CENTER;

    // Ensure all the controls use the Admin UI standard font
    Component[] components = _fieldsPanel.getComponents();
    for (int i = 0; i < components.length; i++) {

        Component c = components[i];
        c.setFont(defaultFont);

    }

    _confirmButton.setText("Add");
    _buttonsPanel.add(_confirmButton);

}

From source file:com.intel.stl.ui.main.view.HealthHistoryView.java

@Override
protected JPanel getMainComponent() {
    if (mainPanel != null) {
        return mainPanel;
    }//  ww w  .j  a v a  2  s . c  o  m

    mainPanel = new JPanel();
    GridBagLayout gridBag = new GridBagLayout();
    mainPanel.setLayout(gridBag);
    GridBagConstraints gc = new GridBagConstraints();

    gc.fill = GridBagConstraints.BOTH;
    gc.weightx = 1;
    gc.weighty = 1;
    gc.gridwidth = GridBagConstraints.REMAINDER;
    chartPanel = new ChartPanel(null);
    // chart.PanelsetBorder(BorderFactory.createMatteBorder(0, 0, 1, 0,
    // UIConstants.INTEL_BORDER_GRAY));
    chartPanel.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            chartPanel.setMaximumDrawHeight(e.getComponent().getHeight());
            chartPanel.setMaximumDrawWidth(e.getComponent().getWidth());
            chartPanel.setMinimumDrawWidth(e.getComponent().getWidth());
            chartPanel.setMinimumDrawHeight(e.getComponent().getHeight());
        }
    });
    mainPanel.add(chartPanel, gc);

    gc.gridwidth = 1;
    gc.insets = new Insets(0, 5, 0, 5);
    gc.fill = GridBagConstraints.NONE;
    gc.anchor = GridBagConstraints.WEST;
    gc.weighty = 0;
    startTimeLabel = ComponentFactory.getH5Label("start", Font.PLAIN);
    mainPanel.add(startTimeLabel, gc);

    gc.gridwidth = GridBagConstraints.REMAINDER;
    gc.anchor = GridBagConstraints.EAST;
    endTimeLabel = ComponentFactory.getH5Label("end", Font.PLAIN);
    mainPanel.add(endTimeLabel, gc);

    return mainPanel;
}

From source file:com.sec.ose.osi.ui.frm.main.manage.dialog.JDlgProjectCreate.java

/**
 * This method initializes jPanelPjtName   
 *    /*  w ww .j av a 2 s .co m*/
 * @return javax.swing.JPanel   
 */
private JPanel getJPanelPjtName() {
    if (jPanelPjtName == null) {
        GridBagConstraints gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.insets = new Insets(10, 10, 0, 0);
        gridBagConstraints.ipadx = 4;
        gridBagConstraints.gridy = 0;
        jLabelNewProjectName = new JLabel();
        jLabelNewProjectName.setText("New Project Name :");
        GridBagConstraints gridBagConstraints7 = new GridBagConstraints();
        gridBagConstraints7.anchor = GridBagConstraints.CENTER;
        gridBagConstraints7.insets = new Insets(10, 10, 10, 0);
        gridBagConstraints7.gridwidth = 1;
        gridBagConstraints7.gridx = 1;
        gridBagConstraints7.gridy = 1;
        gridBagConstraints7.weightx = 0.1;
        gridBagConstraints7.fill = GridBagConstraints.HORIZONTAL;
        GridBagConstraints gridBagConstraints6 = new GridBagConstraints();
        gridBagConstraints6.anchor = GridBagConstraints.EAST;
        gridBagConstraints6.gridx = 0;
        gridBagConstraints6.gridy = 1;
        gridBagConstraints6.ipadx = 0;
        gridBagConstraints6.insets = new Insets(10, 10, 10, 0);
        GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
        gridBagConstraints2.gridx = 2;
        gridBagConstraints2.insets = new Insets(10, 10, 0, 10);
        gridBagConstraints2.fill = GridBagConstraints.NONE;
        gridBagConstraints2.gridy = 0;
        GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
        gridBagConstraints1.fill = GridBagConstraints.BOTH;
        gridBagConstraints1.gridy = 0;
        gridBagConstraints1.weightx = 0.1;
        gridBagConstraints1.gridwidth = 1;
        gridBagConstraints1.insets = new Insets(10, 10, 0, 0);
        gridBagConstraints1.gridx = 1;
        jPanelPjtName = new JPanel();
        jPanelPjtName.setLayout(new GridBagLayout());
        jPanelPjtName.setPreferredSize(new Dimension(500, 200));
        jPanelPjtName.setBorder(BorderFactory.createTitledBorder(null, "Project Name",
                TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION,
                new Font("Dialog", Font.BOLD, 12), new Color(51, 51, 51)));
        jPanelPjtName.add(getJTextFieldNewProjectName(), gridBagConstraints1);
        jPanelPjtName.add(getJButtonCheck(), gridBagConstraints2);
        jPanelPjtName.add(getJCheckBoxClonedFrom(), gridBagConstraints6);
        jPanelPjtName.add(getJComboBoxClonedFrom(), gridBagConstraints7);
        jPanelPjtName.add(jLabelNewProjectName, gridBagConstraints);
    }
    return jPanelPjtName;
}

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

/**
 * layoutProfileSelection./*from  w w w .  j a  v  a 2 s .c o m*/
 *
 * @param contentPane JPanel
 * @param row         int
 */
private void layoutProfileSelection(final JPanel contentPane, final int row) {
    // content
    // profile selection
    final JLabel bagProfileLabel = new JLabel(bagView.getPropertyMessage("Select Profile:"));
    bagProfileLabel.setToolTipText(bagView.getPropertyMessage("bag.projectlist.help"));

    profileList = new JComboBox<>(bagView.getProfileStore().getProfileNames());
    profileList.setName(bagView.getPropertyMessage("bag.label.projectlist"));
    profileList.setSelectedItem(bagView.getPropertyMessage("bag.project.noproject"));
    profileList.setToolTipText(bagView.getPropertyMessage("bag.projectlist.help"));

    GridBagConstraints glbc = new GridBagConstraints();

    final JLabel spacerLabel = new JLabel();
    glbc = LayoutUtil.buildGridBagConstraints(0, row, 1, 1, 5, 50, GridBagConstraints.HORIZONTAL,
            GridBagConstraints.WEST);
    contentPane.add(bagProfileLabel, glbc);
    glbc = LayoutUtil.buildGridBagConstraints(1, row, 1, 1, 40, 50, GridBagConstraints.HORIZONTAL,
            GridBagConstraints.CENTER);
    contentPane.add(profileList, glbc);
    glbc = LayoutUtil.buildGridBagConstraints(2, row, 1, 1, 40, 50, GridBagConstraints.NONE,
            GridBagConstraints.EAST);
    contentPane.add(spacerLabel, glbc);
}

From source file:org.ut.biolab.medsavant.client.filter.TabularFilterView.java

protected final void initContentPanel() {

    setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();

    if (availableValues == null) {
        JTextArea label = new JTextArea(
                "There are too many unique values to generate this list. You will not be able to filter on this column. ");
        label.setOpaque(false);//  w w w. j  a v  a2  s.c o m
        label.setLineWrap(true);
        label.setWrapStyleWord(true);

        gbc.weightx = 1.0;
        gbc.weighty = 1.0;
        gbc.fill = GridBagConstraints.BOTH;
        gbc.insets = new Insets(3, 3, 3, 3);
        add(label, gbc);
        this.showViewCard();
        return;
    }

    applyButton = new JButton("Apply");
    applyButton.setEnabled(false);

    AbstractListModel model = new SimpleListModel();

    field = new QuickListFilterField(model);
    field.setHintText("Type here to filter options");

    // the width of the field has to be less than the width
    // provided to the filter, otherwise, it will push the grid wider
    // and components will be inaccessible
    field.setPreferredSize(new Dimension(FIELD_WIDTH, 22));

    filterableList = new FilterableCheckBoxList(field.getDisplayListModel()) {
        @Override
        public int getNextMatch(String prefix, int startIndex, Position.Bias bias) {
            return -1;
        }

        @Override
        public boolean isCheckBoxEnabled(int index) {
            return true;
        }
    };
    filterableList.getCheckBoxListSelectionModel()
            .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    if (model.getSize() > 0) {
        filterableList.setPrototypeCellValue(model.getElementAt(0)); // Makes it much faster to determine the view's preferred size.
    }

    SearchableUtils.installSearchable(filterableList);

    filterableList.getCheckBoxListSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                applyButton.setEnabled(true);
            }
        }
    });

    setAllSelected(true);

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

    JScrollPane jsp = new JScrollPane(filterableList) {
        @Override
        public Dimension getPreferredSize() {
            Dimension result = super.getPreferredSize();
            result = new Dimension(Math.min(result.width, TabularFilterView.this.getWidth() - 20),
                    result.height);
            return result;
        }
    };

    selectAll = ViewUtil.createHyperLinkButton("Select All");
    selectAll.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setAllSelected(true);
            applyButton.setEnabled(true);
        }
    });

    JButton selectNone = ViewUtil.createHyperLinkButton("Select None");

    selectNone.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setAllSelected(false);
            applyButton.setEnabled(true);
        }
    });

    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(3, 15, 3, 15);
    add(field, gbc);

    gbc.weighty = 1.0;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.insets = new Insets(3, 3, 3, 3);
    add(jsp, gbc);

    gbc.gridwidth = 1;
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    gbc.fill = GridBagConstraints.NONE;
    add(selectAll, gbc);
    add(selectNone, gbc);

    gbc.weightx = 1.0;
    gbc.anchor = GridBagConstraints.EAST;
    add(applyButton, gbc);

    this.showViewCard();

}

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

/**
 * layoutSelectDataContent./*from  w  w w. j  a va2  s  .c om*/
 *
 * @param contentPanel JPanel
 * @param row          int
 */
private void layoutSelectDataContent(final JPanel contentPanel, final int row) {

    final JLabel location = new JLabel("Select Data:");
    final JButton saveAsButton = new JButton(bagView.getPropertyMessage("bag.button.browse"));
    saveAsButton.addActionListener(new BrowseFileHandler());
    saveAsButton.setEnabled(true);
    saveAsButton.setToolTipText(bagView.getPropertyMessage("bag.button.browse.help"));

    String fileName = "";
    if (bag != null) {
        fileName = bag.getName();
    }
    bagNameField = new JTextField(fileName);
    bagNameField.setCaretPosition(fileName.length());
    bagNameField.setEditable(false);
    bagNameField.setEnabled(false);

    GridBagConstraints glbc = new GridBagConstraints();
    glbc = LayoutUtil.buildGridBagConstraints(0, row, 1, 1, 1, 50, GridBagConstraints.NONE,
            GridBagConstraints.WEST);
    contentPanel.add(location, glbc);

    glbc = LayoutUtil.buildGridBagConstraints(2, row, 1, 1, 1, 50, GridBagConstraints.NONE,
            GridBagConstraints.EAST);
    contentPanel.add(saveAsButton, glbc);

    glbc = LayoutUtil.buildGridBagConstraints(1, row, 1, 1, 80, 50, GridBagConstraints.HORIZONTAL,
            GridBagConstraints.WEST);
    glbc.ipadx = 0;
    contentPanel.add(bagNameField, glbc);
}