public SettingsGroup(String title) { setBorder(BorderFactory.createTitledBorder(title)); setLayout(new GridBagLayout()); c = new GridBagConstraints(); c.insets = new Insets(5, 5, 5, 5); c.weighty = 1.0; }
private JPanel makeFoundStatsBox() { JPanel foundStatsBox = new JPanel(); foundStatsBox.setLayout(new GridBagLayout()); Box labelBox = Box.createHorizontalBox(); foundStats = new JLabel(" "); labelBox.add(foundStats); historyButton = new JButton("Statistics"); historyButton.setEnabled(false); historyButton.addActionListener(this); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.weightx = 1.7; foundStatsBox.add(labelBox,c); c.weightx = .3; c.gridwidth = 1; foundStatsBox.add(historyButton); return foundStatsBox; }
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); }
public MainWindow() { mainFrame = new JFrame("RipMe v" + UpdateUtils.getThisJarVersion()); mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); mainFrame.setLayout(new GridBagLayout()); createUI(mainFrame.getContentPane()); pack(); loadHistory(); setupHandlers(); Thread shutdownThread = new Thread(this::shutdownCleanup); Runtime.getRuntime().addShutdownHook(shutdownThread); if (Utils.getConfigBoolean("auto.update", true)) { upgradeProgram(); } boolean autoripEnabled = Utils.getConfigBoolean("clipboard.autorip", false); ClipboardUtils.setClipboardAutoRip(autoripEnabled); trayMenuAutorip.setState(autoripEnabled); }
final GridBagLayout gridbag = new GridBagLayout(); final GridBagConstraints c = new GridBagConstraints(); setLayout(gridbag); JLabel label = new JLabel("Filter Level:"); gridbag.setConstraints(label, c); add(label); label = new JLabel("Filter Thread:"); gridbag.setConstraints(label, c); add(label); label = new JLabel("Filter Logger:"); gridbag.setConstraints(label, c); add(label);
JPanel panel = new JPanel(new GridBagLayout()); EditorPanel.addContent(panel, i, 0, new JLabel("Shape"), false, GridBagConstraints.WEST, GridBagConstraints.NONE, 0,0); EditorPanel.addContent(panel, i++,1, shapeCombo = new JComboBox(new DefaultComboBoxModel(spawnShapes)), false, GridBagConstraints.WEST, GridBagConstraints.NONE, 1,0); EditorPanel.addContent(panel, i, 0, edgesLabel = new JLabel("Edges"), false, GridBagConstraints.WEST, GridBagConstraints.NONE, 0,0); EditorPanel.addContent(panel, i++, 1, edgesCheckbox = new JCheckBox(), false, GridBagConstraints.WEST, GridBagConstraints.NONE, 0,0); EditorPanel.addContent(panel, i, 0, sideLabel = new JLabel("Side"), false, GridBagConstraints.WEST, GridBagConstraints.NONE, 0,0); EditorPanel.addContent(panel, i++, 1, sideCombo = new JComboBox(new DefaultComboBoxModel(SpawnSide.values())), false, GridBagConstraints.WEST, GridBagConstraints.NONE, 1, 0); edgesCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
/** * Constructor taking a "parent" frame as parameter. * @param parent parent frame for this dialog */ public OpenUrlView(JFrame parent) { super(); this.parent = parent; autoCompletionComboBox = new AutoCompletionComboBox(); panel = new JPanel(new GridBagLayout()); GridBagConstraints gridBagConstraints = new GridBagConstraints(); gridBagConstraints.anchor = GridBagConstraints.WEST; panel.add(autoCompletionComboBox, gridBagConstraints); gridBagConstraints.gridy = 1; addUrlCheckBox = new JCheckBox(LocalisationHelper.getString("urlopen_dialog_add_checkbox"), false); addUrlCheckBox.setToolTipText(LocalisationHelper.getString("urlopen_dialog_hint_add_checkbox")); panel.add(addUrlCheckBox, gridBagConstraints); }
public LogFactor5LoadingDialog(JFrame jframe, String message) { super(jframe, "LogFactor5", false); JPanel bottom = new JPanel(); bottom.setLayout(new FlowLayout()); JPanel main = new JPanel(); main.setLayout(new GridBagLayout()); wrapStringOnPanel(message, main); getContentPane().add(main, BorderLayout.CENTER); getContentPane().add(bottom, BorderLayout.SOUTH); show(); } //--------------------------------------------------------------------------
/** * @return Panel with controls to display license. */ private JPanel createLicensePanel() { JPanel licPanel = new JPanel(new GridBagLayout()); licPanel.add(Box.createVerticalGlue(), gbcStrut()); addAboutItem(licPanel, "Version:", ver); addAboutItem(licPanel, "Release Date:", new SimpleDateFormat("dd MMM yyyy").format(release)); addAboutItem(licPanel, "Copyright:", copyright); return licPanel; }
public Tab(String t) { super(new GridBagLayout()); this.setOpaque(false); this.title = t; this.tabTitle = new JLabel(title); this.createTab(); }
tabPane.addTab(title, tabBody); int index = tabPane.indexOfTab(title); JPanel pnlTab = new JPanel(new GridBagLayout()); pnlTab.setOpaque(false); JLabel lblTitle = new JLabel(title); JButton btnClose = new JButton("x"); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.weightx = 1; pnlTab.add(lblTitle, gbc); gbc.gridx++; gbc.weightx = 0; pnlTab.add(btnClose, gbc); tabPane.setTabComponentAt(index, pnlTab); btnClose.addActionListener(myCloseActionHandler);
private JFrame frame = new JFrame("Test"); private JPanel panel = new JPanel(); private JLabel label = new JLabel("CenteredJLabel"); panel.setLayout(new GridBagLayout()); panel.add(label); panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.add(panel); frame.setSize(400, 300); frame.setLocationRelativeTo(null); frame.setVisible(true);
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 class Class4 { private JFrame f; public Class4() { f = new JFrame("Love Test"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setSize(500,200); f.setLayout(new GridBagLayout()); } // ... }
private ExEntryPanel() { setBorder(BorderFactory.createEtchedBorder()); label = new JLabel(" "); entry = new ExTextField(); entry.setBorder(null); setFontForElements(); setForeground(entry.getForeground()); setBackground(entry.getBackground()); label.setForeground(entry.getForeground()); label.setBackground(entry.getBackground()); GridBagLayout layout = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); setLayout(layout); gbc.gridx = 0; layout.setConstraints(this.label, gbc); add(this.label); gbc.gridx = 1; gbc.weightx = 1.0; gbc.fill = GridBagConstraints.HORIZONTAL; layout.setConstraints(entry, gbc); add(entry); setBorder(BorderFactory.createEtchedBorder()); adapter = new ComponentAdapter() { public void componentResized(ComponentEvent e) { positionPanel(); } }; }
public GridBagHelper(Container container, double[] weights) { this.container = container; this.weights = weights; gridbag = new GridBagLayout(); container.setLayout(gridbag); c = new GridBagConstraints(); c.insets = new Insets(2, 2, 2, 2); c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.HORIZONTAL; }
JPanel panel = new JPanel(new GridBagLayout()); EditorPanel.addContent(panel, i, 0, new JLabel("Shape"), false, GridBagConstraints.WEST, GridBagConstraints.NONE, 0,0); EditorPanel.addContent(panel, i++,1, shapeCombo = new JComboBox(new DefaultComboBoxModel(spawnShapes)), false, GridBagConstraints.WEST, GridBagConstraints.NONE, 1,0); EditorPanel.addContent(panel, i, 0, edgesLabel = new JLabel("Edges"), false, GridBagConstraints.WEST, GridBagConstraints.NONE, 0,0); EditorPanel.addContent(panel, i++, 1, edgesCheckbox = new JCheckBox(), false, GridBagConstraints.WEST, GridBagConstraints.NONE, 0,0); EditorPanel.addContent(panel, i, 0, sideLabel = new JLabel("Side"), false, GridBagConstraints.WEST, GridBagConstraints.NONE, 0,0); EditorPanel.addContent(panel, i++, 1, sideCombo = new JComboBox(new DefaultComboBoxModel(SpawnSide.values())), false, GridBagConstraints.WEST, GridBagConstraints.NONE, 1, 0); edgesCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
JPanel buttonPanel = new JPanel(); buttonPanel.setBackground(Color.WHITE); buttonPanel.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); this.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.gridwidth = GridBagConstraints.REMAINDER;
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(); } //--------------------------------------------------------------------------