Volevo creare un pannello con all'interno una lista di bottoni.
La lista di bottoni ha un titolo però quando vado ad eseguire il programma, il titolo risulta sovrapposto alla linea del bordo
Qualcuno sa dirmi dov'è l'errore?
codice:
package it.panel;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.GridLayout;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.Border;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
/**
* @author f4068
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class ProvaBordo extends JPanel {
/**
*
*/
public ProvaBordo() {
//super("prova bordo");
super();
Border marginOutside = new EmptyBorder(10,10,10,10);
TitledBorder title = BorderFactory.createTitledBorder("bla bla bla bla bla");
CompoundBorder upperBorder = new CompoundBorder(marginOutside, title);
Border marginInside = new EmptyBorder(10,10,10,10);
this.setBorder(new CompoundBorder(upperBorder, marginInside));
this.setLayout(new GridLayout(0,1));
this.add(new JLabel("uno"));
this.add(new JLabel("uno"));
this.add(new JLabel("uno"));
this.add(new JLabel("uno"));
}
public static void main(String[] args) {
JPanel p = new ProvaBordo();
JFrame frame = new JFrame("ciao");
Container c = frame.getContentPane();
c.setLayout(new BorderLayout());
c.add("North", p);
frame.setSize(500, 600);
frame.setVisible(true);
}
}