Example usage for java.awt GridBagConstraints HORIZONTAL

List of usage examples for java.awt GridBagConstraints HORIZONTAL

Introduction

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

Prototype

int HORIZONTAL

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

Click Source Link

Document

Resize the component horizontally but not vertically.

Usage

From source file:com.geometrycloud.happydonut.ui.ChartFilterPanel.java

/**
 * Inicializa los componentes.//from   www. jav a2  s  .  c om
 */
private void initComponents() {
    fromPicker.addActionListener(this);
    toPicker.addActionListener(this);

    chart = new ChartPanel(createChart());

    setLayout(new GridBagLayout());

    GridBagConstraints constraints = new GridBagConstraints();

    constraints.insets.set(5, 5, 5, 5);

    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.fill = GridBagConstraints.NONE;
    constraints.weightx = 0;
    constraints.weighty = 0;
    constraints.gridwidth = 1;
    add(fromLabel, constraints);

    constraints.gridx = 1;
    constraints.gridy = 0;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.weightx = 1;
    constraints.weighty = 1;
    constraints.gridwidth = 1;
    add((JComponent) fromPicker, constraints);

    constraints.gridx = 2;
    constraints.gridy = 0;
    constraints.fill = GridBagConstraints.NONE;
    constraints.weightx = 0;
    constraints.weighty = 0;
    constraints.gridwidth = 1;
    add(toLabel, constraints);

    constraints.gridx = 3;
    constraints.gridy = 0;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.weightx = 1;
    constraints.weighty = 1;
    constraints.gridwidth = 1;
    add((JComponent) toPicker, constraints);

    constraints.gridx = 0;
    constraints.gridy = 1;
    constraints.fill = GridBagConstraints.BOTH;
    constraints.weightx = 1;
    constraints.weighty = 1;
    constraints.gridwidth = GridBagConstraints.REMAINDER;
    add(chart, constraints);
}

From source file:org.aaloa.zb4osgi.network.browser.ui.NetworkGraph.java

private JPanel getStatusBar() {
    if (statusBar != null) {
        return statusBar;
    }/*from w w  w.  jav  a 2 s .c o  m*/
    statusBar = new JPanel();
    statusBar.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
    statusBar.setLayout(new GridBagLayout());
    statusBar.setPreferredSize(new Dimension(800, 16));
    Dimension dimension = new Dimension(1280, 16);
    GridBagConstraints opt = new GridBagConstraints();
    opt.fill = GridBagConstraints.HORIZONTAL;
    opt.gridy = 0;
    opt.ipady = 1;
    opt.ipadx = 3;

    opt.gridx = 0;
    statusLeft = new JLabel("");
    statusLeft.setPreferredSize(dimension);
    statusLeft.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
    statusBar.add(statusLeft, opt);

    opt.gridx = 1;
    statusLeft.setPreferredSize(dimension);
    statusMiddle = new JLabel("Picking Mode");
    statusMiddle.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
    statusBar.add(statusMiddle, opt);

    opt.gridx = 2;
    statusLeft.setPreferredSize(dimension);
    statusRight = new JLabel("");
    statusRight.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
    statusBar.add(statusRight, opt);
    return statusBar;
}

From source file:com.sshtools.common.ui.SshToolsConnectionKerberosTab.java

/**
 * Creates a new SshToolsConnectionKerberosTab object.
 */// w ww  .  ja  v  a 2s  .  c o m
