[英]Java Swing - setting margins on TextArea with Line Border
正如標題所說,我只是試圖在TextArea上設置一個LineBorder設置的邊距(提供一些填充)。 沒有設置邊框,.setMargins工作正常。 這是特定的代碼塊。
aboutArea = new JTextArea("program info etc.....");
Border border = BorderFactory.createLineBorder(Color.BLACK);
aboutArea.setSize(400, 200);
aboutArea.setBorder(border);
aboutArea.setEditable(false);
aboutArea.setFont(new Font("Verdana", Font.BOLD, 12));
add(aboutArea);
我嘗試過以下各項:
aboutArea.setMargins(10,10,10,10);
.getBorders(aboutArea).set(10,10,10,10);
UIManager.put("aboutArea.margin", new Insets(10, 10, 10, 10));
但是在應用邊框后沒有任何影響邊距,填充總是為0.任何想法如何在帶有邊框的textArea上設置填充?
如果你嘗試添加一個CompoundBorder會怎么樣,這不會給你帶來幾乎相同的東西
JTextArea tarea = new JTextArea("program info etc.");
Border border = BorderFactory.createLineBorder(Color.BLACK);
tarea.setBorder(BorderFactory.createCompoundBorder(border,
BorderFactory.createEmptyBorder(10, 10, 10, 10)));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.