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 JLabel label(String content, Font font) { JLabel jLabel = new JLabel(content); jLabel.setHorizontalAlignment(JLabel.CENTER); if (font != null) { jLabel.setFont(font); } return jLabel; }
private void createNoDevicesPanel() { panelNoDevices = new JPanel(new BorderLayout()); JLabel labelNoDevices = new JLabel(NO_DEVICE_CONNECTED); labelNoDevices.setHorizontalAlignment(SwingConstants.CENTER); panelNoDevices.add(labelNoDevices); }
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); window.setLayout(new BorderLayout()); display = new JLabel(); display.setHorizontalAlignment(JLabel.RIGHT); display.setText("0"); window.add(display, BorderLayout.NORTH); JPanel digitsPanel = new JPanel(); digitsPanel.setLayout(new GridLayout(4, 3)); int[] digitOrder = new int[] { 7,8,9,4,5,6,1,2,3,0 }; JButton button = new JButton(Integer.toString(digit)); button.addActionListener(this); digitsPanel.add(button); window.add(digitsPanel, BorderLayout.CENTER); JPanel operatorsPanel = new JPanel(); operatorsPanel.setLayout(new GridLayout(5,1)); String[] operators = new String[] { "+","-","x","/","=" }; window.add(operatorsPanel, BorderLayout.EAST); window.pack(); window.setVisible(true);
protected ShutdownWindow() { JLabel shutdownLabel = new JLabel("Shutting down, please wait..."); shutdownLabel.setHorizontalAlignment(JLabel.CENTER); getContentPane().add(shutdownLabel); setPreferredSize(new Dimension(300, 30)); pack(); Application.center(this); } }
public IconTextField() setLayout(new BorderLayout()); iconWrapperLabel = new JLabel(); iconWrapperLabel.setPreferredSize(new Dimension(30, 0)); iconWrapperLabel.setVerticalAlignment(JLabel.CENTER); iconWrapperLabel.setHorizontalAlignment(JLabel.CENTER);
EventQueue.invokeLater(new Runnable(){ public void run(){ JLabel label = new JLabel(); label.setHorizontalAlignment(SwingConstants.CENTER); try{ // URL imageURL = new URL("http://static.ak.fbcdn.net/rsrc.php/v2/yb/r/GsNJNwuI-UM.gif"); URL imageURL = new URL("http://i34.photobucket.com/albums/d129/nirendaran/Speed/verify_anim.gif"); label.setIcon(new ImageIcon(imageURL)); } catch (MalformedURLException ex){ ex.printStackTrace(); } JFrame frame = new JFrame(); frame.add(label, BorderLayout.CENTER); frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); frame.setMinimumSize(new Dimension(160, 120)); frame.setVisible(true); } });
@PostConstruct public void init() { addWindowListener( new WindowAdapter() { @Override public void windowClosing(WindowEvent windowEvent) { dispose(); presenter.onViewDisposed(); } } ); iconLabel.setHorizontalAlignment(JLabel.CENTER); getContentPane().add(iconLabel); setStatus(false); setMinimumSize(new Dimension(100, 100)); setPreferredSize(new Dimension(300, 300)); setResizable(true); pack(); setVisible(true); }
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLayout(new BorderLayout()); setSize(100, 200); inputDisplay = new JLabel(); inputDisplay.setHorizontalAlignment(JLabel.RIGHT); inputDisplay.setText(Integer.toString(leftHandSide)); operatorIndicator = new JLabel(); operatorIndicator.setBorder(new EmptyBorder(0, 4, 0, 4)); final JPanel display = new JPanel(); display.setLayout(new BorderLayout()); display.add(inputDisplay, BorderLayout.CENTER); display.add(operatorIndicator, BorderLayout.WEST); digitPanel.add(new JPanel()); // Blank spacer panel digitPanel.add(new JButton(new DigitButtonAction(0))); add(display, BorderLayout.NORTH); pack(); @Override public void run() { new CalculatorDemo().setVisible(true);
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);
protected JComponent makeTextPanel(String text) { JPanel panel = new JPanel(false); JLabel filler = new JLabel(text); filler.setHorizontalAlignment(JLabel.CENTER); panel.setLayout(new GridLayout(1, 1)); panel.add(filler); return panel; }
private JLabel addPanelDescriptionToGridBagLayout(String descriptionText, Container gridBagContainer, int yPosition) { final JLabel panelDescription = new JLabel(descriptionText); panelDescription.setHorizontalAlignment(SwingConstants.LEFT); callbacks.customizeUiComponent(panelDescription); GridBagConstraints gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridwidth = 3; gridBagConstraints.gridx = 1; gridBagConstraints.gridy = yPosition; gridBagConstraints.ipadx = 5; gridBagConstraints.ipady = 5; gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = GridBagConstraints.WEST; gridBagContainer.add(panelDescription, gridBagConstraints); return panelDescription; }
setLayout( new BorderLayout() ): JLabel center = new JLabel("CENTER"); center.setHorizontalAlignment(JLabel.CENTER); // maybe you are missing this add(center, BorderLayout.CENTER); JLabel right = new JLabel("RIGHT"); add(right, BorderLayout.LINE_END);
public void addRow(String label, String tooltip, JComponent comp) { c.gridy = row++; JLabel jLabel = new JLabel(label); jLabel.setLabelFor(comp); jLabel.setHorizontalAlignment(SwingConstants.LEFT); c.gridx = 0; c.gridwidth = 1; c.anchor = GridBagConstraints.LINE_START; c.weightx = 0.8; c.fill = GridBagConstraints.NONE; add(jLabel, c); c.gridx = 1; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.CENTER; c.weightx = 0.2; c.fill = GridBagConstraints.HORIZONTAL; if (tooltip != null) { jLabel.setToolTipText(tooltip); comp.setToolTipText(tooltip); } add(comp, c); comp.addPropertyChangeListener("enabled", evt -> jLabel.setEnabled((boolean) evt.getNewValue())); }
public class Test { public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { createAndShowGUI(); } }); } private static void createAndShowGUI() { JFrame f = new JFrame("Test label"); f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); JLabel label = new JLabel("Test"); //this set component orientation to the right! label.setHorizontalAlignment(JLabel.TRAILING); f.add(label,BorderLayout.SOUTH); f.setLocationByPlatform(true); f.pack(); f.setVisible(true); } }
table.setDefaultRenderer(Double.class, new CurrencyRenderer(nf)); table.setDefaultEditor(Double.class, new CurrencyEditor(nf)); this.add(new JScrollPane(table)); this.setHorizontalAlignment(JLabel.RIGHT); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(this); f.pack(); f.setLocationRelativeTo(null); f.setVisible(true);
private LaunchProgress() { super(new BorderLayout()); progressBar = new JProgressBar(); progressBar.setIndeterminate(false); progressBar.setStringPainted(true); JPanel panel = new JPanel(); label = new JLabel("Starting up"); label.setHorizontalAlignment(JLabel.CENTER); panel.add(label); panel.add(progressBar); add(panel, BorderLayout.PAGE_START); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); } }
private void uiLayout () { topPanel = new JPanel(new GridBagLayout()); topPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); warningNotice = new JLabel("List of third party extensions for LibGDX"); warningNotice2 = new JLabel("These are not maintained by the LibGDX team, please see the support links for info and help"); warningNotice.setHorizontalAlignment(JLabel.CENTER); warningNotice2.setHorizontalAlignment(JLabel.CENTER); bottomPanel = new JPanel(new GridBagLayout()); buttonPanel = new JPanel(new GridBagLayout()); buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); buttonOK = new SetupButton("Save");
private JLabel addErrorMessageToGridBagLayout(Container gridBagContainer, int yPosition) { final JLabel errorMessage = new JLabel(""); errorMessage.setForeground(new Color(255, 0, 0)); errorMessage.setHorizontalAlignment(SwingConstants.LEFT); callbacks.customizeUiComponent(errorMessage); GridBagConstraints gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridwidth = 3; gridBagConstraints.gridx = 1; gridBagConstraints.gridy = yPosition; gridBagConstraints.ipadx = 5; gridBagConstraints.ipady = 10; gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = GridBagConstraints.WEST; gridBagContainer.add(errorMessage, gridBagConstraints); return errorMessage; }
JPanel panel = new JPanel(new BorderLayout()); JLabel label = new JLabel("L'alliage a bien été enregistré."); label.setHorizontalAlignment(JLabel.CENTER); label.setVerticalAlignment(JLabel.CENTER); panel.add(label, BorderLayout.CENTER);