public SshToolsConnectionKerberosTab() {
    super();

    //  Create the main connection details panel
    JPanel mainConnectionDetailsPanel = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.insets = new Insets(0, 2, 2, 2);
    //  enabled option
    //gbc.fill = GridBagConstraints.NONE;
    useKerberos = new JCheckBox("Use MyProxy Kerberos support");
    UIUtil.jGridBagAdd(mainConnectionDetailsPanel, useKerberos, gbc, GridBagConstraints.REMAINDER);
    //  Host name
    UIUtil.jGridBagAdd(mainConnectionDetailsPanel, new JLabel("Hostname"), gbc, GridBagConstraints.REMAINDER);
    //gbc.fill = GridBagConstraints.HORIZONTAL;
    UIUtil.jGridBagAdd(mainConnectionDetailsPanel, jTextHostname, gbc, GridBagConstraints.REMAINDER);
    //gbc.fill = GridBagConstraints.NONE;

    //  Username
    UIUtil.jGridBagAdd(mainConnectionDetailsPanel, new JLabel("Username"), gbc, GridBagConstraints.REMAINDER);
    //gbc.fill = GridBagConstraints.HORIZONTAL;
    UIUtil.jGridBagAdd(mainConnectionDetailsPanel, jTextUsername, gbc, GridBagConstraints.REMAINDER);

    JPanel settingsPanel = new JPanel(new GridBagLayout());
    settingsPanel
            .setBorder(BorderFactory.createTitledBorder("Settings if krb5.conf or krb5.ini file not found: "));
    GridBagConstraints gbc2 = new GridBagConstraints();
    gbc2.fill = GridBagConstraints.HORIZONTAL;
    gbc2.anchor = GridBagConstraints.NORTHWEST;
    gbc2.insets = new Insets(0, 2, 2, 2);
    gbc2.weightx = 1.0;

    //  realm
    UIUtil.jGridBagAdd(settingsPanel, new JLabel("Realm"), gbc2, GridBagConstraints.REMAINDER);
    gbc2.fill = GridBagConstraints.HORIZONTAL;
    UIUtil.jGridBagAdd(settingsPanel, jTextRealm, gbc2, GridBagConstraints.REMAINDER);
    gbc2.fill = GridBagConstraints.NONE;

    //  kdc
    UIUtil.jGridBagAdd(settingsPanel, new JLabel("KDC"), gbc2, GridBagConstraints.REMAINDER);
    gbc2.fill = GridBagConstraints.HORIZONTAL;
    gbc2.weighty = 1.0;
    UIUtil.jGridBagAdd(settingsPanel, jTextKDC, gbc2, GridBagConstraints.REMAINDER);
    gbc2.fill = GridBagConstraints.NONE;

    //
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    gbc.insets = new Insets(4, 2, 2, 2);
    UIUtil.jGridBagAdd(mainConnectionDetailsPanel, settingsPanel, gbc, GridBagConstraints.REMAINDER);

    IconWrapperPanel iconMainConnectionDetailsPanel = new IconWrapperPanel(
            new ResourceIcon(SshToolsConnectionHostTab.class, AUTH_ICON), mainConnectionDetailsPanel);

    setLayout(new GridBagLayout());
    setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.BOTH;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(2, 2, 2, 2);
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    UIUtil.jGridBagAdd(this, iconMainConnectionDetailsPanel, gbc, GridBagConstraints.REMAINDER);

}

From source file:com.sshtools.common.ui.OptionsPanel.java

/**
 *
 *
 * @param parent/*  w w w  . j  a v  a  2  s.  c  om*/
 * @param tabs tabs
 *
 * @return
 */
public static boolean showOptionsDialog(Component parent, OptionsTab[] tabs) {
    final OptionsPanel opts = new OptionsPanel(tabs);
    opts.reset();

    JDialog d = null;
    Window w = (Window) SwingUtilities.getAncestorOfClass(Window.class, parent);

    if (w instanceof JDialog) {
        d = new JDialog((JDialog) w, "Options", true);
    } else if (w instanceof JFrame) {
        d = new JDialog((JFrame) w, "Options", true);
    } else {
        d = new JDialog((JFrame) null, "Options", true);
    }

    final JDialog dialog = d;

    //  Create the bottom button panel
    final JButton cancel = new JButton("Cancel");
    cancel.setMnemonic('c');
    cancel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            opts.cancelled = true;
            dialog.setVisible(false);
        }
    });

    final JButton ok = new JButton("Ok");
    ok.setMnemonic('o');
    ok.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            if (opts.validateTabs()) {
                dialog.setVisible(false);
            }
        }
    });
    dialog.getRootPane().setDefaultButton(ok);

    JPanel buttonPanel = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.insets = new Insets(6, 6, 0, 0);
    gbc.weighty = 1.0;
    UIUtil.jGridBagAdd(buttonPanel, ok, gbc, GridBagConstraints.RELATIVE);
    UIUtil.jGridBagAdd(buttonPanel, cancel, gbc, GridBagConstraints.REMAINDER);

    JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 0));
    southPanel.add(buttonPanel);

    //
    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    mainPanel.add(opts, BorderLayout.CENTER);
    mainPanel.add(southPanel, BorderLayout.SOUTH);

    // Show the dialog
    dialog.getContentPane().setLayout(new GridLayout(1, 1));
    dialog.getContentPane().add(mainPanel);
    dialog.pack();
    dialog.setResizable(true);
    UIUtil.positionComponent(SwingConstants.CENTER, dialog);
    dialog.setVisible(true);

    if (!opts.cancelled) {
        opts.applyTabs();
    }

    return !opts.cancelled;
}

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

