private void createNoDevicesPanel() { panelNoDevices = new JPanel(new BorderLayout()); JLabel labelNoDevices = new JLabel(NO_DEVICE_CONNECTED); labelNoDevices.setHorizontalAlignment(SwingConstants.CENTER); panelNoDevices.add(labelNoDevices); }
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); 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 GUI() { frame = new JFrame("PMD Duplicate Code Detector (v " + PMDVersion.VERSION + ')'); menuBar.add(fileMenu); menuBar.add(viewMenu); frame.setJMenuBar(menuBar); JButton browseButton = new JButton("Browse"); browseButton.setMnemonic('b'); browseButton.addActionListener(new BrowseListener()); goButton = new JButton("Go"); goButton.setMnemonic('g'); frame.getContentPane().setLayout(new BorderLayout()); JPanel topPanel = new JPanel(); topPanel.setLayout(new BorderLayout()); topPanel.add(settingsPanel, BorderLayout.NORTH); topPanel.add(progressPanel, BorderLayout.CENTER); setProgressControls(false); // not running now frame.getContentPane().add(topPanel, BorderLayout.NORTH); frame.getContentPane().add(resultsPanel, BorderLayout.CENTER); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack();
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 JSpinner gravitySpinner; private JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout()); draw = new DrawingArea(); mainPanel.add(draw, BorderLayout.CENTER); userInt = new JPanel(); mainPanel.add(userInt, BorderLayout.NORTH); b1 = new JButton("Start"); b2 = new JButton("aaa"); b1.addActionListener(new ActionListener() { @Override SwingUtilities.invokeLater(new Runnable() { public void run() { JFrame window = new JFrame("Ball"); window.add(new StartingPoint().getMainPanel()); window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); window.pack(); window.setLocationRelativeTo(null); window.setVisible(true);
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(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());
private void doEncodingPrompt(final String encoding, final String oldEncoding) { final JPanel encodingPanel = new JPanel(); encodingPanel.setLayout(new BoxLayout(encodingPanel, BoxLayout.PAGE_AXIS)); JLabel text = new JLabel("<html>A head finder or tree reader was selected that has the default encoding " + encoding + "; this differs from " + oldEncoding + ", which was being used. If the encoding is changed, all newly loaded" + "treebanks will be read using the new encoding. Choosing an encoding that is not the true encoding of your tree " + "files may cause errors and unexpected behavior.</html>"); text.setAlignmentX(SwingConstants.LEADING); JPanel textPanel = new JPanel(new BorderLayout()); textPanel.setPreferredSize(new Dimension(100,100)); textPanel.add(text); fileFilterDialog.setMessage(encodingPanel); JButton[] options = new JButton[3]; JButton useNewEncoding = new JButton("Use " + encoding); JButton useOldEncoding = new JButton("Use " + oldEncoding); JButton useAnotherEncoding = new JButton("Use encoding...");
final JButton openFileButton = new JButton(new FileSelectionAction()); openFileButton.setMnemonic(KeyEvent.VK_S); openFileButton.setText("Open File"); }); final JLabel modesLabel = new JLabel("Modes:", SwingConstants.RIGHT); final int leftIndentation = 10; modesLabel.setBorder(BorderFactory.createEmptyBorder(0, leftIndentation, 0, 0)); final JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new GridLayout(1, 2)); buttonPanel.add(openFileButton); buttonPanel.add(reloadFileButton); final JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout()); mainPanel.add(buttonPanel); mainPanel.add(modesPanel, BorderLayout.LINE_END);
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();
/** * @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); }
protected JDialog createDialog(Component parent) { Frame frame = parent instanceof Frame ? (Frame) parent : (Frame) SwingUtilities.getAncestorOfClass(Frame.class, parent); JDialog dialog = new JDialog(frame, ("Select Font"), true); Action okAction = new DialogOKAction(dialog); Action cancelAction = new DialogCancelAction(dialog); JButton okButton = new JButton(okAction); okButton.setFont(DEFAULT_FONT); JButton cancelButton = new JButton(cancelAction); cancelButton.setFont(DEFAULT_FONT); JPanel buttonsPanel = new JPanel(); buttonsPanel.setLayout(new GridLayout(2, 1)); buttonsPanel.add(okButton); buttonsPanel.add(cancelButton); buttonsPanel.setBorder(BorderFactory.createEmptyBorder(25, 0, 10, 10)); ActionMap actionMap = buttonsPanel.getActionMap(); actionMap.put(cancelAction.getValue(Action.DEFAULT), cancelAction); actionMap.put(okAction.getValue(Action.DEFAULT), okAction); InputMap inputMap = buttonsPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), cancelAction.getValue(Action.DEFAULT)); inputMap.put(KeyStroke.getKeyStroke("ENTER"), okAction.getValue(Action.DEFAULT)); JPanel dialogEastPanel = new JPanel(); dialogEastPanel.setLayout(new BorderLayout()); dialogEastPanel.add(buttonsPanel, BorderLayout.NORTH); dialog.getContentPane().add(this, BorderLayout.CENTER); dialog.getContentPane().add(dialogEastPanel, BorderLayout.EAST); dialog.pack(); dialog.setLocationRelativeTo(frame); return dialog; }
public static void main(String[] args) { JFrame frame = new TestScrollPane(); JPanel panel = new JPanel(); JTable table = new JTable(); panel.setLayout(new BorderLayout()); panel.add(new JLabel("NORTH"), BorderLayout.NORTH); panel.add(new JLabel("SOUTH"), BorderLayout.SOUTH); JScrollPane sp = new JScrollPane(table); sp.setBorder(BorderFactory.createEmptyBorder()); panel.add(sp, BorderLayout.CENTER); frame.add(panel); frame.setVisible(true); }
super(new BorderLayout()); Model model = new Model(); View view = new View(model); Control control = new Control(model, view); JLabel label = new JLabel("Guess what color!", JLabel.CENTER); this.add(label, BorderLayout.NORTH); this.add(view, BorderLayout.CENTER); this.add(control, BorderLayout.SOUTH); private JButton reset = new JButton("Reset"); private Model model; private ColorIcon icon = new ColorIcon(80, Color.gray); private JLabel label = new JLabel(s, icon, JLabel.CENTER); super(new BorderLayout()); this.model = model; label.setVerticalTextPosition(JLabel.BOTTOM); label.setHorizontalTextPosition(JLabel.CENTER); this.add(label, BorderLayout.CENTER); JPanel panel = new JPanel(); for (Piece p : Piece.values()) { PieceButton pb = new PieceButton(p);
JButton showWaitBtn = new JButton(new ShowWaitAction("Show Wait Dialog")); JPanel panel = new JPanel(); panel.add(showWaitBtn); JFrame frame = new JFrame("Frame"); frame.getContentPane().add(panel); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); JPanel panel = new JPanel(new BorderLayout()); panel.add(progressBar, BorderLayout.CENTER); panel.add(new JLabel("Please wait......."), BorderLayout.PAGE_START); dialog.add(panel); dialog.pack();
final JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JLabel l = new JLabel(); l.setText("Time: " + System.currentTimeMillis()); new Thread(t).start(); final JButton b = new JButton("Stop"); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) f.getContentPane().setLayout(new BorderLayout()); f.getContentPane().add(l, BorderLayout.CENTER); f.getContentPane().add(b, BorderLayout.SOUTH); f.setLocation(100, 100); f.pack(); f.setVisible(true);
private WebEngine engine; private JFrame frame = new JFrame(); private JPanel panel = new JPanel(new BorderLayout()); private JLabel lblStatus = new JLabel(); txtURL.addActionListener(al); progressBar.setPreferredSize(new Dimension(150, 18)); progressBar.setStringPainted(true); JPanel topBar = new JPanel(new BorderLayout(5, 0)); topBar.setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 5)); topBar.add(txtURL, BorderLayout.CENTER); topBar.add(btnGo, BorderLayout.EAST); JPanel statusBar = new JPanel(new BorderLayout(5, 0)); statusBar.setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 5)); statusBar.add(lblStatus, BorderLayout.CENTER); statusBar.add(progressBar, BorderLayout.EAST); panel.add(statusBar, BorderLayout.SOUTH); frame.getContentPane().add(panel); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
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(); }
JLabel l = new JLabel(text, alignment); l.setBorder(new LineBorder(Color.RED, 2)); return l; SwingUtilities.invokeLater(new Runnable() { public void run() { JPanel p = new JPanel(new GridLayout(2,2,4,4)); p.setBackground(Color.black); p.setBorder(new EmptyBorder(4,4,4,4)); JPanel border = new JPanel(new BorderLayout()); border.add(getLabel( "Border", SwingConstants.CENTER), BorderLayout.CENTER); p.add(border); JPanel gridbag = new JPanel(new GridBagLayout()); gridbag.add(getLabel("GridBag")); p.add(gridbag); p.add(box); JFrame f = new JFrame("Streeeetch me.."); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setContentPane(p); f.pack(); f.setLocationByPlatform(true); f.setVisible(true);