From c33e4fe1d9b9ee41be9fbf2fcf8640ab9fca04b1 Mon Sep 17 00:00:00 2001 From: kuangshuai Date: Fri, 8 Oct 2021 17:55:51 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-60472=20=E6=B0=94=E6=B3=A1=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E6=96=87=E5=AD=97=E4=B8=8D=E5=BA=94=E8=AF=A5=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../guide/ui/bubble/BubbleWithClose.java | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/guide/ui/bubble/BubbleWithClose.java b/designer-base/src/main/java/com/fr/design/mainframe/guide/ui/bubble/BubbleWithClose.java index b5e966063..9894e5c93 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/guide/ui/bubble/BubbleWithClose.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/guide/ui/bubble/BubbleWithClose.java @@ -2,12 +2,15 @@ package com.fr.design.mainframe.guide.ui.bubble; import com.fr.base.GraphHelper; +import com.fr.design.gui.frpane.UITextPane; import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.gui.itextarea.UITextArea; import com.fr.general.IOUtils; import com.fr.stable.StringUtils; -import javax.swing.JTextArea; +import javax.swing.JTextPane; +import javax.swing.text.SimpleAttributeSet; +import javax.swing.text.StyleConstants; +import javax.swing.text.StyledDocument; import java.awt.Color; import java.awt.Component; import java.awt.Container; @@ -35,10 +38,11 @@ public class BubbleWithClose extends Bubble { private static final Color CONTENT_COLOR = new Color(51,51,52,128); private static final Insets DEFAULT_INSET = new Insets(10, 15, 10, 15); + private String title; private String content; - private UITextArea titleTextArea; - private UITextArea contentTextArea; + private UITextPane titleTextArea; + private UITextPane contentTextArea; private UIButton closeButton; public BubbleWithClose(String title, String content) { @@ -145,18 +149,24 @@ public class BubbleWithClose extends Bubble { } } - private UITextArea createTextArea(String str, Font font, Color foreground) { - UITextArea textArea= new UITextArea(str){ + private UITextPane createTextArea(String str, Font font, Color foreground) { + UITextPane textArea= new UITextPane(){ @Override public Insets getInsets() { return new Insets(0, 0, 0, 0); } }; - textArea.setEnabled(true); + textArea.setText(str); + textArea.setEnabled(false); + textArea.setDisabledTextColor(foreground); textArea.setBorder(null); textArea.setFont(font); textArea.setOpaque(false); textArea.setForeground(foreground); + StyledDocument doc = textArea.getStyledDocument(); + SimpleAttributeSet center = new SimpleAttributeSet(); + StyleConstants.setAlignment(center, StyleConstants.ALIGN_CENTER); + doc.setParagraphAttributes(0, doc.getLength(), center, false); return textArea; } @@ -206,7 +216,7 @@ public class BubbleWithClose extends Bubble { g2.fillRoundRect(bounds.x, bounds.y, bounds.width, HEADER_HEIGHT, 10, 10); } - private int countLines(JTextArea textArea, int max_width) { + private int countLines(JTextPane textArea, int max_width) { AttributedString text = new AttributedString(textArea.getText()); text.addAttribute(TextAttribute.FONT, textArea.getFont()); FontRenderContext frc = textArea.getFontMetrics(textArea.getFont()) @@ -222,7 +232,7 @@ public class BubbleWithClose extends Bubble { return lines; } - private Dimension calTextSize(JTextArea textArea, int maxWidth) { + private Dimension calTextSize(JTextPane textArea, int maxWidth) { if (textArea == null) { return new Dimension(0, 0); }