Example usage for java.awt GridBagLayout GridBagLayout

List of usage examples for java.awt GridBagLayout GridBagLayout

Introduction

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

Prototype

public GridBagLayout() 

Source Link

Document

Creates a grid bag layout manager.

Usage

From source file:com.att.aro.ui.view.menu.file.BPVideoWarnFailPanel.java

public BPVideoWarnFailPanel() {
    JPanel mainPanel = new JPanel();
    this.add(mainPanel);
    mainPanel.setLayout(new GridBagLayout());
    GridBagConstraints constraint = new GridBagConstraints();
    mainPanel.add(getGridPanel(), constraint);
    mainPanel.add(getDefaultButton("Default", (ActionEvent arg) -> setDefault()), constraint);
    compileResultsField.setEditable(false);
    if (sError.isEmpty()) {
        compileResultsField.setBackground(mainPanel.getBackground());
        compileResultsField.setForeground(Color.red);
        compileResultsField.setFont(compileResultsField.getFont().deriveFont(Font.BOLD));
        compileResultsField.setText("");
        compileResultsField.setVisible(false);
    } else {//from w ww  .  j a v  a 2s. c  o  m
        compileResultsField.setVisible(true);
        compileResultsField.setForeground(Color.red);
        compileResultsField.setText(String.format("ERRORS: %s", sError));
    }
    constraint.anchor = GridBagConstraints.FIRST_LINE_START;
    constraint.gridy = 300;
    constraint.gridwidth = 2;
    mainPanel.add(compileResultsField, constraint);
}

From source file:de.fhg.igd.iva.explorer.main.CompareViewPanel.java

public CompareViewPanel(Table<KnownColormap, ColormapQuality, Double> info) {
    this.table = info;

    setBorder(new EmptyBorder(5, 5, 5, 5));
    setLayout(new BorderLayout());

    JPanel statsPanel = new JPanel(new BorderLayout());

    //      statsLabel = new JLabel();
    //      statsLabel.setBorder(BorderFactory.createTitledBorder("Statistics"));
    //      statsPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    statsBars = new JPanel(new GridBagLayout());
    statsPanel.add(statsBars, BorderLayout.NORTH);
    //      statsPanel.add(statsLabel, BorderLayout.SOUTH);
    add(statsPanel, BorderLayout.SOUTH);

    cmView = new ColormapPanel(new ConstantColormap(), 256);
    cmView.setBorder(new EmptyBorder(5, 0, 5, 0));
    add(cmView, BorderLayout.CENTER);

    mapsCombo = new JComboBox<KnownColormap>(table.rowKeySet().toArray(new KnownColormap[0]));
    mapsCombo.addActionListener(new ActionListener() {
        @Override/*from  w ww . j  a v a  2 s .  co m*/
        public void actionPerformed(ActionEvent e) {
            updateSelection();
        }

    });
    mapsCombo.setSelectedIndex(0);

    add(mapsCombo, BorderLayout.NORTH);
}

From source file:MessageViewer.java

public MessageViewer(Message what) {
    // set our layout
    super(new GridBagLayout());

    // add the toolbar
    addToolbar();//from w ww . j  av  a2s.co m

    GridBagConstraints gb = new GridBagConstraints();
    gb.gridwidth = GridBagConstraints.REMAINDER;
    gb.fill = GridBagConstraints.BOTH;
    gb.weightx = 1.0;
    gb.weighty = 0.0;

    // add the headers
    headers = new TextArea("", 4, 80, TextArea.SCROLLBARS_NONE);
    headers.setEditable(false);
    add(headers, gb);

    // now display our message
    setMessage(what);
}

From source file:com.jostrobin.battleships.view.frames.GameFrame.java

@Override
public void afterPropertiesSet() throws Exception {

    setLayout(new GridBagLayout());

    createPlacementView();//from w w w  .  jav a 2 s .c  o  m

    setPreferredSize(new Dimension(400, 450));
    gamePanel.addAttackListener(this);
    //this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

From source file:com.sec.ose.osi.ui.frm.main.report.JPanReportMain.java

/**
 * This method initializes this//from w  w  w .j  ava2 s  . c  o  m
 * 
 * @return void
 */
private void initialize() {
    this.setSize(482, 200);
    this.setLayout(new GridBagLayout());

    GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
    gridBagConstraints11.fill = GridBagConstraints.BOTH;
    gridBagConstraints11.weighty = 1.0;
    gridBagConstraints11.weightx = 1.0;
    gridBagConstraints11.gridx = 0;
    gridBagConstraints11.gridy = 0;
    GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
    gridBagConstraints1.gridx = 10;
    gridBagConstraints1.insets = new Insets(10, 0, 0, 0);
    gridBagConstraints1.anchor = GridBagConstraints.NORTH;
    gridBagConstraints1.gridy = 0;

    this.add(getJSplitPane(), gridBagConstraints11);
    this.add(getJPanelbutton(), gridBagConstraints1);

}

From source file:TwoStopsGradient.java

/** Creates a new instance of TwoStopsGradient */
public TwoStopsGradient() {
    super("Two Stops Gradient");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JPanel panel = new JPanel(new GridBagLayout());
    JButton button;/*w  w  w .ja v a 2s .  c o m*/
    panel.add(button = new DepthButton("New"), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
            GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(3, 3, 3, 3), 0, 0));
    button.setFocusPainted(false);
    panel.add(button = new DepthButton("Open"), new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,
            GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(3, 3, 3, 3), 0, 0));
    button.setFocusPainted(false);
    panel.add(button = new DepthButton("Save"), new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0,
            GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(3, 3, 3, 3), 0, 0));
    button.setFocusPainted(false);

    add(panel);
    setSize(320, 240);
}

