Example usage for java.awt GridBagConstraints BOTH

List of usage examples for java.awt GridBagConstraints BOTH

Introduction

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

Prototype

int BOTH

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

Click Source Link

Document

Resize the component both horizontally and vertically.

Usage

From source file:org.en.tealEye.guiMain.MainAppFrame.java

private JPanel constructDesktopEnvironment() {
    JPanel jPanel = new JPanel(new GridBagLayout());
    desktop = new JDesktopPane();
    GridBagConstraints gbc;//  w ww. java 2s.com
    gbc = new GridBagConstraints();
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.BOTH;
    jPanel.add(desktop, gbc);
    desktop.setBackground(Color.GRAY);
    desktop.addKeyListener(new MainController(h));
    desktop.requestFocusInWindow();
    return jPanel;
}

From source file:org.bench4Q.console.ui.section.S_SPSSection.java

/**
 * @param resources//ww w  . j  a  v  a  2  s  .c  o  m
 * @param processControl
 * @param dispatcherFactory
 * @param TotalOrNot
 * @param agentIdentity
 * @param agentsCollection
 * @throws ConsoleException
 */
public S_SPSSection(Resources resources, ProcessControl processControl,
        SwingDispatcherFactory dispatcherFactory, Boolean TotalOrNot, AgentIdentity agentIdentity,
        AgentsCollection agentsCollection) throws ConsoleException {

    m_resources = resources;
    m_processControl = processControl;
    m_swingDispatcherFactory = dispatcherFactory;
    m_agentIdentity = agentIdentity;
    m_agentsCollection = agentsCollection;
    m_agentsCollection.registerObserver(this);

    this.TotalOrNot = TotalOrNot;

    this.setLayout(new GridBagLayout());

    this.setPreferredSize(new Dimension(683, 475));
    this.setMinimumSize(new Dimension(683, 475));

    testduring = -1;
    resultNumber = 0;

    picPanel = new PicPanel();
    this.add(picPanel, new GridBagConstraints(0, 0, 1, 4, 99.0, 99.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 1, 1));

}

From source file:org.apache.jackrabbit.oak.explorer.Explorer.java

private void createAndShowGUI(final File path, boolean skipSizeCheck) throws IOException {
    JTextArea log = new JTextArea(5, 20);
    log.setMargin(new Insets(5, 5, 5, 5));
    log.setLineWrap(true);/*from w  w  w.  j av  a2s . com*/
    log.setEditable(false);

    final NodeStoreTree treePanel = new NodeStoreTree(backend, log, skipSizeCheck);

    final JFrame frame = new JFrame("Explore " + path + " @head");
    frame.addWindowListener(new java.awt.event.WindowAdapter() {
        @Override
        public void windowClosing(java.awt.event.WindowEvent windowEvent) {
            IOUtils.closeQuietly(treePanel);
            System.exit(0);
        }
    });

    JPanel content = new JPanel(new GridBagLayout());

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1;
    c.weighty = 1;

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(treePanel),
            new JScrollPane(log));
    splitPane.setDividerLocation(0.3);
    content.add(new JScrollPane(splitPane), c);
    frame.getContentPane().add(content);

    JMenuBar menuBar = new JMenuBar();
    menuBar.setMargin(new Insets(2, 2, 2, 2));

    JMenuItem menuReopen = new JMenuItem("Reopen");
    menuReopen.setMnemonic(KeyEvent.VK_R);
    menuReopen.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ev) {
            try {
                treePanel.reopen();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    });

    JMenuItem menuCompaction = new JMenuItem("Time Machine");
    menuCompaction.setMnemonic(KeyEvent.VK_T);
    menuCompaction.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ev) {
            List<String> revs = backend.readRevisions();
            String s = (String) JOptionPane.showInputDialog(frame, "Revert to a specified revision",
                    "Time Machine", JOptionPane.PLAIN_MESSAGE, null, revs.toArray(), revs.get(0));
            if (s != null && treePanel.revert(s)) {
                frame.setTitle("Explore " + path + " @" + s);
            }
        }
    });

    JMenuItem menuRefs = new JMenuItem("Tar File Info");
    menuRefs.setMnemonic(KeyEvent.VK_I);
    menuRefs.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ev) {
            List<String> tarFiles = new ArrayList<String>();
            for (File f : path.listFiles()) {
                if (f.getName().endsWith(".tar")) {
                    tarFiles.add(f.getName());
                }
            }

            String s = (String) JOptionPane.showInputDialog(frame, "Choose a tar file", "Tar File Info",
                    JOptionPane.PLAIN_MESSAGE, null, tarFiles.toArray(), tarFiles.get(0));
            if (s != null) {
                treePanel.printTarInfo(s);
            }
        }
    });

    JMenuItem menuSCR = new JMenuItem("Segment Refs");
    menuSCR.setMnemonic(KeyEvent.VK_R);
    menuSCR.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ev) {
            String s = JOptionPane.showInputDialog(frame, "Segment References\nUsage: <segmentId>",
                    "Segment References", JOptionPane.PLAIN_MESSAGE);
            if (s != null) {
                treePanel.printSegmentReferences(s);
            }
        }
    });

    JMenuItem menuDiff = new JMenuItem("SegmentNodeState diff");
    menuDiff.setMnemonic(KeyEvent.VK_D);
    menuDiff.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ev) {
            String s = JOptionPane.showInputDialog(frame,
                    "SegmentNodeState diff\nUsage: <recordId> <recordId> [<path>]", "SegmentNodeState diff",
                    JOptionPane.PLAIN_MESSAGE);
            if (s != null) {
                treePanel.printDiff(s);
            }
        }
    });

    JMenuItem menuPCM = new JMenuItem("Persisted Compaction Maps");
    menuPCM.setMnemonic(KeyEvent.VK_P);
    menuPCM.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ev) {
            treePanel.printPCMInfo();
        }
    });

    menuBar.add(menuReopen);
    menuBar.add(new JSeparator(JSeparator.VERTICAL));
    menuBar.add(menuCompaction);
    menuBar.add(new JSeparator(JSeparator.VERTICAL));
    menuBar.add(menuRefs);
    menuBar.add(new JSeparator(JSeparator.VERTICAL));
    menuBar.add(menuSCR);
    menuBar.add(new JSeparator(JSeparator.VERTICAL));
    menuBar.add(menuDiff);
    menuBar.add(new JSeparator(JSeparator.VERTICAL));
    menuBar.add(menuPCM);
    menuBar.add(new JSeparator(JSeparator.VERTICAL));

    frame.setJMenuBar(menuBar);
    frame.pack();
    frame.setSize(960, 720);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

}

