Example usage for javax.swing.text StyleConstants setBold

List of usage examples for javax.swing.text StyleConstants setBold

Introduction

In this page you can find the example usage for javax.swing.text StyleConstants setBold.

Prototype

public static void setBold(MutableAttributeSet a, boolean b) 

Source Link

Document

Sets the bold attribute.

Usage

From source file:FontPicker.java

public void actionPerformed(ActionEvent ae) {
    // Check the name of the font
    if (!StyleConstants.getFontFamily(attributes).equals(fontName.getSelectedItem())) {
        StyleConstants.setFontFamily(attributes, (String) fontName.getSelectedItem());
    }/*w ww  .j a va 2s.  co m*/
    // Check the font size (no error checking yet)
    if (StyleConstants.getFontSize(attributes) != Integer.parseInt(fontSize.getText())) {
        StyleConstants.setFontSize(attributes, Integer.parseInt(fontSize.getText()));
    }
    // Check to see if the font should be bold
    if (StyleConstants.isBold(attributes) != fontBold.isSelected()) {
        StyleConstants.setBold(attributes, fontBold.isSelected());
    }
    // Check to see if the font should be italic
    if (StyleConstants.isItalic(attributes) != fontItalic.isSelected()) {
        StyleConstants.setItalic(attributes, fontItalic.isSelected());
    }
    // and update our preview label
    updatePreviewFont();
}

From source file:eu.ggnet.dwoss.redtape.document.DocumentUpdateView.java

/**
 * Refreshes the Areas contant if changes occur.
 *///from   w ww  .ja  v  a 2 s  .c  om
public final void refreshAddressArea() {
    addressesArea.setText("");
    StyledDocument doc = addressesArea.getStyledDocument();
    Style boldStyle = addressesArea.addStyle("bold", null);
    StyleConstants.setBold(boldStyle, true);
    try {
        if (document.getInvoiceAddress().getDescription()
                .equals(document.getShippingAddress().getDescription())) {
            doc.insertString(doc.getLength(), "Rechnungs und Lieferadresse:\n", boldStyle);
            doc.insertString(doc.getLength(), document.getInvoiceAddress().getDescription(), null);
        } else {
            doc.insertString(doc.getLength(), "Rechnungsadresse:\n", boldStyle);
            doc.insertString(doc.getLength(), document.getInvoiceAddress().getDescription(), null);
            doc.insertString(doc.getLength(), "\n\nLieferadresse:\n", boldStyle);
            doc.insertString(doc.getLength(), document.getShippingAddress().getDescription(), null);
        }
    } catch (BadLocationException ex) {
        addressesArea.setText("Rechnungsadresse:\n" + document.getInvoiceAddress().getDescription()
                + "\n\nLieferAdresse:\n" + document.getShippingAddress().getDescription());
    }
}

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 v  a 2s  .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);//from w w  w  . j a v  a2 s .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);//from w w  w  . ja  v a 2 s.  c om
}

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  a  va 2s  . c  o m
}

From source file:TextSamplerDemo.java

protected void addStylesToDocument(StyledDocument doc) {
    //Initialize some styles.
    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);

    s = doc.addStyle("small", regular);
    StyleConstants.setFontSize(s, 10);

    s = doc.addStyle("large", regular);
    StyleConstants.setFontSize(s, 16);

    s = doc.addStyle("icon", regular);
    StyleConstants.setAlignment(s, StyleConstants.ALIGN_CENTER);
    ImageIcon pigIcon = createImageIcon("images/Pig.gif", "a cute pig");
    if (pigIcon != null) {
        StyleConstants.setIcon(s, pigIcon);
    }/*from ww  w .  j  a v a2  s.c  o m*/

    s = doc.addStyle("button", regular);
    StyleConstants.setAlignment(s, StyleConstants.ALIGN_CENTER);
    ImageIcon soundIcon = createImageIcon("images/sound.gif", "sound icon");
    JButton button = new JButton();
    if (soundIcon != null) {
        button.setIcon(soundIcon);
    } else {
        button.setText("BEEP");
    }
    button.setCursor(Cursor.getDefaultCursor());
    button.setMargin(new Insets(0, 0, 0, 0));
    button.setActionCommand(buttonString);
    button.addActionListener(this);
    StyleConstants.setComponent(s, button);
}

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   w w w.  j  a  va2s  .c  o 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: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;
}