From source file:com.igormaznitsa.sciareto.ui.tabs.TabTitle.java

public TabTitle(@Nonnull final Context context, @Nonnull final TabProvider parent,
        @Nullable final File associatedFile) {
    super(new GridBagLayout());
    this.parent = parent;
    this.context = context;
    this.associatedFile = associatedFile;
    this.changed = this.associatedFile == null;
    this.setOpaque(false);
    final GridBagConstraints constraints = new GridBagConstraints();
    constraints.fill = GridBagConstraints.BOTH;
    constraints.weightx = 1000.0d;/* w  w  w .j  a  v  a 2  s  .  c om*/

    final TabTitle theInstance = this;

    this.titleLabel = new JLabel() {
        private static final long serialVersionUID = 8689945842487138781L;

        @Override
        protected void processKeyEvent(@Nonnull final KeyEvent e) {
            theInstance.getParent().dispatchEvent(e);
        }

        @Override
        public String getToolTipText() {
            return theInstance.getToolTipText();
        }

        @Override
        public boolean isFocusable() {
            return false;
        }
    };
    this.add(this.titleLabel, constraints);

    final Icon uiCloseIcon = UIManager.getIcon("InternalFrameTitlePane.closeIcon");

    this.closeButton = new JButton(uiCloseIcon == null ? NIMBUS_CLOSE_ICON : uiCloseIcon) {
        private static final long serialVersionUID = -8005282815756047979L;

        @Override
        public String getToolTipText() {
            return theInstance.getToolTipText();
        }

        @Override
        public boolean isFocusable() {
            return false;
        }
    };
    this.closeButton.setToolTipText("Close tab");
    this.closeButton.setBorder(null);
    this.closeButton.setContentAreaFilled(false);
    this.closeButton.setMargin(new Insets(0, 0, 0, 0));
    this.closeButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    this.closeButton.setOpaque(false);
    this.closeButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(@Nonnull final ActionEvent e) {
            doSafeClose();
        }
    });
    constraints.fill = GridBagConstraints.BOTH;
    constraints.weightx = 0.0d;
    constraints.insets = new Insets(2, 8, 2, 0);

    this.add(this.closeButton, constraints);

    updateView();

    ToolTipManager.sharedInstance().registerComponent(closeButton);
    ToolTipManager.sharedInstance().registerComponent(this.titleLabel);
    ToolTipManager.sharedInstance().registerComponent(this);
}

From source file:TextDemo.java

public TextDemo() {
    super(new GridBagLayout());

    textField = new JTextField(20);
    textField.addActionListener(this);

    textArea = new JTextArea(5, 20);
    textArea.setEditable(false);/* w  ww. j  a v a  2  s.c  o m*/
    JScrollPane scrollPane = new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

    //Add Components to this panel.
    GridBagConstraints c = new GridBagConstraints();
    c.gridwidth = GridBagConstraints.REMAINDER;

    c.fill = GridBagConstraints.HORIZONTAL;
    add(textField, c);

    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1.0;
    c.weighty = 1.0;
    add(scrollPane, c);
}

From source file:de.codesourcery.eve.skills.ui.utils.CalendarWidget.java

public CalendarWidget(Date startDate, ICalendarRenderer renderer) {
    super.setLayout(new GridBagLayout());

    if (renderer == null) {
        throw new IllegalArgumentException("renderer cannot be NULL");
    }/*w  w  w. j  a va 2 s . c  o  m*/

    setStartDate(startDate, false);

    this.startDate = calcAlignedStartDate(de.codesourcery.eve.skills.util.Misc.stripToDay(startDate));
    this.renderer = renderer;
    setup();
}

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);/*from www  . j a  v a 2s  .com*/
    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));
}