2015-02-11 39 views
0

我嘗試以下調整的JLabel Swing中

JPanel round1Score = new JPanel(new GridLayout(0,1)); 
JLabel accuracy = new JLabel("<html><div style=\"text-align: center; padding: 10px;\">Accuracy score _____ %</html>"); 
JLabel repeatibility = new JLabel("<html><div style=\"text-align: center; padding: 10px;\">Repeatibility score _____ %</html>"); 
JLabel classification = new JLabel("<html><div style=\"text-align: center; padding: 10px;\">You have been clasified as _____</html>"); 
JLabel tendency = new JLabel("<html><div style=\"text-align: center; padding: 10px;\">You have a tendency to _____</html>"); 

round1Score.add(accuracy); 
round1Score.add(repeatibility); 
round1Score.add(classification); 
round1Score.add(tendency); 

我得到這個

enter image description here

但是我要像10px的或類似這樣的東西標籤之間的間距。你會建議什麼佈局/ HTML?

+0

我要麼在單個'JLabel'中使用單個HTML表格,要麼在[本答案](http://stackoverflow.com/a/21659516/418556)中看到的控件集合「GroupLayout」中使用。 – 2015-02-11 23:02:04

+0

順便說一句 - 對於標籤之間的間距,將'new GridLayout(0,1)'改爲'new GridLayout(0,1,10,10)'。 – 2015-02-14 08:02:52

回答