From source file:com.sshtools.sshterm.SshTermCommandTab.java

/**
 * Creates a new SshToolsConnectionCommandTab object.
 *//*from www. j  av  a2  s .c o  m*/
public SshTermCommandTab() {
    super();

    JPanel main = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.NORTH;
    gbc.insets = new Insets(0, 2, 2, 2);

    Insets ins2 = new Insets(2, 24, 2, 2);
    gbc.weightx = 1.0;
    requestPseudoTerminal.getModel().setSelected(false);
    disconnectOnSessionClose.getModel().setSelected(true);
    UIUtil.jGridBagAdd(main, requestPseudoTerminal, gbc, GridBagConstraints.REMAINDER);
    UIUtil.jGridBagAdd(main, disconnectOnSessionClose, gbc, GridBagConstraints.REMAINDER);
    UIUtil.jGridBagAdd(main, new JSeparator(JSeparator.HORIZONTAL), gbc, GridBagConstraints.REMAINDER);
    UIUtil.jGridBagAdd(main, onceAuthenticated, gbc, GridBagConstraints.REMAINDER);
    group.add(doNothing);
    group.add(startShell);
    group.add(executeCommands);
    startShell.setSelected(true);
    UIUtil.jGridBagAdd(main, doNothing, gbc, GridBagConstraints.REMAINDER);
    UIUtil.jGridBagAdd(main, startShell, gbc, GridBagConstraints.REMAINDER);
    UIUtil.jGridBagAdd(main, executeCommands, gbc, GridBagConstraints.REMAINDER);
    gbc.fill = GridBagConstraints.BOTH;
    gbc.insets = ins2;
    gbc.weighty = 1.0;

    //commands.setLineWrap(true);
    commands.setBorder(BorderFactory.createEtchedBorder());

    JScrollPane scroll = new JScrollPane(commands);
    scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    UIUtil.jGridBagAdd(main, scroll, gbc, GridBagConstraints.REMAINDER);

    IconWrapperPanel iconProxyDetailsPanel = new IconWrapperPanel(new ResourceIcon(COMMANDS_ICON), main);
    commands.setRows(8);

    //  This panel
    setLayout(new BorderLayout());
    setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.NORTH;
    gbc.insets = new Insets(2, 2, 2, 2);
    gbc.weightx = 1.0;
    add(iconProxyDetailsPanel, BorderLayout.NORTH);
}

