List of usage examples for javax.swing.text StyleConstants setForeground
public static void setForeground(MutableAttributeSet a, Color fg)
From source file:multiplayer.pong.client.LobbyFrame.java
private void displayHelp(String message) { SimpleAttributeSet set = new SimpleAttributeSet(); StyleConstants.setBold(set, true); StyleConstants.setForeground(set, new Color(48, 140, 38)); if (message == null) appendMessage("Instructions:\n" + "/aide : Affiche ce menu\n" + "/ajouter [nom] : Envoie une demande d'ajout un joueur\n" + "/accepterAmi [nom] : Accepte une demande d'ajout reue\n" + "/m [nom] [message] : envoie un message priv un ami connect\n" + "/challenge [nom] : Invite un ami une partie de Pong\n" + "/supprimer [nom] : Supprime le joueur de votre liste d'amis\n", set); else//w w w . j a va 2 s.c om appendMessage(message, set); }
From source file:multiplayer.pong.client.LobbyFrame.java
private void displayError(String error) { SimpleAttributeSet set = new SimpleAttributeSet(); StyleConstants.setBold(set, true); StyleConstants.setForeground(set, new Color(245, 10, 10)); appendMessage(error, set);// w ww. j a va2s . com }
From source file:multiplayer.pong.client.LobbyFrame.java
private void displayWarning(String message) { SimpleAttributeSet set = new SimpleAttributeSet(); StyleConstants.setBold(set, true); StyleConstants.setForeground(set, new Color(255, 178, 46)); appendMessage(message, set);// w w w . ja va 2s . c o m }
From source file:multiplayer.pong.client.LobbyFrame.java
private void displayNotification(String message) { SimpleAttributeSet set = new SimpleAttributeSet(); StyleConstants.setBold(set, true); StyleConstants.setForeground(set, new Color(81, 20, 237)); appendMessage(message, set);/*from w w w.j av a2 s .c om*/ }
From source file:TextComponentDemo.java
protected SimpleAttributeSet[] initAttributes(int length) { // Hard-code some attributes. SimpleAttributeSet[] attrs = new SimpleAttributeSet[length]; attrs[0] = new SimpleAttributeSet(); StyleConstants.setFontFamily(attrs[0], "SansSerif"); StyleConstants.setFontSize(attrs[0], 16); attrs[1] = new SimpleAttributeSet(attrs[0]); StyleConstants.setBold(attrs[1], true); attrs[2] = new SimpleAttributeSet(attrs[0]); StyleConstants.setItalic(attrs[2], true); attrs[3] = new SimpleAttributeSet(attrs[0]); StyleConstants.setFontSize(attrs[3], 20); attrs[4] = new SimpleAttributeSet(attrs[0]); StyleConstants.setFontSize(attrs[4], 12); attrs[5] = new SimpleAttributeSet(attrs[0]); StyleConstants.setForeground(attrs[5], Color.red); return attrs; }
From source file:com.xilinx.kintex7.MainScreen.java
public void initialize(LandingPage l, String imgName, int mode) { lp = l;//from www . j a va 2s. co m blockDiagram = Toolkit.getDefaultToolkit() .getImage(getClass().getResource("/com/xilinx/kintex7/" + 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; 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; // create a new jframe, and pack it frame = new JFrame("Kintex-7 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) && ((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; } 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 = 700; 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/kintex7/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 = 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; t1_psize.setText(String.valueOf(maxpkt0)); t2_psize.setText(String.valueOf(maxpkt1)); t1_psize.setToolTipText(minpkt0 + "-" + maxpkt0); t2_psize.setToolTipText(minpkt1 + "-" + maxpkt1); updateLog(di.getPCIInfo().getVersionInfo(), logStatus); updateLog("Configuration: " + modeText, logStatus); // LED status di.get_LedStats(); lstats = di.getLedStats(); setLedStats(lstats); startTimer(); }
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 w w . j ava 2s.com 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:TextComponentDemo.java
protected SimpleAttributeSet[] initAttributes(int length) { //Hard-code some attributes. SimpleAttributeSet[] attrs = new SimpleAttributeSet[length]; attrs[0] = new SimpleAttributeSet(); StyleConstants.setFontFamily(attrs[0], "SansSerif"); StyleConstants.setFontSize(attrs[0], 16); attrs[1] = new SimpleAttributeSet(attrs[0]); StyleConstants.setBold(attrs[1], true); attrs[2] = new SimpleAttributeSet(attrs[0]); StyleConstants.setItalic(attrs[2], true); attrs[3] = new SimpleAttributeSet(attrs[0]); StyleConstants.setFontSize(attrs[3], 20); attrs[4] = new SimpleAttributeSet(attrs[0]); StyleConstants.setFontSize(attrs[4], 12); attrs[5] = new SimpleAttributeSet(attrs[0]); StyleConstants.setForeground(attrs[5], Color.red); return attrs; }
From source file:com.xilinx.virtex7.MainScreen.java
public void initialize(LandingPage l, String imgName, int mode) { lp = l;// w w w.ja v a 2 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; }