private void initializeComponent() {
    if (!this.initialized) {
        if (this.file == null) {
            this.dialogTitle = "No File Provided";
            this.file = null;
        } else {/*from  w w  w  .j a v a2 s.  c  om*/
            StringBuilder title = new StringBuilder(128);
            this.dialogTitle = title.append("Attributes for ").append(file.getFile().getName()).toString();
            title.setLength(0);
            title = null;
        }

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

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

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

        GridBagConstraints filePathValueConstraints = new GridBagConstraints();
        filePathValueConstraints.anchor = GridBagConstraints.WEST;
        filePathValueConstraints.gridx = 0;
        filePathValueConstraints.gridy = 0;
        filePathValueConstraints.weightx = 1.0;
        filePathValueConstraints.weighty = 1.0;
        filePathValueConstraints.gridheight = 1;
        filePathValueConstraints.gridwidth = 1;
        filePathValueConstraints.insets = new Insets(5, 5, 5, 5);

        String filePath = "File is null.";
        if (file != null) {
            File diskFile = file.getFile();
            if (diskFile == null) {
                filePath = "The disk file is not set.";
            } else {
                filePath = diskFile.getPath();
            }
            diskFile = null;
        }
        JLabel filePathValue = new JLabel(filePath);
        filePath = null;
        filePanel.add(filePathValue, filePathValueConstraints);

        this.add(filePanel, filePanelConstraints);

        Border attributesBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
        attributesBorder = BorderFactory.createTitledBorder(attributesBorder, "File Attributes",
                TitledBorder.CENTER, TitledBorder.TOP);

        GridBagConstraints attributesPanelConstraints = new GridBagConstraints();
        attributesPanelConstraints.anchor = GridBagConstraints.SOUTH;
        attributesPanelConstraints.fill = GridBagConstraints.BOTH;
        attributesPanelConstraints.gridx = 0;
        attributesPanelConstraints.gridy = 1;
        attributesPanelConstraints.weightx = 1.0;
        attributesPanelConstraints.weighty = 0.9;
        attributesPanelConstraints.gridheight = 1;
        attributesPanelConstraints.gridwidth = 1;
        attributesPanelConstraints.insets = new Insets(0, 5, 5, 5);

        JPanel attributesPanel = this.createFileAttributesPanel(file);

        attributesPanel.setBorder(attributesBorder);

        this.add(attributesPanel, attributesPanelConstraints);

        this.initialized = true;
    }
}

From source file:com.sec.ose.osi.ui.frm.main.identification.autoidentify.JPanImportSPDX.java

private JPanel getJPanMain() {
    if (jPanMain == null) {
        jPanMain = new JPanel();

        GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
        gridBagConstraints1.fill = GridBagConstraints.BOTH;
        gridBagConstraints1.gridx = 0;/*  ww  w.  jav a  2s . c  o m*/
        gridBagConstraints1.gridy = 0;
        GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
        gridBagConstraints2.fill = GridBagConstraints.BOTH;
        gridBagConstraints2.gridx = 0;
        gridBagConstraints2.gridy = 1;
        GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
        gridBagConstraints3.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints3.gridx = 0;
        gridBagConstraints3.gridy = 2;

        jPanMain.add(getJScrollPaneImportSPDX(), gridBagConstraints1);

        jPanMain.add(getJPanelForOption(), gridBagConstraints2);
        jPanMain.add(getJButtonPanel(), gridBagConstraints3);

        addJPanSPDXLocation(null);
    }

    return jPanMain;
}

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

@Override
protected void initializeComponent() {
    if (!this.initialized) {
        if (this.exclusion == null) {
            this.mode = AssuranceDialogMode.ADD;
            this.dialogTitle = "Add New Exclusion";
            this.exclusion = new FileReference();
        } else {//from  ww  w  . j  a v a 2s .  c  o m
            this.mode = AssuranceDialogMode.EDIT;
            this.dialogTitle = "Edit Exclusion";
        }

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

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

        Border exclusionPanelBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
        exclusionPanelBorder = BorderFactory.createTitledBorder(exclusionPanelBorder, "Exclusion",
                TitledBorder.CENTER, TitledBorder.TOP);

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

        exclusionPathPanel.setBorder(exclusionPanelBorder);
        this.add(exclusionPathPanel, exclusionPathPanelConstraints);

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

        exclusionPathPanel.add(this.exclusionPathTextFieldPicker, exclusionPathFieldConstraints);

        if (this.exclusion != null) {
            File exclusionPath = exclusion.getFile();
            if (exclusionPath != null) {
                this.exclusionPathTextFieldPicker.setValue(exclusionPath.getPath());
            } else {
                this.exclusionPathTextFieldPicker.setValue("");
            }
        }

        this.initialized = true;
    }
}

