List of usage examples for java.awt GridBagConstraints BOTH
int BOTH
To view the source code for java.awt GridBagConstraints BOTH.
Click Source Link
From source file:org.openconcerto.sql.view.listview.ListSQLView.java
protected void uiInit() { this.setLayout(new GridBagLayout()); final GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(1, 2, 1, 2); c.anchor = GridBagConstraints.NORTHWEST; c.gridx = 0;//from w w w . ja va2s . c o m c.gridy = 0; c.weightx = 1; c.weighty = 1; c.fill = GridBagConstraints.BOTH; this.add(this.itemsPanel, c); c.weighty = 0; c.gridy++; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.NORTHEAST; this.add(this.addBtn, c); this.addBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { addNewItem(); } }); this.itemsConstraints.gridx = 0; this.itemsConstraints.gridy = 0; this.itemsConstraints.weightx = 1; this.itemsConstraints.fill = GridBagConstraints.BOTH; }
From source file:fr.free.hd.servers.gui.FaceView.java
@Override protected JComponent createControl() { final GridBagLayout layout = new GridBagLayout(); final JPanel view = new JPanel(layout); //Face list//from ww w . j av a 2s . c om GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.gridheight = 3; c.weighty = 0.75; c.weightx = 0.15; c.fill = GridBagConstraints.BOTH; final JList facesList = CreateList(); facesList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting() == false) { if (facesList.getSelectedIndex() != -1) { face = (Face) facesList.getSelectedValue(); updateLabel(); } else { } } } }); view.add(facesList, c); // New button c = new GridBagConstraints(); c.gridx = 0; c.gridy = 3; c.fill = GridBagConstraints.BOTH; JButton btnNew = new JButton("Nouveau"); btnNew.setEnabled(false); view.add(btnNew, c); // Save button c = new GridBagConstraints(); c.gridx = 0; c.gridy = 4; c.fill = GridBagConstraints.BOTH; JButton btnModified = new JButton("Modifier"); btnModified.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { facesDAO.storeFace(face); } }); view.add(btnModified, c); //Draw Face c = new GridBagConstraints(); c.gridx = 1; c.gridy = 0; c.gridheight = 5; c.gridwidth = 1; c.fill = GridBagConstraints.BOTH; c.weightx = 0.60; lblFace = new JLabel(); view.add(lblFace, c); //Hand Panel c = new GridBagConstraints(); c.gridx = 2; c.gridy = 0; c.weightx = 0.15; c.fill = GridBagConstraints.BOTH; JPanel pnlHand = createPosition(); view.add(pnlHand, c); //Mouth Panel c = new GridBagConstraints(); c.gridx = 2; c.gridy = 1; c.weightx = 0.15; c.fill = GridBagConstraints.BOTH; JPanel pnlKind = createKind(); view.add(pnlKind, c); //Mouth Panel c = new GridBagConstraints(); c.gridx = 2; c.gridy = 2; c.weightx = 0.15; c.fill = GridBagConstraints.BOTH; JPanel pnlMouth = createMouth(); view.add(pnlMouth, c); // Picture filename c = new GridBagConstraints(); c.gridx = 0; c.gridy = 5; c.gridwidth = 2; c.fill = GridBagConstraints.BOTH; JTextField txtPath = new JTextField(); view.add(txtPath, c); //Browse Button c = new GridBagConstraints(); c.gridx = 2; c.gridy = 5; c.fill = GridBagConstraints.BOTH; JButton btnBrownse = new JButton("Browse"); view.add(btnBrownse, c); //Select default face if (facesList.getModel().getSize() > 0) { facesList.setSelectedIndex(0); position = HandPositionEnum.HAND_POSITION_MENTON; kind = HandKeyEnum.HAND_KEY_2V; } return view; }
From source file:FocusEventDemo.java
public void addComponentsToPane(final Container pane) { GridBagLayout gridbag = new GridBagLayout(); pane.setLayout(gridbag);/*from ww w . j a va 2s .c o m*/ GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; // Make column as wide as possible. JTextField textField = new JTextField("A TextField"); textField.setMargin(new Insets(0, 2, 0, 2)); textField.addFocusListener(this); gridbag.setConstraints(textField, c); add(textField); c.weightx = 0.1; // Widen every other column a bit, when possible. c.fill = GridBagConstraints.NONE; JLabel label = new JLabel("A Label"); label.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); label.addFocusListener(this); gridbag.setConstraints(label, c); add(label); String comboPrefix = "ComboBox Item #"; final int numItems = 15; Vector<String> vector = new Vector<String>(numItems); for (int i = 0; i < numItems; i++) { vector.addElement(comboPrefix + i); } JComboBox comboBox = new JComboBox(vector); comboBox.addFocusListener(this); gridbag.setConstraints(comboBox, c); add(comboBox); c.gridwidth = GridBagConstraints.REMAINDER; JButton button = new JButton("A Button"); button.addFocusListener(this); gridbag.setConstraints(button, c); add(button); c.weightx = 0.0; c.weighty = 0.1; c.fill = GridBagConstraints.BOTH; String listPrefix = "List Item #"; Vector<String> listVector = new Vector<String>(numItems); for (int i = 0; i < numItems; i++) { listVector.addElement(listPrefix + i); } JList list = new JList(listVector); list.setSelectedIndex(1); // It's easier to see the focus change // if an item is selected. list.addFocusListener(this); JScrollPane listScrollPane = new JScrollPane(list); gridbag.setConstraints(listScrollPane, c); add(listScrollPane); c.weighty = 1.0; // Make this row as tall as possible. c.gridheight = GridBagConstraints.REMAINDER; // Set up the area that reports focus-gained and focus-lost events. display = new JTextArea(); display.setEditable(false); // The setRequestFocusEnabled method prevents a // component from being clickable, but it can still // get the focus through the keyboard - this ensures // user accessibility. display.setRequestFocusEnabled(false); display.addFocusListener(this); JScrollPane displayScrollPane = new JScrollPane(display); gridbag.setConstraints(displayScrollPane, c); add(displayScrollPane); setPreferredSize(new Dimension(450, 450)); ((JPanel) pane).setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }
From source file:be.ac.ua.comp.scarletnebula.gui.ServerCellRenderer.java
@Override public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) { // Dirty hack: the last item in the serverlist is always a fake server // that when double clicked produces an "add new server" wizard. if (value == null) { return getNewServerServer(list, index, isSelected); }/*from w w w.ja v a2 s . c o m*/ final Server server = (Server) value; final JPanel p = createServerPanel(server, list, index, isSelected); final Color foreground = getForegroundColor(list, index, isSelected); final JLabel label = getServernameComponent(server, foreground); final JLabel tags = getTagComponent(server, foreground); // final ChartPanel chartPanel = getChartPanelComponent(); final GraphPanelCache gcp = GraphPanelCache.get(); final Component chartOrNothing; if (server.getServerStatistics() == null) { chartOrNothing = new JLabel(); } else { chartOrNothing = gcp.inBareServerCache(server) ? gcp.getBareChartPanel(server) : createAndStoreBareChartPanel(list, server); } p.setLayout(new GridBagLayout()); final GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; c.gridx = 0; c.gridy = 0; c.insets = new Insets(5, 5, 1, 5); c.anchor = GridBagConstraints.FIRST_LINE_START; p.add(label, c); c.insets = new Insets(0, 5, 5, 5); c.gridy = 1; p.add(tags, c); c.fill = GridBagConstraints.BOTH; c.weighty = 1.0; c.gridy = 2; p.add(chartOrNothing, c); return p; }
From source file:com.geometrycloud.happydonut.ui.ChartFilterPanel.java
/** * Inicializa los componentes./*from ww w . j a va 2 s . co m*/ */ 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.pentaho.reporting.engine.classic.demo.ancient.demo.layouts.DemoReportController.java
public DemoReportController() { setLayout(new GridBagLayout()); final JLabel messageOneLabel = new JLabel("One:"); final JLabel messageTwoLabel = new JLabel("Two:"); messageOneField = new JTextArea(); messageOneField.setWrapStyleWord(true); messageOneField.setRows(10);/*from w ww.j a v a 2s. com*/ messageTwoField = new JTextArea(); messageTwoField.setRows(10); messageTwoField.setWrapStyleWord(true); updateAction = new UpdateAction(); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; add(messageOneLabel, gbc); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 1; add(messageTwoLabel, gbc); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 0; gbc.weightx = 1; gbc.weighty = 1; gbc.fill = GridBagConstraints.BOTH; add(new JScrollPane(messageOneField), gbc); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 1; gbc.weightx = 1; gbc.weighty = 1; gbc.fill = GridBagConstraints.BOTH; add(new JScrollPane(messageTwoField), gbc); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 2; gbc.anchor = GridBagConstraints.EAST; add(new JButton(updateAction)); setEnabled(false); messageOneField.setEnabled(false); messageTwoField.setEnabled(false); updateAction.setEnabled(false); }
From source file:FocusEventDemo.java
public FocusEventDemo() { super(new GridBagLayout()); GridBagLayout gridbag = (GridBagLayout) getLayout(); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; //Make column as wide as possible. JTextField textField = new JTextField("A TextField"); textField.setMargin(new Insets(0, 2, 0, 2)); textField.addFocusListener(this); gridbag.setConstraints(textField, c); add(textField);//from www . j ava2 s. c om c.weightx = 0.1; //Widen every other column a bit, when possible. c.fill = GridBagConstraints.NONE; JLabel label = new JLabel("A Label"); label.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); label.addFocusListener(this); gridbag.setConstraints(label, c); add(label); String comboPrefix = "ComboBox Item #"; final int numItems = 15; Vector vector = new Vector(numItems); for (int i = 0; i < numItems; i++) { vector.addElement(comboPrefix + i); } JComboBox comboBox = new JComboBox(vector); comboBox.addFocusListener(this); gridbag.setConstraints(comboBox, c); add(comboBox); c.gridwidth = GridBagConstraints.REMAINDER; JButton button = new JButton("A Button"); button.addFocusListener(this); gridbag.setConstraints(button, c); add(button); c.weightx = 0.0; c.weighty = 0.1; c.fill = GridBagConstraints.BOTH; String listPrefix = "List Item #"; Vector listVector = new Vector(numItems); for (int i = 0; i < numItems; i++) { listVector.addElement(listPrefix + i); } JList list = new JList(listVector); list.setSelectedIndex(1); //It's easier to see the focus change //if an item is selected. list.addFocusListener(this); JScrollPane listScrollPane = new JScrollPane(list); //We want to prevent the list's scroll bars //from getting the focus - even with the keyboard. //Note that in general we prefer setRequestFocusable //over setFocusable for reasons of accessibility, //but this is to work around bug #4866958. listScrollPane.getVerticalScrollBar().setFocusable(false); listScrollPane.getHorizontalScrollBar().setFocusable(false); gridbag.setConstraints(listScrollPane, c); add(listScrollPane); c.weighty = 1.0; //Make this row as tall as possible. c.gridheight = GridBagConstraints.REMAINDER; //Set up the area that reports focus-gained and focus-lost events. display = new JTextArea(); display.setEditable(false); //The method setRequestFocusEnabled prevents a //component from being clickable, but it can still //get the focus through the keyboard - this ensures //user accessibility. display.setRequestFocusEnabled(false); display.addFocusListener(this); JScrollPane displayScrollPane = new JScrollPane(display); //Work around for bug #4866958. displayScrollPane.getHorizontalScrollBar().setFocusable(false); displayScrollPane.getVerticalScrollBar().setFocusable(false); gridbag.setConstraints(displayScrollPane, c); add(displayScrollPane); setPreferredSize(new Dimension(450, 450)); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }
From source file:com.jostrobin.battleships.view.frames.GameFrame.java
public void addChatPanel(int gridX, int gridY) { GridBagConstraints chatPanelConstraints = new GridBagConstraints(); chatPanelConstraints.gridy = gridY;//w ww . j a va2 s . com chatPanelConstraints.gridx = gridX; chatPanelConstraints.anchor = GridBagConstraints.ABOVE_BASELINE_LEADING; chatPanelConstraints.fill = GridBagConstraints.BOTH; chatPanelConstraints.weightx = 1.0; chatPanelConstraints.weighty = 0.2; add(chatPanel, chatPanelConstraints); }
From source file:org.executequery.gui.editor.ManageShortcutsPanel.java
private void init() { createTextPane();//from w ww .j a v a 2s .c om createList(); JSplitPane splitPane = createSplitPane(); splitPane.setLeftComponent(new JScrollPane(list)); splitPane.setRightComponent(new JScrollPane(textPane)); JPanel panel = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.NORTHWEST; gbc.gridy = 0; gbc.gridx = 1; gbc.insets.top = 5; gbc.insets.left = 5; gbc.insets.right = 5; panel.add(labelForKey("shortcuts"), gbc); gbc.gridy++; gbc.insets.bottom = 5; gbc.weighty = 1.0; gbc.weightx = 1.0; gbc.fill = GridBagConstraints.BOTH; panel.add(splitPane, gbc); gbc.gridx = 0; gbc.weightx = 0; gbc.weighty = 0; gbc.insets.left = 5; gbc.insets.right = 0; gbc.fill = GridBagConstraints.NONE; panel.add(createMoveButtonsPanel(), gbc); addActionButton(createSaveButton()); addActionButton(createCancelButton()); addContentPanel(panel); setPreferredSize(new Dimension(600, 350)); }
From source file:Applet.EmbeddedChart.java
public synchronized void updateInfo(String[] legends, List<double[][]> yVals, boolean gofr) { removeAll();/* w ww . j ava 2 s . com*/ GridBagLayout gbl = new GridBagLayout(); gbl.columnWidths = new int[] { 10, 0, 0 }; gbl.rowHeights = new int[] { 0, 0, 0 }; gbl.columnWeights = new double[] { 0.0, 1.0, 1.0 }; gbl.rowWeights = new double[] { 1.0, 1.0, 0.0 }; setLayout(gbl); this.legends = legends; this.yvals = yVals; this.gofr = gofr; XYDataset dataset = createDataset(gofr, legends, yVals); JFreeChart chart = createChart(dataset, title, gofr); chartPanel = new ChartPanel(chart); chartPanel.setMinimumDrawWidth(0); chartPanel.setMinimumDrawHeight(0); chartPanel.setMaximumDrawWidth(2000); chartPanel.setMaximumDrawHeight(2000); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); chartPanel.getChart().setBackgroundPaint(null); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 0; gbc.gridwidth = 2; gbc.gridheight = 2; gbc.fill = GridBagConstraints.BOTH; add(chartPanel, gbc); GridBagConstraints gbcX1 = new GridBagConstraints(); GridBagConstraints gbcX2 = new GridBagConstraints(); GridBagConstraints gbcY1 = new GridBagConstraints(); GridBagConstraints gbcY2 = new GridBagConstraints(); GridBagConstraints gbcButton = new GridBagConstraints(); final NumberAxis domain = (NumberAxis) ((XYPlot) chartPanel.getChart().getPlot()).getDomainAxis(); final NumberAxis range = (NumberAxis) ((XYPlot) chartPanel.getChart().getPlot()).getRangeAxis(); if (gofr) { domain.setLowerBound(over.gr_xMin); domain.setUpperBound(over.gr_xMax); range.setLowerBound(over.gr_yMin); range.setUpperBound(over.gr_yMax); } else { domain.setLowerBound(over.pot_xMin); domain.setUpperBound(over.pot_xMax); range.setLowerBound(over.pot_yMin); range.setUpperBound(over.pot_yMax); } gbcX2.gridx = 2; gbcX2.gridy = 2; gbcX2.anchor = GridBagConstraints.EAST; gbcX2.insets = new Insets(0, 0, 0, 12); final JTextField xMax = new JTextField(5); xMax.setMinimumSize(new Dimension(50, 20)); xMax.setText("" + domain.getUpperBound()); // gbcX2.fill = GridBagConstraints.VERTICAL; add(xMax, gbcX2); final boolean gr = gofr; xMax.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { if (gr) { over.gr_xMax = Double.parseDouble(xMax.getText()); domain.setRange(over.gr_xMin, over.gr_xMax); } else { over.pot_xMax = Double.parseDouble(xMax.getText()); domain.setRange(over.pot_xMin, over.pot_xMax); } } @Override public void focusGained(FocusEvent e) { } }); gbcX1.gridx = 1; gbcX1.gridy = 2; gbcX1.anchor = GridBagConstraints.WEST; gbcX1.insets = new Insets(0, 70, 0, 0); final JTextField xMin = new JTextField(5); xMin.setMinimumSize(new Dimension(50, 20)); xMin.setText("" + domain.getLowerBound()); // gbcX1.fill = GridBagConstraints.VERTICAL; add(xMin, gbcX1); xMin.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { x1 = Double.parseDouble(xMin.getText()); domain.setRange(x1, x2); if (gr) { over.gr_xMin = Double.parseDouble(xMin.getText()); domain.setRange(over.gr_xMin, over.gr_xMax); } else { over.pot_xMin = Double.parseDouble(xMin.getText()); domain.setRange(over.pot_xMin, over.pot_xMax); } } @Override public void focusGained(FocusEvent e) { } }); gbcY1.gridx = 0; gbcY1.gridy = 1; gbcY1.anchor = GridBagConstraints.SOUTH; gbcY1.insets = new Insets(0, 0, 45, 0); final JTextField yMin = new JTextField(5); yMin.setMinimumSize(new Dimension(50, 20)); yMin.setText("" + range.getLowerBound()); // gbcY1.fill = GridBagConstraints.BOTH; add(yMin, gbcY1); yMin.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { if (gr) { over.gr_yMin = Double.parseDouble(yMin.getText()); range.setRange(over.gr_yMin, over.gr_yMax); } else { over.pot_yMin = Double.parseDouble(yMin.getText()); range.setRange(over.pot_yMin, over.pot_yMax); } } @Override public void focusGained(FocusEvent e) { } }); gbcY2.gridx = 0; gbcY2.gridy = 0; gbcY2.anchor = GridBagConstraints.NORTH; gbcY2.insets = new Insets(10, 0, 0, 0); final JTextField yMax = new JTextField(5); yMax.setMinimumSize(new Dimension(50, 20)); yMax.setText("" + range.getUpperBound()); // gbcY2.fill = GridBagConstraints.BOTH; add(yMax, gbcY2); yMax.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { if (gr) { over.gr_yMax = Double.parseDouble(yMax.getText()); range.setRange(over.gr_yMin, over.gr_yMax); } else { over.pot_yMax = Double.parseDouble(yMax.getText()); range.setRange(over.pot_yMin, over.pot_yMax); } } @Override public void focusGained(FocusEvent e) { } }); }