List of usage examples for javax.swing.text StyledDocument addStyle
public Style addStyle(String nm, Style parent);
From source file:de.tor.tribes.ui.wiz.ret.RetimerCalculationPanel.java
/** * Creates new form AttackSourcePanel/*from w w w . j ava 2 s . c o m*/ */ RetimerCalculationPanel() { initComponents(); jXCollapsiblePane1.setLayout(new BorderLayout()); jXCollapsiblePane1.add(jInfoScrollPane, BorderLayout.CENTER); jInfoTextPane.setText(GENERAL_INFO); StyledDocument doc = (StyledDocument) jTextPane1.getDocument(); Style defaultStyle = doc.addStyle("Default", null); StyleConstants.setItalic(defaultStyle, true); StyleConstants.setFontFamily(defaultStyle, "SansSerif"); dateFormat = new SimpleDateFormat("HH:mm:ss"); retimes = new LinkedList<>(); }
From source file:de.tor.tribes.ui.wiz.ref.SupportRefillCalculationPanel.java
/** * Creates new form AttackSourcePanel/*from w w w.ja v a2 s . c o m*/ */ SupportRefillCalculationPanel() { initComponents(); jXCollapsiblePane1.setLayout(new BorderLayout()); jXCollapsiblePane1.add(jInfoScrollPane, BorderLayout.CENTER); jInfoTextPane.setText(GENERAL_INFO); StyledDocument doc = (StyledDocument) jTextPane1.getDocument(); Style defaultStyle = doc.addStyle("Default", null); StyleConstants.setItalic(defaultStyle, true); StyleConstants.setFontFamily(defaultStyle, "SansSerif"); dateFormat = new SimpleDateFormat("HH:mm:ss"); }
From source file:gda.gui.BatonPanel.java
private JTextPane getLogPanel() { if (logPanel == null) { logPanel = new JTextPane(); logPanel.setEditable(false);//from w w w. j a v a 2 s. com StyledDocument doc = logPanel.getStyledDocument(); Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE); Style regular = doc.addStyle("regular", def); StyleConstants.setFontFamily(def, "SansSerif"); Style s = doc.addStyle("italic", regular); StyleConstants.setItalic(s, true); s = doc.addStyle("bold", regular); StyleConstants.setBold(s, true); } return logPanel; }
From source file:ome.formats.importer.gui.GuiImporter.java
/** * This method appends data to the output window * /* w w w. j a va2 s. c o m*/ * @param s - text to append */ public void appendToOutput(String s) { try { StyledDocument doc = (StyledDocument) outputTextPane.getDocument(); Style style = doc.addStyle("StyleName", null); StyleConstants.setForeground(style, Color.black); StyleConstants.setFontFamily(style, "SansSerif"); StyleConstants.setFontSize(style, 12); StyleConstants.setBold(style, false); doc.insertString(doc.getLength(), s, style); //trim the document size so it doesn't grow to big int maxChars = 200000; if (doc.getLength() > maxChars) doc.remove(0, doc.getLength() - maxChars); //outputTextPane.setDocument(doc); } catch (BadLocationException e) { } }
From source file:ome.formats.importer.gui.GuiImporter.java
/** * This method appends data to the output window. * // w ww . j a va 2s . c o m * @param s - string to append */ public void appendToDebug(String s) { log.debug(s); try { StyledDocument doc = (StyledDocument) debugTextPane.getDocument(); Style style = doc.addStyle("StyleName", null); StyleConstants.setForeground(style, Color.black); StyleConstants.setFontFamily(style, "SansSerif"); StyleConstants.setFontSize(style, 12); StyleConstants.setBold(style, false); doc.insertString(doc.getLength(), s, style); //trim the document size so it doesn't grow to big int maxChars = 200000; if (doc.getLength() > maxChars) doc.remove(0, doc.getLength() - maxChars); //debugTextPane.setDocument(doc); } catch (BadLocationException e) { } }
From source file:org.astrojournal.logging.JTextPaneAppender.java
/** * Add the graphical JTextPane to capture the logging information. * //from ww w. ja v a 2 s. c om * @param textPane */ public static void addJTextPane(final JTextPane textPane) { // The application graphical output jTextPane = textPane; // Define JTextPane styles StyledDocument doc = jTextPane.getStyledDocument(); styleRegular = doc.addStyle("regular", null); StyleConstants.setForeground(styleRegular, Color.BLACK); StyleConstants.setFontSize(styleRegular, 12); StyleConstants.setFontFamily(styleRegular, "Arial"); styleBold = doc.addStyle("bold", styleRegular); StyleConstants.setBold(styleBold, true); styleItalic = doc.addStyle("italic", styleRegular); StyleConstants.setItalic(styleItalic, true); styleSmall = doc.addStyle("small", styleRegular); StyleConstants.setFontSize(styleSmall, 11); styleSmallItalic = doc.addStyle("smallItalic", styleSmall); StyleConstants.setItalic(styleSmallItalic, true); styleRed = doc.addStyle("red", styleBold); StyleConstants.setForeground(styleRed, Color.RED); styleBlue = doc.addStyle("blue", styleSmall); StyleConstants.setForeground(styleBlue, Color.BLUE); // Remove the Appender Console as the GUI is being initialised and // therefore having this information twice is not desirable. Logger logger = LogManager.getLogger("Console"); org.apache.logging.log4j.core.Logger coreLogger = (org.apache.logging.log4j.core.Logger) logger; LoggerContext context = coreLogger.getContext(); coreLogger.removeAppender(context.getConfiguration().getAppender("Console")); }
From source file:org.drugis.addis.gui.wizard.AddStudyWizard.java
public static void addStylesToDoc(StyledDocument doc) { //Initialize some styles. Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE); Style regular = doc.addStyle("regular", def); Style bold = doc.addStyle("bold", regular); StyleConstants.setBold(bold, true); // The image must first be wrapped in a style Style style = doc.addStyle("tip", null); StyleConstants.setIcon(style, Main.IMAGELOADER.getIcon(FileNames.ICON_TIP)); }
From source file:org.openmicroscopy.shoola.agents.fsimporter.view.ImporterUI.java
/** * Creates the component hosting the debug text. * /*from ww w . j ava 2 s. c o m*/ * @return See above. */ private JComponent createDebugTab() { debugTextPane = new JTextPane(); debugTextPane.setEditable(false); StyledDocument doc = (StyledDocument) debugTextPane.getDocument(); Style style = doc.addStyle(STYLE, null); StyleConstants.setForeground(style, Color.black); StyleConstants.setFontFamily(style, "SansSerif"); StyleConstants.setFontSize(style, 12); StyleConstants.setBold(style, false); JScrollPane sp = new JScrollPane(debugTextPane); sp.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent e) { try { debugTextPane.setCaretPosition(debugTextPane.getDocument().getLength()); } catch (IllegalArgumentException ex) { // } } }); JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.add(sp, BorderLayout.CENTER); return panel; }
From source file:org.openmicroscopy.shoola.util.ui.UIUtilities.java
/** Builds the UI component displaying the exception.*/ public static JTextPane buildExceptionArea() { StyleContext context = new StyleContext(); StyledDocument document = new DefaultStyledDocument(context); JTextPane textPane = new JTextPane(document); textPane.setOpaque(false);/* www. j a v a 2s . c o m*/ textPane.setEditable(false); // Create one of each type of tab stop List<TabStop> list = new ArrayList<TabStop>(); // Create a left-aligned tab stop at 100 pixels from the left margin float pos = 15; int align = TabStop.ALIGN_LEFT; int leader = TabStop.LEAD_NONE; TabStop tstop = new TabStop(pos, align, leader); list.add(tstop); // Create a right-aligned tab stop at 200 pixels from the left margin pos = 15; align = TabStop.ALIGN_RIGHT; leader = TabStop.LEAD_NONE; tstop = new TabStop(pos, align, leader); list.add(tstop); // Create a center-aligned tab stop at 300 pixels from the left margin pos = 15; align = TabStop.ALIGN_CENTER; leader = TabStop.LEAD_NONE; tstop = new TabStop(pos, align, leader); list.add(tstop); // Create a decimal-aligned tab stop at 400 pixels from the left margin pos = 15; align = TabStop.ALIGN_DECIMAL; leader = TabStop.LEAD_NONE; tstop = new TabStop(pos, align, leader); list.add(tstop); // Create a tab set from the tab stops TabSet tabs = new TabSet(list.toArray(new TabStop[0])); // Add the tab set to the logical style; // the logical style is inherited by all paragraphs Style style = textPane.getLogicalStyle(); StyleConstants.setTabSet(style, tabs); textPane.setLogicalStyle(style); Style debugStyle = document.addStyle("StyleName", null); StyleConstants.setForeground(debugStyle, Color.BLACK); StyleConstants.setFontFamily(debugStyle, "SansSerif"); StyleConstants.setFontSize(debugStyle, 12); StyleConstants.setBold(debugStyle, false); return textPane; }
From source file:org.quackbot.gui.GUIConsoleAppender.java
public void init() { //Init styles for (JTextPane curPane : ImmutableList.of(gui.BerrorLog, gui.CerrorLog)) { StyledDocument doc = curPane.getStyledDocument(); doc.addStyle("Normal", null); StyleConstants.setForeground(doc.addStyle("Class", null), Color.blue); StyleConstants.setForeground(doc.addStyle("Error", null), Color.red); //BotSend gets a better shade of orange than Color.organ gives StyleConstants.setForeground(doc.addStyle("BotSend", null), new Color(255, 127, 0)); //BotRecv gets a better shade of green than Color.green gives StyleConstants.setForeground(doc.addStyle("BotRecv", null), new Color(0, 159, 107)); StyleConstants.setBold(doc.addStyle("Server", null), true); StyleConstants.setItalic(doc.addStyle("Thread", null), true); StyleConstants.setItalic(doc.addStyle("Level", null), true); }//from ww w . ja va2 s.co m log.debug("Inited GUILogAppender, processing any saved messages"); synchronized (initMessageQueue) { inited = true; while (!initMessageQueue.isEmpty()) append(initMessageQueue.poll()); } }