From source file:DocumentEventDemo.java

public DocumentEventDemo() {
    super(new GridBagLayout());
    GridBagLayout gridbag = (GridBagLayout) getLayout();
    GridBagConstraints c = new GridBagConstraints();

    JButton button = new JButton("Clear");
    button.addActionListener(this);

    textField = new JTextField(20);
    textField.addActionListener(new MyTextActionListener());
    textField.getDocument().addDocumentListener(new MyDocumentListener());
    textField.getDocument().putProperty("name", "Text Field");

    textArea = new JTextArea();
    textArea.getDocument().addDocumentListener(new MyDocumentListener());
    textArea.getDocument().putProperty("name", "Text Area");

    JScrollPane scrollPane = new JScrollPane(textArea);
    scrollPane.setPreferredSize(new Dimension(200, 75));

    displayArea = new JTextArea();
    displayArea.setEditable(false);/*w  w w  . j  ava2s .c  om*/
    JScrollPane displayScrollPane = new JScrollPane(displayArea);
    displayScrollPane.setPreferredSize(new Dimension(200, 75));

    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    gridbag.setConstraints(textField, c);
    add(textField);

    c.gridx = 0;
    c.gridy = 1;
    c.weightx = 0.0;
    c.gridheight = 2;
    c.fill = GridBagConstraints.BOTH;
    gridbag.setConstraints(scrollPane, c);
    add(scrollPane);

    c.gridx = 1;
    c.gridy = 0;
    c.weightx = 1.0;
    c.weighty = 1.0;
    gridbag.setConstraints(displayScrollPane, c);
    add(displayScrollPane);

    c.gridx = 1;
    c.gridy = 2;
    c.weightx = 0.0;
    c.gridheight = 1;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    gridbag.setConstraints(button, c);
    add(button);

    setPreferredSize(new Dimension(450, 250));
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
}

From source file:org.fhcrc.cpl.viewer.quant.gui.PanelWithLogRatioHistAndFields.java

/**
 * Lay out GUI components, but NOT the histogram
 *//*  www. ja  va 2 s  . c o  m*/
protected void initGUI() {
    setLayout(new GridBagLayout());
    maxLowRatioLabel = new JLabel("Max Low Ratio: ");
    minHighRatioLabel = new JLabel("Min High Ratio: ");
    numPassingRatiosLabel = new JLabel("Retained: ");
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.PAGE_START;
    gbc.insets = new Insets(0, 0, 0, 0);
    gbc.weighty = 0;
    gbc.weightx = 1;
    gbc.gridwidth = 1;
    add(maxLowRatioLabel, gbc);
    gbc.gridwidth = GridBagConstraints.RELATIVE;
    add(minHighRatioLabel, gbc);
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    add(numPassingRatiosLabel, gbc);
}

From source file:org.executequery.gui.browser.FindAction.java

private void init() {

    searchPanel = new JPanel(new GridBagLayout());
    popup = new JPopupMenu();

    searchField = WidgetFactory.createTextField();
    searchField.setPreferredSize(new Dimension(270, 22));

    resultsList = initSearchResultsList();
    JScrollPane scrollPane = new JScrollPane(resultsList);
    scrollPane.setPreferredSize(new Dimension(300, 150));

    JLabel label = new JLabel(" Search: ");

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;// w w  w  .  j a v a2s . c o  m
    gbc.gridy = 0;
    gbc.insets.left = 3;
    gbc.insets.top = 3;
    gbc.insets.bottom = 3;
    searchPanel.add(label, gbc);
    gbc.gridx = 1;
    gbc.insets.right = 3;
    gbc.insets.left = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    searchPanel.add(searchField, gbc);
    gbc.gridx = 0;
    gbc.gridy++;
    gbc.gridwidth = 2;
    gbc.insets.left = 3;
    gbc.insets.top = 0;
    gbc.fill = GridBagConstraints.BOTH;
    searchPanel.add(scrollPane, gbc);

    popup.setBorder(BorderFactory.createLineBorder(UIUtils.getDefaultBorderColour()));
    popup.add(searchPanel);

    // when the window containing the "comp" has registered Esc key
    // then on pressing Esc instead of search popup getting closed
    // the event is sent to the window. to overcome this we
    // register an action for Esc.
    searchField.registerKeyboardAction(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            popup.setVisible(false);
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_FOCUSED);
}