From source file:org.bench4Q.console.ui.section.E_ErrorSection.java

/**
 * @param resources//from  ww  w . ja  v  a2 s . c  om
 * @param processControl
 * @param TotalOrNot
 * @param agentIdentity
 * @param agentsCollection
 */
public E_ErrorSection(Resources resources, ProcessControl processControl, Boolean TotalOrNot,
        AgentIdentity agentIdentity, AgentsCollection agentsCollection) {
    m_resources = resources;
    m_processControl = processControl;

    this.TotalOrNot = TotalOrNot;
    m_agentIdentity = agentIdentity;

    m_agentsCollection = agentsCollection;
    m_agentsCollection.registerObserver(this);

    errors = new ErrorSet[15];
    testduring = -1;

    this.setLayout(new GridBagLayout());

    this.setPreferredSize(new Dimension(683, 475));
    this.setMinimumSize(new Dimension(683, 475));

    picPanel = new PicPanel();
    this.add(picPanel, new GridBagConstraints(0, 0, 1, 5, 99.0, 99.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 1, 1));

}

From source file:com.sec.ose.osi.ui.dialog.setting.JPanReportProperty.java

/**
 * This method initializes this//from w w  w .  j  av  a2  s . c  o m
 * 
 * @return void
 */
private void initialize() {
    GridBagConstraints gridBagConstraints9 = new GridBagConstraints();
    gridBagConstraints9.gridx = 2;
    gridBagConstraints9.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints9.gridwidth = 2;
    gridBagConstraints9.insets = new Insets(10, 10, 0, 10);
    gridBagConstraints9.anchor = GridBagConstraints.NORTH;
    gridBagConstraints9.gridy = 0;
    GridBagConstraints gridBagConstraints7 = new GridBagConstraints();
    gridBagConstraints7.gridx = 0;
    gridBagConstraints7.fill = GridBagConstraints.BOTH;
    gridBagConstraints7.gridwidth = 2;
    gridBagConstraints7.insets = new Insets(0, 0, 0, 0);
    gridBagConstraints7.weightx = 1.0;
    gridBagConstraints7.weighty = 1.0;
    gridBagConstraints7.anchor = GridBagConstraints.CENTER;
    gridBagConstraints7.gridy = 0;
    this.setLayout(new GridBagLayout());
    this.add(getJPanelValue(), gridBagConstraints7);
    this.add(getJPanelButtons(), gridBagConstraints9);
}

From source file:org.bench4Q.console.ui.section.S_LengthSection.java

/**
 * @param resources/*from   w  w  w . java  2  s  . c  om*/
 * @param processControl
 * @param dispatcherFactory
 * @param TotalOrNot
 * @param agentIdentity
 * @param agentsCollection
 * @throws ConsoleException
 */
public S_LengthSection(Resources resources, ProcessControl processControl,
        SwingDispatcherFactory dispatcherFactory, Boolean TotalOrNot, AgentIdentity agentIdentity,
        AgentsCollection agentsCollection) throws ConsoleException {

    m_resources = resources;
    m_processControl = processControl;
    m_swingDispatcherFactory = dispatcherFactory;

    this.TotalOrNot = TotalOrNot;
    m_agentIdentity = agentIdentity;
    m_agentsCollection = agentsCollection;
    m_agentsCollection.registerObserver(this);

    this.setLayout(new GridBagLayout());
    this.setPreferredSize(new Dimension(683, 475));
    this.setMinimumSize(new Dimension(683, 475));

    picPanel = new PicPanel();
    this.add(picPanel, new GridBagConstraints(0, 0, 1, 5, 99.0, 99.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 1, 1));

}

From source file:com.intel.stl.ui.monitor.view.PSEventsPieChart.java

