Creare un JFrame o JPanel con BorderLayout, assegnargli qualcosa come un BevelBorder o un bordo di linea in modo che sia separato dal resto del contenuto e quindi aggiungere il pannello di stato in BorderLayout.SOUTH.
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);
Ecco il risultato del codice barra di stato sopra sulla mia macchina:
grazie a dio, questo è l'unico codice a barre di stato java utile su tutti gli interni. –
non ha funzionato per me, la barra di stato è finita nel mezzo del finestra –
È necessario utilizzare un layout diverso all'interno di JPanel.Come nel frammento di codice sopra, BoxLayout produrrà il risultato come nell'immagine. –