protected JPanel createStatusArea() { JPanel statusArea = new JPanel(); JLabel status = new JLabel("No log records to display."); _statusLabel = status; status.setHorizontalAlignment(JLabel.LEFT); statusArea.setBorder(BorderFactory.createEtchedBorder()); statusArea.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); statusArea.add(status); return (statusArea); }
private void setup() { setLayout(new BorderLayout()); JPanel panel = new JPanel(); add(jl, BorderLayout.SOUTH); add(panel, BorderLayout.CENTER); panel.setLayout(new GridLayout(6, 2)); panel.add(new JLabel("Name")); panel.add(jtFields[0]); panel.add(new JLabel("Contact Number")); panel.add(jtFields[1]); panel.add(new JLabel("Address")); panel.add(jtAreas[0]); panel.add(new JLabel("Deposit Number")); panel.add(jtFields[2]); panel.add(new JLabel("Order")); panel.add(jtAreas[1]); panel.add(clearButton); panel.add(processButton); clearButton.addActionListener(e -> { for (JTextArea i : jtAreas) { i.setText(""); processButton.addActionListener(e -> { Order order = new Order(jtFields[0].getText(), jtFields[1].getText(), jtAreas[0].getText(), jtFields[2].getText(), jtAreas[1].getText()); jl.setText(sendRequest(order)); });
private JLabel label(String content, Font font) { JLabel jLabel = new JLabel(content); jLabel.setHorizontalAlignment(JLabel.CENTER); if (font != null) { jLabel.setFont(font); } return jLabel; }
@Override public void mouseEntered(MouseEvent mouseEvent) { textLabel.setForeground(HIGHLIGHT_COLOR); if (!ordering) { arrowLabel.setIcon(HIGHLIGHT_ARROW_UP); } }
((JSpinner.DefaultEditor)((JSpinner)component).getEditor()).getTextField().setColumns(4); JPanel panel = new JPanel(); 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 + ":")); panel.add(component); JPanel buttonPanel = new JPanel(); getContentPane().add( buttonPanel, new GridBagConstraints(0, 2, 2, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); JButton okButton = new JButton("OK"); buttonPanel.add(okButton); okButton.addActionListener(new ActionListener() { public void actionPerformed (ActionEvent evt) { okPressed = true; JButton cancelButton = new JButton("Cancel"); buttonPanel.add(cancelButton); cancelButton.addActionListener(new ActionListener() {
public void afterPropertiesSet() throws Exception { ClassPathResource resource = new ClassPathResource("logo.png"); ImageIcon icon = new ImageIcon(resource.getURL()); JLabel logo = new JLabel(icon); saveButton = new JButton("Save Value"); saveButton.addActionListener(this); refreshButton = new JButton("Refresh Value"); refreshButton.addActionListener(this); JPanel valuePanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); valuePanel.add(valueField); valuePanel.add(saveButton); valuePanel.add(refreshButton); methodPanel.add(secureMethod3Button); frame = new JFrame("Apache Shiro Sample Application"); frame.setSize(500, 200); Container panel = frame.getContentPane(); panel.setLayout(new BorderLayout()); panel.add(logo, BorderLayout.NORTH); panel.add(valuePanel, BorderLayout.CENTER); panel.add(methodPanel, BorderLayout.SOUTH);
public final void initUI() { Font font = new Font("Serif", Font.BOLD, 13); JLabel name = new JLabel("jadx"); name.setFont(font); name.setAlignmentX(0.5f); JLabel desc = new JLabel("Dex to Java decompiler"); desc.setFont(font); desc.setAlignmentX(0.5f); JLabel version = new JLabel("version: " + JadxDecompiler.getVersion()); version.setFont(font); version.setAlignmentX(0.5f); JPanel textPane = new JPanel(); textPane.setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15)); textPane.setLayout(new BoxLayout(textPane, BoxLayout.PAGE_AXIS)); textPane.add(Box.createRigidArea(new Dimension(0, 10))); textPane.add(name); textPane.add(Box.createRigidArea(new Dimension(0, 20))); JButton close = new JButton(NLS.str("tabs.close")); close.addActionListener(event -> dispose()); close.setAlignmentX(0.5f); contentPane.add(textPane, BorderLayout.CENTER); contentPane.add(close, BorderLayout.PAGE_END);
String name = node.makeLongString(); final JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 3, 0)); panel.setOpaque(false); final JLabel label = new JLabel(name); label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10)); label.setIcon(node.getIcon()); final JButton button = new JButton(); button.setIcon(ICON_CLOSE_INACTIVE); button.setRolloverIcon(ICON_CLOSE); button.setRolloverEnabled(true); button.setOpaque(false); button.addActionListener(e -> closeCodePanel(contentPanel)); panel.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) {
JFrame frame = new JFrame(); frame.setLayout(new BorderLayout()); frame.setSize(200, 200); // create the status bar panel and shove it down the bottom of the frame JPanel statusPanel = new JPanel(); statusPanel.setBorder(new BevelBorder(BevelBorder.LOWERED)); frame.add(statusPanel, BorderLayout.SOUTH); statusPanel.setPreferredSize(new Dimension(frame.getWidth(), 16)); statusPanel.setLayout(new BoxLayout(statusPanel, BoxLayout.X_AXIS)); JLabel statusLabel = new JLabel("status"); statusLabel.setHorizontalAlignment(SwingConstants.LEFT); statusPanel.add(statusLabel); frame.setVisible(true);
public static void main(String args[]){ JFrame f = new JFrame(); f.setLayout(new BorderLayout()); final JPanel p = new JPanel(); p.add(new JLabel("A Panel")); f.add(p, BorderLayout.CENTER); //create a button which will hide the panel when clicked. JButton b = new JButton("HIDE"); b.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ p.setVisible(false); } }); f.add(b,BorderLayout.SOUTH); f.pack(); f.setVisible(true); }
private void initUI() { JLabel lbl = new JLabel(NLS.str("usage_dialog.label")); JLabel nodeLabel = new JLabel(this.node.makeLongString(), this.node.getIcon(), SwingConstants.LEFT); lbl.setLabelFor(nodeLabel); JPanel searchPane = new JPanel(); searchPane.setLayout(new FlowLayout(FlowLayout.LEFT)); searchPane.add(lbl); searchPane.add(nodeLabel); searchPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); initCommon(); JPanel resultsPanel = initResultsTable(); JPanel buttonPane = initButtonsPanel(); Container contentPane = getContentPane(); contentPane.add(searchPane, BorderLayout.PAGE_START); contentPane.add(resultsPanel, BorderLayout.CENTER); contentPane.add(buttonPane, BorderLayout.PAGE_END); setTitle(NLS.str("usage_dialog.title")); pack(); setSize(800, 500); setLocationRelativeTo(null); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); setModalityType(ModalityType.MODELESS); } }
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; }
textPane.setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15)); JPanel controlPane = new JPanel(); controlPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); final JComboBox<Level> cb = new JComboBox<>(LEVEL_ITEMS); cb.setSelectedItem(level); registerLogListener(); }); JLabel levelLabel = new JLabel(NLS.str("log_viewer.log_level")); levelLabel.setLabelFor(cb); controlPane.add(levelLabel); controlPane.add(cb); JButton close = new JButton(NLS.str("tabs.close")); close.addActionListener(event -> close()); close.setAlignmentX(0.5f); contentPane.add(controlPane, BorderLayout.PAGE_START); contentPane.add(scrollPane, BorderLayout.CENTER); contentPane.add(close, BorderLayout.PAGE_END);
super(jframe, title, true); JPanel bottom = new JPanel(); bottom.setLayout(new FlowLayout()); JPanel main = new JPanel(); main.setLayout(new FlowLayout()); main.add(new JLabel(label)); _textField = new JTextField(size); main.add(_textField); JButton ok = new JButton("Ok"); ok.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { hide(); JButton cancel = new JButton("Cancel"); cancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { bottom.add(ok); bottom.add(cancel); getContentPane().add(main, BorderLayout.CENTER); getContentPane().add(bottom, BorderLayout.SOUTH); pack(); centerWindow(this);
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 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; }
JFrame frame = new JFrame(); frame.setTitle("Welcome!"); frame.setSize(520, 480); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel heroShotPanel = new JPanel(); JLabel heroShot = new JLabel(heroShotImage); heroShotPanel.add(heroShot); JPanel submitPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); JButton start = new JButton("Start"); start.setToolTipText("Click to use library"); submitPanel.add(start); frame.getContentPane().add(heroShotPanel, BorderLayout.NORTH); frame.getContentPane().add(submitPanel, BorderLayout.SOUTH); frame.setVisible(true); frame.getRootPane().setDefaultButton(start); start.requestFocus();
final JFrame frame = new JFrame("Nested Layout Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JPanel gui = new JPanel(new BorderLayout(5,5)); gui.setBorder( new TitledBorder("BorderLayout(5,5)") ); plafComponents.add(plafChooser); plafComponents.add(pack); gui.add(plafComponents, BorderLayout.NORTH); JPanel dynamicLabels = new JPanel(new BorderLayout(4,4)); dynamicLabels.setBorder( new TitledBorder("GridLayout(0,2,3,3)") ); JButton addNew = new JButton("Add Another Label"); labels.add( new JLabel("Label " + ++labelCount) ); g.fillRect(0,0,200,200); ImageIcon ii = new ImageIcon(bi); JLabel imageLabel = new JLabel(ii); frame.setContentPane(gui); frame.pack();
rootPanel = new JPanel(); rootPanel.setLayout(new GridLayoutManager(9, 4, new Insets(5, 5, 0, 0), -1, -1)); final Spacer spacer1 = new Spacer(); rootPanel.add(spacer1, new GridConstraints(2, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); final JLabel label1 = new JLabel(); Font label1Font = this.$$$getFont$$$(null, Font.BOLD, 20, label1.getFont()); if (label1Font != null) label1.setFont(label1Font); label1.setText("Miscellaneous Settings"); rootPanel.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final Spacer spacer2 = new Spacer(); rootPanel.add(spacer2, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); resetCustomAssociationsButton = new JButton(); resetCustomAssociationsButton.setText("Reset custom associations"); rootPanel.add(resetCustomAssociationsButton, new GridConstraints(7, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); alwaysSendRequestsCheckBox.setMargin(new Insets(2, 2, 2, 2)); alwaysSendRequestsCheckBox.setText("Always send requests"); alwaysSendRequestsCheckBox.setToolTipText("Send requests even if a language plugin already supports it"); rootPanel.add(alwaysSendRequestsCheckBox, new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1, false));