List of usage examples for javax.swing.text SimpleAttributeSet SimpleAttributeSet
public SimpleAttributeSet()
From source file:com.adito.upgrade.GUIUpgrader.java
void appendString(String message, Color c) { Document doc = console.getDocument(); if (doc.getLength() != 0) { message = "\n" + message; }// w ww. ja v a 2 s . c om SimpleAttributeSet attr = new SimpleAttributeSet(); StyleConstants.setForeground(attr, c); try { doc.insertString(doc.getLength(), message, attr); } catch (Exception e) { } console.setCaretPosition(doc.getLength()); console.scrollRectToVisible(console.getVisibleRect()); }
From source file:com.xilinx.virtex7.MainScreen.java
public void initialize(LandingPage l, String imgName, int mode) { lp = l;// w w w .j av a2 s . com 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:de.codesourcery.jasm16.utils.ASTInspector.java
private static SimpleAttributeSet createStyle(Color color) { SimpleAttributeSet result = new SimpleAttributeSet(); StyleConstants.setForeground(result, color); return result; }
From source file:de.codesourcery.jasm16.utils.ASTInspector.java
public ASTInspector() { defaultStyle = new SimpleAttributeSet(); errorStyle = createStyle(Color.RED); registerStyle = createStyle(Color.ORANGE); commentStyle = createStyle(Color.DARK_GRAY); instructionStyle = createStyle(Color.BLUE); labelStyle = createStyle(Color.GREEN); preProcessorStyle = createStyle(new Color(200, 200, 200)); }
From source file:com.hexidec.ekit.component.RelativeImageView.java
/** Change the size of this image. This alters the HEIGHT and WIDTH * attributes of the Element and causes a re-layout. *///from www . j a va 2s .co m protected void resize(int width, int height) { if ((width == fWidth) && (height == fHeight)) { return; } fWidth = width; fHeight = height; // Replace attributes in document MutableAttributeSet attr = new SimpleAttributeSet(); attr.addAttribute(HTML.Attribute.WIDTH, Integer.toString(width)); attr.addAttribute(HTML.Attribute.HEIGHT, Integer.toString(height)); ((StyledDocument) getDocument()).setCharacterAttributes(fElement.getStartOffset(), fElement.getEndOffset(), attr, false); }
From source file:de.codesourcery.jasm16.ide.ui.views.SourceCodeView.java
public SourceCodeView(IResourceResolver resourceResolver, IWorkspace workspace, NavigationHistory navigationHistory, boolean isEditable) { if (workspace == null) { throw new IllegalArgumentException("workspace must not be null"); }//from w w w .j a va 2s.c om if (resourceResolver == null) { throw new IllegalArgumentException("resourceResolver must not be NULL."); } this.navigationHistory = navigationHistory; this.resourceResolver = resourceResolver; this.editable = isEditable; this.workspace = workspace; defaultStyle = new SimpleAttributeSet(); errorStyle = createStyle(Color.RED); registerStyle = createStyle(Color.ORANGE); commentStyle = createStyle(Color.WHITE); macroDefinitionStyle = createStyle(Color.YELLOW); macroInvocationStyle = createStyle(Color.YELLOW); instructionStyle = createStyle(new Color(50, 186, 223)); labelStyle = createStyle(new Color(237, 237, 81)); preProcessorStyle = createStyle(new Color(200, 200, 200)); workspace.addWorkspaceListener(workspaceListener); navigationHistory.addListener(navigationHistoryListener); }
From source file:dylemator.DylematorUI.java
private void displayCenteredText(String text) { textArea.setText(""); text = "\n\n\n" + text; SimpleAttributeSet attribs = new SimpleAttributeSet(); if (sd == null) sd = new SettingsDialog(this, true); float fnt = sd.getFontSize(); StyledDocument doc = (StyledDocument) textArea.getDocument(); Style style = doc.getStyle(StyleContext.DEFAULT_STYLE);//doc.addStyle("MyStyle",null); StyleConstants.setFontSize(style, (int) fnt); StyleConstants.setLineSpacing(attribs, 0.5f); StyleConstants.setFontFamily(style, "Segoe UI"); StyleConstants.setAlignment(attribs, StyleConstants.ALIGN_CENTER); textArea.setParagraphAttributes(attribs, true); try {/* w ww . j a va2 s .c om*/ doc.insertString(doc.getLength(), text, style); doc.setParagraphAttributes(0, doc.getLength() - 1, attribs, false); } catch (BadLocationException ex) { Logger.getLogger(DylematorUI.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.rapidminer.gui.properties.RegexpPropertyDialog.java
/** * Sets the text of the search field./*from w w w . ja va 2s. co m*/ * * @param text */ public void setSearchFieldText(String text) { try { this.inlineSearchDocument.insertString(0, text, new SimpleAttributeSet()); } catch (BadLocationException e) { } }
From source file:com.sec.ose.osi.ui.frm.main.identification.codematch.JPanCodeMatchMain.java
private void markMySourceSnippet() { MutableAttributeSet attr = new SimpleAttributeSet(); StyleConstants.setBackground(attr, new Color(255, 255, 180)); startMySourceMatchPos.clear();//w w w . j a v a 2 s. com endMySourceMatchPos.clear(); String projectName = IdentifyMediator.getInstance().getSelectedProjectName(); File mySourceCode = new File(protexSDK.getSourceLocation(projectName) + File.separator + currentFileName); if (mySourceCode.exists()) { FileReader fr = null; try { fr = new FileReader(mySourceCode); BufferedReader br = new BufferedReader(fr); String tmpStr = null; int curLine = 1; int curTextSize = 0; while ((tmpStr = br.readLine()) != null) { setMySourceMatchLine(curLine, curTextSize); curTextSize += tmpStr.length() + 1; curLine++; } totalLine = curLine - 1; setMySourceMatchLine(curLine, curTextSize); } catch (Exception e) { log.warn(e); } finally { try { if (fr != null) { fr.close(); } } catch (Exception e) { log.warn(e); } } getJPanMatchedSourceViewLeft().clearStyle(); if (startMySourceMatchPos.size() > endMySourceMatchPos.size()) endMySourceMatchPos .add(getJPanMatchedSourceViewLeft().getStyledDocumentForSourcePane().getLength()); int snippetCnt = startMySourceMatchPos.size(); if (snippetCnt > 0) { for (int i = 0; i < snippetCnt; i++) { int offset = startMySourceMatchPos.get(i); int length = endMySourceMatchPos.get(i) - offset; getJPanMatchedSourceViewLeft().getStyledDocumentForSourcePane().setCharacterAttributes(offset, length, attr, true); } getJPanMatchedSourceViewLeft().getJTextPaneSourceView() .setCaretPosition(startMySourceMatchPos.get(0)); } } }
From source file:org.apache.ftpserver.gui.LoggerPanel.java
/** * Constructor - set the container.//w w w. ja va 2 s. co m */ public LoggerPanel(PluginPanelContainer container) { super(container); // create style attributes m_debugAttr = new SimpleAttributeSet(); StyleConstants.setForeground(m_debugAttr, COLOR_DEBUG); m_infoAttr = new SimpleAttributeSet(); StyleConstants.setForeground(m_infoAttr, COLOR_INFO); m_warnAttr = new SimpleAttributeSet(); StyleConstants.setForeground(m_warnAttr, COLOR_WARN); m_errorAttr = new SimpleAttributeSet(); StyleConstants.setForeground(m_errorAttr, COLOR_ERROR); initComponents(); }