2011-09-21 62 views
7

我想在我的應用程序中創建一個選項對話框。在這個對話框中,我想製作一種由邊框和標題圍成的區域。在Firefox中製作帶有標題的JPanel邊框

的我想要的一個例子是在Firefox:

Firefox Options

我怎麼可以這樣做,在Java中?

回答

10

Here你可以找到你需要的所有信息。

基本上你可以使用邊界工廠使用可用的類型在Swing創建一個邊框:

Border lineBorder = BorderFactory.createLineBorder(Color.black); 
JPanel panel = new JPanel(); 
panel.setBorder(lineBorder); 

你也可以定義你的自定義邊框實現Border interface

+2

+1這就是我正在尋找的。 'BorderFactory.createTitledBorder( \t \t loweredetched, 「標題」);'謝謝 – Neifen

+0

爲最好的輸出將是CompoundBorder +1 – mKorbel

+1

@mKorbel更好看:最後,你是一個10K的用戶:) – Heisenbug