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); }