protected JPanel getLengendPanel() {
    JPanel panel = new JPanel();
    panel.setOpaque(false);/* w w w  .ja  v  a  2s .c o m*/
    panel.setLayout(new GridBagLayout());
    GridBagConstraints gc = new GridBagConstraints();

    gc.fill = GridBagConstraints.BOTH;
    StateLongTypeViz[] states = StateLongTypeViz.values();
    stateLabels = new JLabel[states.length];
    for (int i = 0; i < states.length; i++) {
        StateLongTypeViz state = states[i];
        gc.insets = new Insets(2, 5, 2, 2);
        gc.weightx = 0;
        gc.gridwidth = 1;

        JLabel label = new JLabel(state.getName(),
                Util.generateImageIcon(state.getColor(), 8, new Insets(1, 1, 1, 1)), JLabel.LEFT);
        label.setFont(UIConstants.H5_FONT);
        label.setForeground(UIConstants.INTEL_DARK_GRAY);
        panel.add(label, gc);

        gc.gridwidth = GridBagConstraints.REMAINDER;
        gc.weightx = 0;
        stateLabels[i] = new JLabel();
        stateLabels[i].setForeground(UIConstants.INTEL_DARK_GRAY);
        stateLabels[i].setFont(UIConstants.H5_FONT);
        panel.add(stateLabels[i], gc);
    }
    return panel;
}

From source file:org.jets3t.gui.ErrorDialog.java

/**
 * Initialises all GUI elements./*from   w w  w  . ja v  a  2 s  .c  o  m*/
 */
private void initGui(String message, String details) {
    // Initialise skins factory.
    skinsFactory = SkinsFactory.getInstance(applicationProperties);

    // Set Skinned Look and Feel.
    LookAndFeel lookAndFeel = skinsFactory.createSkinnedMetalTheme("SkinnedLookAndFeel");
    try {
        UIManager.setLookAndFeel(lookAndFeel);
    } catch (UnsupportedLookAndFeelException e) {
        log.error("Unable to set skinned LookAndFeel", e);
    }

    this.setResizable(false);
    this.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);

    JHtmlLabel messageLabel = skinsFactory.createSkinnedJHtmlLabel("ErrorMessageLabel", hyperlinkListener);
    messageLabel.setText(message);
    messageLabel.setHorizontalAlignment(JLabel.CENTER);
    JHtmlLabel detailsLabel = skinsFactory.createSkinnedJHtmlLabel("ErrorDetailsLabel", hyperlinkListener);
    detailsLabel.setText(details);

    JButton okButton = skinsFactory.createSkinnedJButton("ErrorOkButton");
    okButton.setName("OK");
    okButton.setText("OK");
    okButton.addActionListener(this);
    this.getRootPane().setDefaultButton(okButton);

    JPanel dialogPanel = skinsFactory.createSkinnedJPanel("ErrorDialogPanel");

    int row = 0;
    dialogPanel.setLayout(new GridBagLayout());
    dialogPanel.add(messageLabel, new GridBagConstraints(0, row++, 1, 1, 1, 0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(12, 5, 12, 5), 0, 0));
    dialogPanel.add(detailsLabel, new GridBagConstraints(0, row++, 1, 1, 1, 0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, insetsDefault, 0, 0));
    dialogPanel.add(okButton, new GridBagConstraints(0, row++, 1, 1, 1, 0, GridBagConstraints.CENTER,
            GridBagConstraints.NONE, insetsDefault, 0, 0));

    this.getContentPane().add(dialogPanel);
    this.pack();
    this.setLocationRelativeTo(this.getOwner());
}

From source file:org.bench4Q.console.ui.section.P_WIRTSection.java

/**
 * @param resources/* w w  w . ja v a2  s.com*/
 * @param processControl
 * @param dispatcherFactory
 * @param TotalOrNot
 * @param agentIdentity
 * @param agentsCollection
 * @throws ConsoleException
 */
public P_WIRTSection(Resources resources, ProcessControl processControl,
        SwingDispatcherFactory dispatcherFactory, Boolean TotalOrNot, AgentIdentity agentIdentity,
        AgentsCollection agentsCollection) throws ConsoleException {

    m_resources = resources;
    m_processControl = processControl;
    m_swingDispatcherFactory = dispatcherFactory;

    this.TotalOrNot = TotalOrNot;
    m_agentIdentity = agentIdentity;

    m_agentsCollection = agentsCollection;
    m_agentsCollection.registerObserver(this);

    testduring = -1;
    resultNumber = 0;

    wirt = new ResultSet[15];
    thiswirt = new ArrayList();

    this.setLayout(new GridBagLayout());

    this.setPreferredSize(new Dimension(550, 445));
    this.setMinimumSize(new Dimension(550, 445));

    picPanel = new PicPanel();
    this.add(picPanel, new GridBagConstraints(0, 0, 1, 4, 99.0, 99.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 1, 1));

}