/** * @param components Components. * @return Panel. */ private JPanel createPanel(JComponent... components) { JPanel panel = new JPanel(); panel.setLayout(new FlowLayout()); for (JComponent component : components) panel.add(component); return panel; }
JPanel buttonPanel = new JPanel(); FlowLayout layout = new FlowLayout(); layout.setAlignment(FlowLayout.LEFT); buttonPanel.setLayout(layout); playButton = new JButton("Play"); playButton.setEnabled(true); playButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { player.play(audioPanel.getSelectionStart(), buttonPanel.add(recordButton); buttonPanel.add(playButton); buttonPanel.add(zoomInButton);
JPanel buttonPanel = new JPanel(); buttonPanel.setBackground(Color.WHITE); buttonPanel.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); FlowLayout fl = new FlowLayout(); fl.setAlignment(FlowLayout.RIGHT); buttonPanel.setLayout(fl); tagButton.setText("Tag sentence!"); tagButton.setBackground(Color.WHITE); buttonPanel.add(tagButton); tagButton.addActionListener(e -> performTagAction(e));
JPanel fontPanel = new JPanel(); fontPanel.add(new JLabel("Size:"), new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0)); GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0)); bitmapPanel.add(new JLabel("Gamma:"), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0)); browseButton = new JButton("..."); browseButton.setMargin(new Insets(0, 0, 0, 0)); fontPanel.add(new JLabel("Rendering:"), new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0)); sampleNeheButton = new JButton(); getContentPane().add(rightSidePanel, new GridBagConstraints(1, 0, 1, 2, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); FlowLayout advancePanelLayout = new FlowLayout();
private void init() { JTextArea errorArea = new JTextArea(); errorArea.setEditable(false); errorArea.setText(exc.getMessage() + "\n"); getContentPane().setLayout(new BorderLayout()); JPanel messagePanel = new JPanel(new BorderLayout()); messagePanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory .createTitledBorder(BorderFactory.createEtchedBorder(), NLS.nls("COMPILE_ERROR.PANEL.TITLE")))); messagePanel.add(new JScrollPane(errorArea), BorderLayout.CENTER); getContentPane().add(messagePanel, BorderLayout.CENTER); JPanel btnPane = new JPanel(new FlowLayout(FlowLayout.RIGHT)); okBtn = new JButton(NLS.nls("COMPILE_ERROR.OK_BUTTON.CAPTION")); okBtn.addActionListener(this); btnPane.add(okBtn); getRootPane().setDefaultButton(okBtn); getContentPane().add(btnPane, BorderLayout.SOUTH); pack(); setLocationRelativeTo(getParent()); setVisible(true); }
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); secureMethod3Button.addActionListener(this); JPanel methodPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); methodPanel.add(secureMethod1Button); methodPanel.add(secureMethod2Button); methodPanel.add(secureMethod3Button); frame = new JFrame("Apache Shiro Sample Application"); frame.setSize(500, 200);
@Override public void run () { JPanel panel = new JPanel(new FlowLayout()); JPanel textPanel = new JPanel() { public boolean isOptimizedDrawingEnabled () { return false; }; textPanel.setLayout(new OverlayLayout(textPanel)); panel.add(textPanel); textPanel.add(textField); final JLabel placeholderLabel = new JLabel(hint); placeholderLabel.setForeground(Color.GRAY); placeholderLabel.setAlignmentX(0.0f); textPanel.add(placeholderLabel, 0);
private void setupHandlers() { ripButton.addActionListener(new RipButtonHandler()); ripTextfield.addActionListener(new RipButtonHandler()); ripTextfield.getDocument().addDocumentListener(new DocumentListener() { logPanel.setVisible(!logPanel.isVisible()); emptyPanel.setVisible(!logPanel.isVisible()); checkChoise.setLayout(new FlowLayout()); JFrame.setDefaultLookAndFeelDecorated(true); JFrame frame = new JFrame("Are you sure?"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); changeLocale(); }); configSaveDirLabel.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { return; configSaveDirLabel.setText(Utils.shortenPath(chosenPath)); Utils.setConfigString("rips.directory", chosenPath); });
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(); } //--------------------------------------------------------------------------
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) {
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); JLabel contributorsLabel = new JLabel("contributors (alphabetically ordered):", JLabel.CENTER); buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); if (UrlDisplayHelper.displayUrlIsSupported()) { JButton homePageButton = new JButton("Homepage"); homePageButton.setActionCommand(ACTION_HOMEPAGE); homePageButton.addActionListener(this); buttonPanel.add(homePageButton); okButton.addActionListener(this); buttonPanel.add(okButton); getContentPane().add("North", logoPanel); getContentPane().add("Center", versionPanel); getContentPane().add("South", buttonPanel); pack(); setResizable(false);
jb_add.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { jb_addAndClose.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { jb_cancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { c.setLayout(new BorderLayout()); JPanel jp = new JPanel(new BorderLayout()); c.add(jp, BorderLayout.NORTH); c.add(jsp, BorderLayout.CENTER); JPanel jp = new JPanel(); jp.setLayout(new FlowLayout(FlowLayout.RIGHT)); jp.add(jb_cancel); jp.add(jb_add);
ASTPanel astPanel = new ASTPanel(model); xPathPanel = new XPathPanel(model); getContentPane().setLayout(new BorderLayout()); JSplitPane editingPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sourcePanel, astPanel); editingPane.setResizeWeight(0.5d); JPanel interactionsPane = new JPanel(new BorderLayout()); interactionsPane.add(xPathPanel, BorderLayout.SOUTH); interactionsPane.add(editingPane, BorderLayout.CENTER); getContentPane().add(interactionsPane, BorderLayout.CENTER); JButton compileBtn = new JButton(NLS.nls("MAIN.FRAME.COMPILE_BUTTON.TITLE")); compileBtn.setActionCommand(ActionCommands.COMPILE_ACTION); compileBtn.addActionListener(this); evalBtn = new JButton(NLS.nls("MAIN.FRAME.EVALUATE_BUTTON.TITLE")); evalBtn.setActionCommand(ActionCommands.EVALUATE_ACTION); evalBtn.addActionListener(this); evalBtn.setEnabled(false); statusLbl = new JLabel(); statusLbl.setHorizontalAlignment(SwingConstants.RIGHT); JPanel btnPane = new JPanel(new FlowLayout(FlowLayout.LEFT)); btnPane.add(compileBtn); btnPane.add(evalBtn); btnPane.add(statusLbl); getContentPane().add(btnPane, BorderLayout.SOUTH);
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); } }
cache.addChangeListener(model); add(new JScrollPane(table)); JPanel key=new JPanel(new FlowLayout(FlowLayout.LEFT)); key.add(new JLabel("Key ")); key.add(key_field); add(key); JPanel value=new JPanel(new FlowLayout(FlowLayout.LEFT)); value.add(new JLabel("Value")); JPanel repl_count=new JPanel(new FlowLayout(FlowLayout.LEFT)); repl_count.add(new JLabel("Replication count")); JPanel timeout=new JPanel(new FlowLayout(FlowLayout.LEFT)); JPanel prefix=new JPanel(new FlowLayout(FlowLayout.LEFT)); JPanel keys=new JPanel(new FlowLayout(FlowLayout.LEFT)); JPanel size=new JPanel(new FlowLayout(FlowLayout.LEFT)); JPanel perf_repl_count=new JPanel(new FlowLayout(FlowLayout.LEFT)); JPanel perf_timeout=new JPanel(new FlowLayout(FlowLayout.LEFT)); JPanel perf_buttons=new JPanel(new FlowLayout(FlowLayout.LEFT));
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); }
/** * @param gcResource resource to be tracked */ public GCModelLoaderView(GCResource gcResource) { super(new BorderLayout()); setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); JPanel parserInfo = new JPanel(new FlowLayout(FlowLayout.LEFT)); progressBar = new JProgressBar(0, 100); progressBar.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); progressBar.setVisible(true); progressBar.setValue(0); progressBar.setStringPainted(true); cancelButton = new JButton(new SquareIcon()); cancelButton.setActionCommand(CMD_CANCEL); cancelButton.addActionListener(this); messageLabel = new JLabel(); messageLabel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); messageLabel.setVisible(false); parserInfo.add(progressBar); parserInfo.add(cancelButton); parserInfo.add(messageLabel); add(parserInfo, BorderLayout.NORTH); JTextArea textArea = textAreaLogHandler.getTextArea(); textArea.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); JScrollPane textAreaScrollPane = new JScrollPane(textArea); textAreaScrollPane.setPreferredSize(new Dimension(700, 500)); add(textAreaScrollPane, BorderLayout.CENTER); setGCResource(gcResource); }
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)") ); JPanel plafComponents = new JPanel( new FlowLayout(FlowLayout.RIGHT, 3,3)); plafComponents.setBorder( new TitledBorder("FlowLayout(FlowLayout.RIGHT, 3,3)") ); plafComponents.add(plafChooser); plafComponents.add(pack); gui.add(plafComponents, BorderLayout.NORTH); new TitledBorder("GridLayout(0,2,3,3)") ); JButton addNew = new JButton("Add Another Label"); labels.add( new JLabel("Label " + ++labelCount) ); frame.setContentPane(gui); frame.pack();
private void initComponents() { JPanel jp = new JPanel(); jp.setLayout(new BorderLayout()); jta_error = new JTextArea(10, 40); jta_error.setEditable(false); JScrollPane jsp = new JScrollPane(jta_error); jp.add(jsp, BorderLayout.CENTER); JPanel jp_south = new JPanel(); jp_south.setLayout(new FlowLayout(FlowLayout.CENTER)); jb_ok = new JButton("Ok"); jb_ok.setMnemonic('o'); getRootPane().setDefaultButton(jb_ok); jb_ok.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { jb_okActionPerformed(event); } }); jp_south.add(jb_ok); jp.add(jp_south, BorderLayout.SOUTH); this.setContentPane(jp); pack(); }