List of usage examples for java.awt GridBagConstraints GridBagConstraints
public GridBagConstraints(int gridx, int gridy, int gridwidth, int gridheight, double weightx, double weighty, int anchor, int fill, Insets insets, int ipadx, int ipady)
From source file:com.ohalo.cn.awt.JFreeChartTest.java
public static void main(String[] args) throws Exception { JFreeChartTest test = new JFreeChartTest(); List<JFreeChart> charts = test.printHardDiskCharts(); JPanel mainPanel = new JPanel(); JFreeChart chart = charts.get(0);/*from www .j a v a 2 s .c om*/ JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new Dimension(400, 300)); panel.add(chartPanel, BorderLayout.CENTER); mainPanel.add(panel, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(20, 20, 10, 10), 0, 0)); chart = charts.get(1); panel = new JPanel(); ChartPanel chartPanel2 = new ChartPanel(chart); chartPanel2.setPreferredSize(new Dimension(400, 300)); panel.setLayout(new BorderLayout()); panel.add(chartPanel2, BorderLayout.CENTER); mainPanel.add(panel, new GridBagConstraints(1, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10, 10, 10, 10), 0, 0)); chart = charts.get(2); panel = new JPanel(); ChartPanel chartPanel3 = new ChartPanel(chart); chartPanel3.setPreferredSize(new Dimension(400, 300)); panel.setLayout(new BorderLayout()); panel.add(chartPanel3, BorderLayout.CENTER); mainPanel.add(panel, new GridBagConstraints(1, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10, 10, 10, 10), 0, 0)); chart = charts.get(3); panel = new JPanel(); ChartPanel chartPanel4 = new ChartPanel(chart); chartPanel4.setPreferredSize(new Dimension(400, 300)); panel.setLayout(new BorderLayout()); panel.add(chartPanel4, BorderLayout.CENTER); mainPanel.add(panel, new GridBagConstraints(1, 1, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10, 10, 20, 20), 0, 0)); JDialog dialog = new JDialog(new JFrame(), true); dialog.setTitle("?"); dialog.setSize(850, 650); dialog.getContentPane().add(mainPanel); dialog.setVisible(true); }
From source file:Main.java
private static void addComponent(Container container, Component component, int gridx, int gridy, int gridwidth, int gridheight, int anchor, int fill) { Insets insets = new Insets(0, 0, 0, 0); GridBagConstraints gbc = new GridBagConstraints(gridx, gridy, gridwidth, gridheight, 1.0, 1.0, anchor, fill, insets, 0, 0);/* w w w . j a v a 2 s. co m*/ container.add(component, gbc); }
From source file:Main.java
Main() { setDefaultCloseOperation(EXIT_ON_CLOSE); setSize(500, 500);// ww w . j ava 2 s . c o m JPanel panel1 = new JPanel(new GridBagLayout()); JButton b1 = new JButton("button 1"), b2 = new JButton("button 2"); panel1.add(b1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); panel1.add(b2, new GridBagConstraints(1, 0, 1, 1, 2.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); add(panel1); setVisible(true); }
From source file:GridBagButtons.java
private static void addComponent(Container container, Component component, int gridx, int gridy, int gridwidth, int gridheight, int anchor, int fill) { GridBagConstraints gbc = new GridBagConstraints(gridx, gridy, gridwidth, gridheight, 1.0, 1.0, anchor, fill, insets, 0, 0);/*from w w w .j a va 2s .c o m*/ container.add(component, gbc); }
From source file:Main.java
/** * Puts the grid constraints for a component. * /* w w w.j av a 2 s . c o m*/ * @param container * The container to add the component to. * @param component * The component to create the constraints for. * @param gridX * The initial gridx value. * @param gridY * The initial gridy value. * @param gridWidth * The initial gridwidth value. * @param gridHeight * The initial gridheight value. * @param weightX * The initial weightx value. * @param weightY * The initial weighty value. * @param anchor * The initial anchor value. * @param fill * The initial fill value. * @param insets * The insets to be used. */ public static final void insetPutGrid(final Container container, final Component component, final int gridX, final int gridY, final int gridWidth, final int gridHeight, final double weightX, final double weightY, final int anchor, final int fill, final Insets insets) { LayoutManager l; l = container.getLayout(); if (l instanceof GridBagLayout) { ((GridBagLayout) (l)).setConstraints(component, new GridBagConstraints(gridX, gridY, gridWidth, gridHeight, weightX, weightY, anchor, fill, insets, DEFAULT_IPAD_X, DEFAULT_IPAD_Y)); } container.add(component); }
From source file:Main.java
/** * Puts the grid constraints for a component. * //from w w w .j a v a2 s.co m * @param container * The container to add the component to. * @param component * The component to create the constraints for. * @param gridX * The initial gridx value. * @param gridY * The initial gridy value. * @param gridWidth * The initial gridwidth value. * @param gridHeight * The initial gridheight value. * @param weightX * The initial weightx value. * @param weightY * The initial weighty value. * @param anchor * The initial anchor value. * @param fill * The initial fill value. */ public static final void noInsetsPutGrid(final Container container, final Component component, final int gridX, final int gridY, final int gridWidth, final int gridHeight, final double weightX, final double weightY, final int anchor, final int fill) { LayoutManager l; l = container.getLayout(); if (l instanceof GridBagLayout) { ((GridBagLayout) (l)).setConstraints(component, new GridBagConstraints(gridX, gridY, gridWidth, gridHeight, weightX, weightY, anchor, fill, NOINSETS, DEFAULT_IPAD_X, DEFAULT_IPAD_Y)); } container.add(component); }
From source file:rhinova.gui.dataentry.link.LinkDataEditPannel.java
private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents // Generated using JFormDesigner non-commercial license label1 = new JLabel(); label2 = new JLabel(); lblId = new JLabel(); label3 = new JLabel(); txtName = new JTextField(); label8 = new JLabel(); txtCapacity = new JTextField(); label4 = new JLabel(); txtSurvivalRate = new JTextField(); label5 = new JLabel(); comboReserve1 = new JComboBox<>(); label6 = new JLabel(); comboReserve2 = new JComboBox<>(); //======== this ======== setLayout(new GridBagLayout()); ((GridBagLayout) getLayout()).columnWidths = new int[] { 54, 0, 0 }; ((GridBagLayout) getLayout()).rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; ((GridBagLayout) getLayout()).columnWeights = new double[] { 0.0, 0.0, 1.0E-4 }; ((GridBagLayout) getLayout()).rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4 }; //---- label1 ---- label1.setText("Link Properties"); label1.setFont(new Font("Tahoma", Font.PLAIN, 16)); add(label1, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 15, 0), 0, 0)); //---- label2 ---- label2.setText("id"); add(label2, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, new Insets(0, 0, 15, 15), 0, 0)); add(lblId, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 15, 0), 0, 0)); //---- label3 ---- label3.setText("name"); add(label3, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, new Insets(0, 0, 15, 15), 0, 0)); add(txtName, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 15, 0), 0, 0)); //---- label8 ---- label8.setText("capacity"); add(label8, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, new Insets(0, 0, 15, 15), 0, 0)); add(txtCapacity, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 15, 0), 0, 0)); //---- label4 ---- label4.setText("survival rate"); add(label4, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, new Insets(0, 0, 15, 15), 0, 0)); add(txtSurvivalRate, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 15, 0), 0, 0)); //---- label5 ---- label5.setText("reserve 1"); add(label5, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, new Insets(0, 0, 15, 15), 0, 0)); add(comboReserve1, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 15, 0), 0, 0)); //---- label6 ---- label6.setText("reserve 2"); add(label6, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, new Insets(0, 0, 0, 15), 0, 0)); add(comboReserve2, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); // JFormDesigner - End of component initialization //GEN-END:initComponents }
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;/*from w w w . ja v a 2 s . co 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:geneon.intellij.plugin.jenkins.ui.EditServerDialog.java
@Nullable @Override//from w ww . j a v a2 s. com protected JComponent createCenterPanel() { nameTextField.setMinimumSize(new Dimension(300, 10)); urlTextField.setMinimumSize(new Dimension(300, 10)); JButton testButton = new JButton("Test"); testButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { testSettings(); } }); JPanel panel = new JPanel(new GridBagLayout()); JLabel nameLabel = new JLabel("Server name:"); panel.add(nameLabel, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 10), 0, 0)); panel.add(nameTextField, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0)); JLabel urlLabel = new JLabel("URL:"); panel.add(urlLabel, new GridBagConstraints(0, 1, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 10), 0, 0)); panel.add(urlTextField, new GridBagConstraints(1, 1, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0)); panel.add(testButton, new GridBagConstraints(0, 2, 2, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 0), 0, 0)); return panel; }
From source file:ecosim.gui.SummaryPane.java
public SummaryPane(Summary summary) { this.summary = summary; setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15)); setLayout(new GridBagLayout()); // Setup the constraints for the GridBagLayout. GridBagConstraints northWest = new GridBagConstraints(0, 0, // gridx, gridy 1, 1, // gridwidth, gridheight 0.9D, 0.9D, // weightx, weighty GridBagConstraints.CENTER, // anchor GridBagConstraints.BOTH, // fill new Insets(0, 0, 0, 0), // insets 0, 0 // ipadx, ipady );// w w w . j av a 2 s . c om GridBagConstraints northEast = new GridBagConstraints(1, 0, // gridx, gridy 1, 1, // gridwidth, gridheight 0.1D, 0.5D, // weightx, weighty GridBagConstraints.NORTH, // anchor GridBagConstraints.HORIZONTAL, // fill new Insets(0, 0, 0, 0), // insets 0, 0 // ipadx, ipady ); GridBagConstraints south = new GridBagConstraints(0, 1, // gridx, gridy 2, 1, // gridwidth, gridheight 1.0D, 0.1D, // weightx, weighty GridBagConstraints.SOUTH, // anchor GridBagConstraints.HORIZONTAL, // fill new Insets(0, 0, 0, 0), // insets 0, 0 // ipadx, ipady ); // Add everything to the summary pane. add(makeBinningChart(), northWest); add(makeTextPane(), northEast); add(makeTablePane(), south); }