List of usage examples for javax.swing.text StyleConstants setBold
public static void setBold(MutableAttributeSet a, boolean b)
From source file:com.xilinx.virtex7.MainScreen.java
public void initialize(LandingPage l, String imgName, int mode) { lp = l;// w w w . j av a 2 s . c o m blockDiagram = Toolkit.getDefaultToolkit() .getImage(getClass().getResource("/com/xilinx/virtex7/" + imgName)); led1 = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/com/xilinx/gui/green.png")); led2 = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/com/xilinx/gui/ledoff.png")); led3 = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/com/xilinx/gui/red.png")); this.mode = mode; setModeText(mode); dataMismatch0 = dataMismatch2 = errcnt0 = errcnt1 = false; dataMismatch4 = dataMismatch6 = errcnt2 = errcnt3 = false; di = null; di = new DriverInfo(); di.init(mode); int ret = di.get_PCIstate(); //ret = di.get_PowerStats(); test1_option = DriverInfo.ENABLE_LOOPBACK; test2_option = DriverInfo.ENABLE_LOOPBACK; test3_option = DriverInfo.ENABLE_LOOPBACK; test4_option = DriverInfo.ENABLE_LOOPBACK; // create a new jframe, and pack it frame = new JFrame("Virtex-7 XT Connectivity TRD Control & Monitoring Interface"); frame.pack(); frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); final int m = mode; frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { // check if tests are running or not if ((testStarted || testStarted1 || testStarted2 || testStarted3) && ((m != LandingPage.APPLICATION_MODE) || (m != LandingPage.APPLICATION_MODE_P2P))) { int confirmed = JOptionPane.showConfirmDialog(null, "This will stop the tests and uninstall the drivers. Do you want to continue?", "Exit", JOptionPane.YES_NO_OPTION); if (confirmed == JOptionPane.YES_OPTION) { if (testStarted) { di.stopTest(0, test1_option, Integer.parseInt(t1_psize.getText())); testStarted = false; } if (testStarted1) { di.stopTest(1, test2_option, Integer.parseInt(t2_psize.getText())); testStarted1 = false; } if (testStarted2) { di.stopTest(2, test3_option, Integer.parseInt(t3_psize.getText())); testStarted2 = false; } if (testStarted3) { di.stopTest(3, test4_option, Integer.parseInt(t4_psize.getText())); testStarted3 = false; } timer.cancel(); textArea.removeAll(); di.flush(); di = null; System.gc(); lp.uninstallDrivers(); showDialog("Removing Device Drivers...Please wait..."); } } else { int confirmed = JOptionPane.showConfirmDialog(null, "This will Uninstall the drivers. Do you want to continue?", "Exit", JOptionPane.YES_NO_OPTION); if (confirmed == JOptionPane.YES_OPTION) { timer.cancel(); textArea.removeAll(); di.flush(); di = null; System.gc(); lp.uninstallDrivers(); showDialog("Removing Device Drivers...Please wait..."); } } } }); // make the frame half the height and width Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); height = screenSize.height; width = screenSize.width; minWidth = 1000; minHeight = 600; minFrameWidth = 1024; minFrameHeight = 745; reqHeight = 745; if (width < 1280) reqWidth = 1024; else if (width == 1280) reqWidth = 1280; else if (width < 1600) { reqWidth = width - (width * 4) / 100; reqHeight = height - (height * 3) / 100; } else { reqWidth = reqHeight = height = height - (height * 10) / 100; } frame.setSize(new Dimension(minFrameWidth, minFrameHeight)); frame.setResizable(true); frame.addComponentListener(new ComponentListener() { @Override public void componentResized(ComponentEvent ce) { frame.setSize(new Dimension(Math.max(minFrameWidth, frame.getWidth()), Math.max(minFrameHeight, frame.getHeight()))); } @Override public void componentMoved(ComponentEvent ce) { //throw new UnsupportedOperationException("Not supported yet."); } @Override public void componentShown(ComponentEvent ce) { //throw new UnsupportedOperationException("Not supported yet."); } @Override public void componentHidden(ComponentEvent ce) { //throw new UnsupportedOperationException("Not supported yet."); } }); frame.setVisible(true); frame.setIconImage( Toolkit.getDefaultToolkit().getImage(getClass().getResource("/com/xilinx/virtex7/icon.png"))); // center the jframe on screen frame.setLocationRelativeTo(null); frame.setContentPane(createContentPane()); keyWord = new SimpleAttributeSet(); StyleConstants.setForeground(keyWord, Color.RED); StyleConstants.setBold(keyWord, true); logStatus = new SimpleAttributeSet(); StyleConstants.setForeground(logStatus, Color.BLACK); StyleConstants.setBold(logStatus, true); if ((mode == LandingPage.APPLICATION_MODE) || (mode == LandingPage.APPLICATION_MODE_P2P)) { testStarted = testStarted1 = testStarted2 = testStarted3 = true; } if (mode == LandingPage.PERFORMANCE_MODE_RAW) { t1_o1.setSelected(true); t1_o2.setEnabled(false); t1_o3.setEnabled(false); t2_o2.setEnabled(false); t2_o3.setEnabled(false); } if (mode == LandingPage.PERFORMANCE_MODE_RAW_DV) { t1_o2.setEnabled(false); t1_o3.setEnabled(false); t2_o2.setEnabled(false); t2_o3.setEnabled(false); t1_o1.setSelected(true); } // initialize max packet size ret = di.get_EngineState(); EngState[] engData = di.getEngState(); maxpkt0 = engData[0].MaxPktSize; minpkt0 = engData[0].MinPktSize; minpkt1 = engData[2].MinPktSize; maxpkt1 = engData[2].MaxPktSize; maxpkt2 = engData[4].MaxPktSize; minpkt2 = engData[4].MinPktSize; minpkt3 = engData[6].MinPktSize; maxpkt3 = engData[6].MaxPktSize; t1_psize.setText(String.valueOf(maxpkt0)); t2_psize.setText(String.valueOf(maxpkt1)); t3_psize.setText(String.valueOf(maxpkt2)); t4_psize.setText(String.valueOf(maxpkt3)); t1_psize.setToolTipText(minpkt0 + "-" + maxpkt0); t2_psize.setToolTipText(minpkt1 + "-" + maxpkt1); t3_psize.setToolTipText(minpkt2 + "-" + maxpkt2); t4_psize.setToolTipText(minpkt3 + "-" + maxpkt3); updateLog(di.getPCIInfo().getVersionInfo(), logStatus); updateLog("Configuration: " + modeText, logStatus); // LED status di.get_LedStats(); lstats = di.getLedStats(); setLedStats(lstats); // if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV) { t2_o1.setEnabled(true); t4_o1.setEnabled(true); } else { t2_o1.setEnabled(false); t4_o1.setEnabled(false); } t2_o2.setEnabled(false); t2_o3.setEnabled(false); t3_o2.setEnabled(false); t3_o3.setEnabled(false); t4_o2.setEnabled(false); t4_o3.setEnabled(false); startTimer(); }
From source file:net.sf.jabref.gui.plaintextimport.TextInputDialog.java
private void addStylesToDocument() { //Initialize some styles. Style defaultStyle = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE); Style regularStyle = document.addStyle("regular", defaultStyle); StyleConstants.setFontFamily(defaultStyle, "SansSerif"); StyleConstants.setFontSize(defaultStyle, Globals.prefs.getInt(JabRefPreferences.FONT_SIZE)); Style s = document.addStyle("used", regularStyle); StyleConstants.setBold(s, true); StyleConstants.setForeground(s, Color.blue); s = document.addStyle("marked", regularStyle); StyleConstants.setBold(s, true); StyleConstants.setForeground(s, Color.red); }
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 a2 s . c o m*/ 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 ww. j av a 2 s. com * @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. * /*from ww w .j av a2 s. 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 w w w.j a v a2 s . c o m*/ * @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.nuxeo.launcher.gui.ColoredTextPane.java
/** * Append text at the end of document, choosing foreground and background colors, and bold attribute. * * @param text Text to append//from w w w . ja va 2 s .c o m * @param color Foreground color * @param bgColor Background color * @param isBold Is the text bold ? */ public void append(String text, Color color, Color bgColor, boolean isBold) { StyleConstants.setForeground(style, color); StyleConstants.setBackground(style, bgColor); StyleConstants.setBold(style, isBold); int len = doc.getLength(); try { doc.insertString(len, text + "\n", style); if (maxSize > 0 && len > maxSize) { doc.remove(0, len - maxSize); } } catch (BadLocationException e) { log.error(e); } if (follow) { setCaretPosition(doc.getLength()); } }
From source file:org.openmicroscopy.shoola.agents.fsimporter.view.ImporterUI.java
/** * Creates the component hosting the debug text. * // w w w . j a v a 2s . co 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);//from www. j ava 2 s . c om 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; }