For IntelliJ IDEA,
Android Studio or Eclipse



private void myMethod () {}
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(); } //--------------------------------------------------------------------------
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 GUIRunner() { imageLabel = new JLabel(); textArea = new JTextArea(); textArea.setEditable(false); textArea.setMaximumSize(new Dimension(400, 200)); Container panel = new JPanel(); panel.setLayout(new FlowLayout()); panel.add(imageLabel); panel.add(textArea); setTitle("ZXing"); setSize(400, 400); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); setContentPane(panel); setLocationRelativeTo(null); }
private void makeGUI() { final JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().setLayout(new FlowLayout()); // include: "class AnswerWorker" code here. // include: "JButton" b code here. f.getContentPane().add(b); f.getContentPane().add(new JButton("Nothing")); f.pack(); f.setVisible(true); }
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(); } //--------------------------------------------------------------------------
public CategoryNodeRenderer() { _panel.setBackground(UIManager.getColor("Tree.textBackground")); if (_sat == null) { // Load the satellite image. String resource = "/org/apache/log4j/lf5/viewer/images/channelexplorer_satellite.gif"; URL satURL = getClass().getResource(resource); _sat = new ImageIcon(satURL); } setOpaque(false); _checkBox.setOpaque(false); _panel.setOpaque(false); // The flowlayout set to LEFT is very important so that the editor // doesn't jump around. _panel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); _panel.add(_checkBox); _panel.add(this); setOpenIcon(_sat); setClosedIcon(_sat); setLeafIcon(_sat); }
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);
this.fcn = fcn; getContentPane().setLayout(new BorderLayout()); getContentPane().add(tabs, BorderLayout.CENTER); buttonPanel = new JPanel(new FlowLayout()); refreshClass = new JButton("Refresh"); refreshClass.addActionListener(this); buttonPanel.add(refreshClass); buttonPanel.setVisible(false); getContentPane().add(buttonPanel, BorderLayout.SOUTH);
@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);
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));
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();
public TabbedPane(String name, final JTabbedPane pane) { super(new FlowLayout(FlowLayout.LEFT, 0, 0)); label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5)); button.setComponentPopupMenu(pop_up); button.addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) {
JFrame frame = new JFrame("Layout Example"); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); borderPanel.setBackground(Color.WHITE); for (int i = 0; i < 5; i++) { buttons[i] = new JButton(borderConstraints[i]); borderPanel.add(buttons[i], borderConstraints[i]); contentPane.add(borderPanel); flowPanel = new JPanel(new FlowLayout( FlowLayout.CENTER, hGap, vGap)); flowPanel.setBorder( flowPanel.setBackground(Color.WHITE); for (int i = 5; i < 8; i++) { buttons[i] = new JButton(Integer.toString(i)); flowPanel.add(buttons[i]); gridPanel.setBackground(Color.WHITE); for (int i = 8; i < 12; i++) { buttons[i] = new JButton(Integer.toString(i)); JPanel panel = new JPanel(new FlowLayout( FlowLayout.CENTER, hGap, vGap)); panel.setOpaque(true);
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();
protected void initComponents() { Panel buttonPanel = new Panel(); buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); JButton okButton = new JButton(LocalisationHelper.getString("button_ok")); okButton.setActionCommand(ACTION_OK); okButton.addActionListener(this); buttonPanel.add(okButton); getContentPane().add("South", buttonPanel); }
JFrame frame = new JFrame(); frame.getContentPane().setLayout(new FlowLayout()); frame.getContentPane().add(new JLabel(new ImageIcon(img))); frame.getContentPane().add(new JLabel(new ImageIcon(img2))); frame.getContentPane().add(new JLabel(new ImageIcon(img3))); frame.pack(); frame.setVisible(true); //frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // if you want the X button to close the app
import java.awt.*; import javax.swing.*; public class DemoJTextFieldWithLimit extends JApplet{ JTextField textfield1; JLabel label1; public void init() { getContentPane().setLayout(new FlowLayout()); // label1 = new JLabel("max 10 chars"); textfield1 = new JTextField(15); getContentPane().add(label1); getContentPane().add(textfield1); textfield1.setDocument (new JTextFieldLimit(10)); } }
/** * @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); }
setLayout(new BorderLayout()); this.panel = new JPanel(); this.panel.setLayout(new FlowLayout()); add(panel, BorderLayout.CENTER); JButton button = new JButton("CLICK HERE"); add(button, BorderLayout.SOUTH); button.addActionListener(this); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(500, 500); setVisible(true); this.panel.add(new JButton("Button")); this.panel.revalidate(); validate();
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-2017: 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);