private JPanel makeBrowseButtonBox() { JPanel buttonBox = new JPanel(); buttonBox.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); buttonBox.setLayout(new GridBagLayout()); browseButton = new JButton("Browse Trees"); browseButton.addActionListener(this); JLabel sizeLabel = new JLabel("Tree size:"); JSlider fontSlider = new JSlider(2, 64, 12); fontSlider.addChangeListener(this); GridBagConstraints buttonConstraints = new GridBagConstraints(); buttonConstraints.fill = GridBagConstraints.HORIZONTAL; buttonConstraints.weightx = 0.2; buttonConstraints.weighty = 0.2; buttonBox.add(browseButton,buttonConstraints); buttonConstraints.weightx = 0.6; buttonBox.add(fontSlider, buttonConstraints); buttonConstraints.weightx = 0.2; buttonBox.add(sizeLabel, buttonConstraints); return buttonBox; }
public void actionPerformed (ActionEvent event) { boolean visible = !highMaxSlider.isVisible(); highMaxSlider.setVisible(visible); highRangeButton.setText(visible ? "<" : ">"); GridBagLayout layout = (GridBagLayout)formPanel.getLayout(); GridBagConstraints constraints = layout.getConstraints(highRangeButton); constraints.gridx = visible ? 5 : 4; layout.setConstraints(highRangeButton, constraints); Slider slider = visible ? highMaxSlider : highMinSlider; value.setHighMax((Float)slider.getValue()); } });
public void setEmbedded () { GridBagLayout layout = (GridBagLayout)getLayout(); GridBagConstraints constraints = layout.getConstraints(contentPanel); constraints.insets = new Insets(0, 0, 0, 0); layout.setConstraints(contentPanel, constraints); titlePanel.setVisible(false); }
private void initializeComponents () { getContentPane().setLayout(new GridBagLayout()); JPanel leftSidePanel = new JPanel(); leftSidePanel.setLayout(new GridBagLayout()); getContentPane().add(leftSidePanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); JPanel fontPanel = new JPanel(); leftSidePanel.add(fontPanel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); fontPanel.setLayout(new GridBagLayout()); unicodePanel = new JPanel(new GridBagLayout()); bitmapPanel = new JPanel(new GridBagLayout()); JPanel renderingPanel = new JPanel(new GridBagLayout()); samplePanel.setLayout(new GridBagLayout()); renderingPanel.setLayout(new GridBagLayout()); glyphCachePanel.setLayout(new GridBagLayout()); radioButtonsPanel.setLayout(new GridBagLayout()); rightSidePanel.setLayout(new GridBagLayout()); getContentPane().add(rightSidePanel, new GridBagConstraints(1, 0, 1, 2, 0.0, 0.0, GridBagConstraints.CENTER, paddingPanel.setLayout(new GridBagLayout());
frame.setTitle(appName); JPanel mainPanel = new JPanel(); JLabel splashLabel = null; cardPanel.setLayout(cardLayout); splashLabel = new JLabel("", splash, JLabel.CENTER); frame.setIconImage(offIcon.getImage()); mainPanel.setLayout(new BorderLayout()); cardPanel.setBackground(Color.white); final JButton startButton = new JButton("Start"); startButton.setActionCommand("Start"); quitButton.setActionCommand("Quit"); toolbar.setLayout(new GridBagLayout()); toolbar.add(startButton, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); toolbar.add(stopButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); toolbar.add(browserButton, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); toolbar.add(quitButton, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0,
effectsList.getListSelectionListeners()[0].valueChanged(null); setLayout(new GridBagLayout()); setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, java.awt.Color.black)); appliedEffectsPanel.add(this, constrains); JPanel titlePanel = new JPanel(); titlePanel.setLayout(new LayoutManager() { public void removeLayoutComponent (Component comp) { upButton = new JButton(); titlePanel.add(upButton); upButton.setText("Up"); upButton.setMargin(new Insets(0, 0, 0, 0)); downButton.setMargin(new Insets(0, 0, 0, 0)); deleteButton.setMargin(new Insets(0, 0, 0, 0)); nameLabel = new JLabel(effect.toString()); titlePanel.add(nameLabel); Font font = nameLabel.getFont(); nameLabel.setFont(new Font(font.getName(), Font.BOLD, font.getSize())); add(titlePanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, valuesPanel.setLayout(new GridBagLayout()); add(valuesPanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
public ValueDialog (JComponent component, String name, String description) { setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); setLayout(new GridBagLayout()); setModal(true); ((JSpinner.DefaultEditor)((JSpinner)component).getEditor()).getTextField().setColumns(4); JPanel descriptionPanel = new JPanel(); descriptionPanel.setLayout(new GridBagLayout()); getContentPane().add( descriptionPanel, new GridBagConstraints(0, 0, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); descriptionPanel.setBackground(Color.white); descriptionPanel.add(descriptionText, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); descriptionText.setWrapStyleWord(true); descriptionText.setLineWrap(true); getContentPane().add( panel, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); panel.add(new JLabel(name + ":")); getContentPane().add( JButton cancelButton = new JButton("Cancel");
Panel logoPanel = new Panel(); ImageIcon logoIcon = ImageHelper.loadImageIcon(LocalisationHelper.getString("about_dialog_image")); JLabel la_icon = new JLabel(logoIcon); la_icon.setBorder(new SoftBevelBorder(SoftBevelBorder.LOWERED)); logoPanel.add(la_icon); JPanel versionPanel = new JPanel(); versionPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); versionPanel.setLayout(new GridBagLayout()); JLabel copyright = new JLabel("\u00A9" + " 2011-2018: Joerg Wuethrich and contributors", JLabel.CENTER); GridBagConstraints gridBagConstraints = new GridBagConstraints(); gridBagConstraints.anchor = GridBagConstraints.NORTH; gridBagConstraints.fill = GridBagConstraints.VERTICAL; Insets insetsGapOnTop = new Insets(10, 0, 0, 0); GridBagConstraints gridBagConstraintsGapOnTop = new GridBagConstraints(); gridBagConstraintsGapOnTop.gridy = 1; gridBagConstraintsGapOnTop.insets = insetsGapOnTop; getContentPane().add("North", logoPanel); getContentPane().add("Center", versionPanel); getContentPane().add("South", buttonPanel); pack(); setResizable(false);
panelInput = new JPanel(new GridLayout(1, 2, 10, 0)); JPanel panelFrom = new JPanel(new BorderLayout()); JPanel panelTo = new JPanel(new BorderLayout()); svgFrom = new SVGDrawingPanel(); svgFrom.setPreferredSize(new Dimension(190, 200)); svgTo.setPreferredSize(new Dimension(190, 200)); btnEditFrom = new JButton("Edit Path"); btnEditTo = new JButton("Edit Path"); btnSvgFrom = new JButton("Load SVG"); panelStrokeSize.add(new JLabel("Stroke size: "), BorderLayout.WEST); SpinnerModel spinnerModel = new SpinnerNumberModel(2, //initial value btnMorphAnimation.setMargin(new Insets(0, 0, 0, 0)); panelOutput.setLayout(new GridBagLayout()); GridBagConstraints gc1 = new GridBagConstraints(); gc1.fill = GridBagConstraints.BOTH; gc1.gridx = 0; gc1.weightx = 0.975f; gc1.weighty = 0.5f; GridBagConstraints gcBtn1 = new GridBagConstraints(); gcBtn1.fill = GridBagConstraints.BOTH; gcBtn1.gridx = 1;
protected void initializeComponents () { setLayout(new GridBagLayout()); titlePanel = new JPanel(new GridBagLayout()); add(titlePanel, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(3, 0, 3, 0), 0, 0)); titlePanel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); descriptionLabel = new JLabel(description); titlePanel.add(descriptionLabel, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 6, 3, 6), 0, 0)); removeButton = new JButton("X"); titlePanel.add(removeButton, new GridBagConstraints(4, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 6), 0, 0)); contentPanel = new JPanel(new GridBagLayout()); add(contentPanel, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 6, 6, 6), 0, 0)); advancedPanel = new JPanel(new GridBagLayout()); add(advancedPanel, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 6, 6, 6), 0, 0)); removeButton.addActionListener(new ActionListener() { public void actionPerformed (ActionEvent event) { removePanel();
getContentPane().add(splitPane, BorderLayout.CENTER); JPanel propertiesPanel = new JPanel(new GridBagLayout()); rightSplit.add(propertiesPanel, JSplitPane.TOP); propertiesPanel.setBorder(new CompoundBorder(BorderFactory.createEmptyBorder(3, 0, 6, 6), BorderFactory .createTitledBorder("Editor Properties"))); editorPropertiesPanel = new JPanel(new GridBagLayout()); scroll.setViewportView(editorPropertiesPanel); scroll.getVerticalScrollBar().setUnitIncrement(70); rightSplit.add(rightSplitPane, JSplitPane.BOTTOM); JPanel propertiesPanel = new JPanel(new GridBagLayout()); JPanel influencersPanel = new JPanel(new GridBagLayout()); influencerBox = new JComboBox(new DefaultComboBoxModel()); JButton addInfluencerButton = new JButton("Add"); addInfluencerButton.addActionListener(new ActionListener() { @Override public void actionPerformed (ActionEvent e) { propertiesPanel = new JPanel(new GridBagLayout()); controllerPropertiesPanel = new JPanel(new GridBagLayout()); scroll.setViewportView(controllerPropertiesPanel); scroll.getVerticalScrollBar().setUnitIncrement(70);
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setLayout(new GridBagLayout()); JPanel panel = new JPanel(); panel.add(new JLabel("This is a label")); panel.setBorder(new LineBorder(Color.BLACK)); // make it easy to see frame.add(panel, new GridBagConstraints()); frame.setSize(400, 400); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
private void uiLayout () { topPanel = new JPanel(new GridBagLayout()); topPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); warningNotice = new JLabel("List of third party extensions for LibGDX"); warningNotice2 = new JLabel("These are not maintained by the LibGDX team, please see the support links for info and help"); warningNotice.setHorizontalAlignment(JLabel.CENTER); warningNotice2.setHorizontalAlignment(JLabel.CENTER); topPanel.add(warningNotice, new GridBagConstraints(0, 0, 1, 1, 1, 0, NORTH, HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); topPanel.add(warningNotice2, new GridBagConstraints(0, 1, 1, 1, 1, 0, NORTH, HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); separator.setBackground(new Color(85, 85, 85)); topPanel.add(separator, new GridBagConstraints(0, 2, 1, 1, 1, 1, NORTH, HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); bottomPanel = new JPanel(new GridBagLayout()); buttonPanel = new JPanel(new GridBagLayout()); buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); buttonOK = new SetupButton("Save");
GridBagConstraints gbc; JPanel mainPanel = new JPanel(new GridBagLayout()); JButton ok = new JButton(resourceBundle.getString("button.ok")); JButton cancel = new JButton(resourceBundle.getString("button.cancel")); icon = new JLabel(imageFile != null ? new ImageIcon(imageFile) : null); gammaBox.setSelected(source.isGammaCorrection()); gbc = new GridBagConstraints(); gbc.weightx = 0.5; gbc.gridx = 0; mainPanel.add(vsyncBox, gbc); gbc = new GridBagConstraints(); gbc.weightx = 0.5; gbc.gridx = 3; gbc.insets = new Insets(4, 4, 4, 4); gbc.weightx = 0.5; gbc.gridx = 0; ok.addActionListener(new ActionListener() { this.getContentPane().add(mainPanel);
private void initializeComponents (String chartTitle, boolean hasIndependent) { JPanel contentPanel = getContentPanel(); formPanel = new JPanel(new GridBagLayout()); contentPanel.add(formPanel, new GridBagConstraints(5, 5, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 6), 0, 0)); JLabel label = new JLabel("High:"); formPanel.add(label, new GridBagConstraints(2, 1, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 6), 0, 0)); formPanel.add(highMinSlider, new GridBagConstraints(3, 1, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); highRangeButton = new JButton("<"); highRangeButton.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6)); formPanel.add(highRangeButton, new GridBagConstraints(5, 1, 1, 1, 0.0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 1, 0, 0), 0, 0)); JLabel label = new JLabel("Low:"); formPanel.add(label, new GridBagConstraints(2, 2, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 6), 0, 0)); lowRangeButton = new JButton("<"); lowRangeButton.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6)); formPanel.add(lowRangeButton, new GridBagConstraints(5, 2, 1, 1, 0.0, 0, GridBagConstraints.WEST,
private void initializeComponents () { setLayout(new GridBagLayout()); titlePanel = new JPanel(new GridBagLayout()); add(titlePanel, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(3, 0, 3, 0), 0, 0)); titlePanel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); JLabel label = new JLabel(name); titlePanel.add(label, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 6, 3, 6), 0, 0)); label.setFont(label.getFont().deriveFont(Font.BOLD)); descriptionLabel = new JLabel(description); titlePanel.add(descriptionLabel, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 6, 3, 6), 0, 0)); contentPanel = new JPanel(new GridBagLayout()); add(contentPanel, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 6, 6, 6), 0, 0)); advancedPanel = new JPanel(new GridBagLayout()); add(advancedPanel, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 6, 6, 6), 0, 0));
public LogFactor5ErrorDialog(JFrame jframe, String message) { super(jframe, "Error", true); JButton ok = new JButton("Ok"); ok.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { hide(); } }); JPanel bottom = new JPanel(); bottom.setLayout(new FlowLayout()); bottom.add(ok); JPanel main = new JPanel(); main.setLayout(new GridBagLayout()); wrapStringOnPanel(message, main); getContentPane().add(main, BorderLayout.CENTER); getContentPane().add(bottom, BorderLayout.SOUTH); show(); } //--------------------------------------------------------------------------
private JTextField nameField = new JTextField(10); private JComboBox searchTermsCombo = new JComboBox(); private JButton addNewFieldBtn = new JButton("Add New Field"); private JButton submitBtn = new JButton("Submit"); private JPanel centerPanel = new JPanel(new GridBagLayout()); private int gridY = 0; centerPanel.add(new JLabel("Name:"), gbc); gbc = createGBC(1, gridY); centerPanel.add(nameField, gbc); gridY++; centerPanel.add(new JLabel("Search Terms:"), gbc); win.pack(); win.setLocationRelativeTo(null); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = x; gbc.gridy = y; gbc.anchor = (x == 0) ? gbc.LINE_START : gbc.LINE_END; gbc.fill = (x == 0) ? gbc.BOTH : gbc.HORIZONTAL; gbc.insets = (x == 0) ? new Insets(5, 0, 5, 5) : new Insets(5, 5, 5, 0); return gbc;
GridBagLayout gridBag = new GridBagLayout(); GridBagConstraints constraints; Insets insets; contentPane.setLayout(gridBag); filename = new JTextField(12); JLabel filenameLabel = new JLabel("Filename:"); filenameLabel.setLabelFor(filename); insets = new Insets(12, 12, 0, 0); // top, left, bottom, right constraints = new GridBagConstraints( 0, 0, 1, 1, // x, y, width, height 0.0, 0.0, // weightx, weighty gridBag.setConstraints(filenameLabel, constraints); contentPane.add(filenameLabel); insets = new Insets(12, 7, 0, 12); // top, left, bottom, right constraints = new GridBagConstraints( 1, 0, 1, 1, // x, y, width, height 1.0, 1.0, // weightx, weighty gridBag.setConstraints(filename, constraints); contentPane.add(filename); gridBag.setConstraints(okButton, constraints); contentPane.add(okButton);
JFrame frame = new JFrame("Testing"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setContentPane(new JLabel(new ImageIcon(img))); frame.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridwidth = GridBagConstraints.REMAINDER; frame.add(new JLabel("Hello world"), gbc); frame.add(new JLabel("I'm on top"), gbc); frame.add(new JButton("Clickity-clackity"), gbc); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); } catch (IOException exp) { exp.printStackTrace();