Tag: insets

Java – 内置边距和JTextArea的JPanel

我想创建这样的东西: 主面板的边距(x)和TextArea位于该面板的中心,几乎填满了面板。 在底部是另一个具有自定义尺寸(高度y)的面板,可以通过一些快捷方式切换为可见和不可见。 底部面板具有FlowLayout和少量元素。 问题是我不知道该怎么做。 BoxLayout没有边距。 我尝试使用GridBagLayout,但我不工作或我不能理解它:( 我也试过设置JTextArea边距 textMain.setMargin(new Insets(insetTop, insetLeft, insetBottom, insetRight)); 但是当有大量文本时,顶部和底部边距消失。 所以现在我正在尝试使用Panels。 有人可以帮帮我吗?

Java Swing – 使用Line Border在TextArea上设置边距

正如标题所说,我只是试图在具有LineBorder集的TextArea上设置边距(提供一些填充)。 没有设置边框,.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上的填充?