Example usage for java.awt Font BOLD

List of usage examples for java.awt Font BOLD

Introduction

In this page you can find the example usage for java.awt Font BOLD.

Prototype

int BOLD

To view the source code for java.awt Font BOLD.

Click Source Link

Document

The bold style constant.

Usage

From source file:JColorChooserSample.java

public static void main(String args[]) {
    JFrame frame = new JFrame("JColorChooser Popup");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    final JLabel label = new JLabel("www.java2s.com", JLabel.CENTER);
    label.setFont(new Font("Serif", Font.BOLD | Font.ITALIC, 48));
    frame.add(label, BorderLayout.SOUTH);

    final JColorChooser colorChooser = new JColorChooser(label.getBackground());
    colorChooser.setBorder(BorderFactory.createTitledBorder("Pick Foreground Color"));

    frame.add(colorChooser, BorderLayout.CENTER);

    frame.pack();/*from  w ww  .j  a v a 2s. c o m*/
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(String[] a) {

    final JColorChooser colorChooser = new JColorChooser();
    final JLabel previewLabel = new JLabel("I Love Swing", JLabel.CENTER);
    previewLabel.setFont(new Font("Serif", Font.BOLD | Font.ITALIC, 48));
    previewLabel.setSize(previewLabel.getPreferredSize());
    previewLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 1, 0));
    colorChooser.setPreviewPanel(previewLabel);

    ActionListener okActionListener = new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            System.out.println("OK Button");
            System.out.println(colorChooser.getColor());
        }//from w  ww .  j a  v  a  2 s .c o  m
    };

    ActionListener cancelActionListener = new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            System.out.println("Cancel Button");
        }
    };

    final JDialog dialog = JColorChooser.createDialog(null, "Change Button Background", true, colorChooser,
            okActionListener, cancelActionListener);

    dialog.setVisible(true);
}

From source file:MainClass.java

public static void main(String args[]) throws Exception {

    JFrame frame = new JFrame("Number Input");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Font font = new Font("SansSerif", Font.BOLD, 16);

    JLabel label;//from w w  w  .j  a  va  2  s .com
    JFormattedTextField input;
    JPanel panel;

    BoxLayout layout = new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS);
    frame.setLayout(layout);

    Format number = NumberFormat.getNumberInstance(Locale.FRENCH);
    label = new JLabel("French Number:");
    input = new JFormattedTextField(number);
    input.setValue(2424.50);
    input.setColumns(20);
    input.setFont(font);
    panel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    panel.add(label);
    panel.add(input);
    frame.add(panel);

    frame.pack();
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(String args[]) throws Exception {

    JFrame frame = new JFrame("Number Input");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Font font = new Font("SansSerif", Font.BOLD, 16);

    JLabel label;//from w ww  .  j  av a 2s. co  m
    JFormattedTextField input;
    JPanel panel;

    BoxLayout layout = new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS);
    frame.setLayout(layout);

    Format integer = NumberFormat.getIntegerInstance(Locale.ITALIAN);
    label = new JLabel("Italian integer:");
    input = new JFormattedTextField(integer);
    input.setValue(2424.50);
    input.setColumns(20);
    input.setFont(font);
    panel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    panel.add(label);
    panel.add(input);
    frame.add(panel);

    frame.pack();
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(String args[]) throws Exception {

    JFrame frame = new JFrame("Number Input");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Font font = new Font("SansSerif", Font.BOLD, 16);

    JLabel label;/*ww w  . ja v a 2  s  .co  m*/
    JFormattedTextField input;
    JPanel panel;

    BoxLayout layout = new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS);
    frame.setLayout(layout);

    Format currency = NumberFormat.getCurrencyInstance(Locale.UK);
    label = new JLabel("UK Currency:");
    input = new JFormattedTextField(currency);
    input.setValue(2424.50);
    input.setColumns(20);
    input.setFont(font);
    panel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    panel.add(label);
    panel.add(input);
    frame.add(panel);

    frame.pack();
    frame.setVisible(true);
}

From source file:FileSamplePanel.java

public static void main(String args[]) {
    JFrame frame = new JFrame("JFileChooser Popup");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    final JLabel directoryLabel = new JLabel(" ");
    directoryLabel.setFont(new Font("Serif", Font.BOLD | Font.ITALIC, 36));
    frame.add(directoryLabel, BorderLayout.NORTH);

    final JLabel filenameLabel = new JLabel(" ");
    filenameLabel.setFont(new Font("Serif", Font.BOLD | Font.ITALIC, 36));
    frame.add(filenameLabel, BorderLayout.SOUTH);

    JFileChooser fileChooser = new JFileChooser(".");
    fileChooser.setControlButtonsAreShown(false);
    frame.add(fileChooser, BorderLayout.CENTER);

    //  Create ActionListener
    ActionListener actionListener = new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            JFileChooser theFileChooser = (JFileChooser) actionEvent.getSource();
            String command = actionEvent.getActionCommand();
            if (command.equals(JFileChooser.APPROVE_SELECTION)) {
                File selectedFile = theFileChooser.getSelectedFile();
                directoryLabel.setText(selectedFile.getParent());
                filenameLabel.setText(selectedFile.getName());
            } else if (command.equals(JFileChooser.CANCEL_SELECTION)) {
                directoryLabel.setText(" ");
                filenameLabel.setText(" ");
            }/*  ww w  .  ja  va 2 s .  c o  m*/
        }
    };
    fileChooser.addActionListener(actionListener);

    frame.pack();
    frame.setVisible(true);
}

From source file:NumberInputSampleLocaleUK.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Number Input");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Font font = new Font("SansSerif", Font.BOLD, 16);

    JLabel label;/*w  w w  . j  a v a  2s  . c o  m*/
    JFormattedTextField input;
    JPanel panel;

    BoxLayout layout = new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS);
    frame.setLayout(layout);

    Format currency = NumberFormat.getCurrencyInstance(Locale.UK);
    label = new JLabel("UK Currency:");
    input = new JFormattedTextField(currency);
    input.setValue(2424.50);
    input.setColumns(20);
    input.setFont(font);

    panel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    panel.add(label);
    panel.add(input);
    frame.add(panel);

    frame.add(new JTextField());
    frame.pack();
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Changed Renderer");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JTree tree = new JTree();
    DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) tree.getCellRenderer();

    renderer.setFont(new Font("Dialog", Font.BOLD | Font.ITALIC, 32));
    int rowHeight = tree.getRowHeight();
    if (rowHeight <= 0) {
        tree.setRowHeight(rowHeight - 1);
    }/*from ww w. java  2s  . c  om*/

    Color backgroundSelection = renderer.getBackgroundSelectionColor();
    renderer.setBackgroundSelectionColor(Color.blue);
    renderer.setBackgroundNonSelectionColor(backgroundSelection);

    // Swap text colors
    Color textSelection = renderer.getTextSelectionColor();
    renderer.setTextSelectionColor(Color.green);
    renderer.setTextNonSelectionColor(textSelection);

    JScrollPane scrollPane = new JScrollPane(tree);
    frame.add(scrollPane, BorderLayout.CENTER);
    frame.setSize(300, 150);
    frame.setVisible(true);
}

From source file:NumberInputNumberFormatgetInstance.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Number Input");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Font font = new Font("SansSerif", Font.BOLD, 16);

    JLabel label;//  w w  w . j a v a  2 s  .co  m
    JFormattedTextField input;
    JPanel panel;

    BoxLayout layout = new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS);
    frame.setLayout(layout);

    Format general = NumberFormat.getInstance();
    label = new JLabel("General/Instance:");
    input = new JFormattedTextField(general);
    input.setValue(2424.50);
    input.setColumns(20);
    input.setFont(font);

    panel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    panel.add(label);
    panel.add(input);
    frame.add(panel);

    frame.add(new JTextField());
    frame.pack();
    frame.setVisible(true);
}

From source file:NumberFormatgetNumberInstanceLocaleFRENCH.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Number Input");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Font font = new Font("SansSerif", Font.BOLD, 16);

    JLabel label;// ww  w.  j a v a 2s .com
    JFormattedTextField input;
    JPanel panel;

    BoxLayout layout = new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS);
    frame.setLayout(layout);

    Format number = NumberFormat.getNumberInstance(Locale.FRENCH);
    label = new JLabel("French Number:");
    input = new JFormattedTextField(number);
    input.setValue(2424.50);
    input.setColumns(20);
    input.setFont(font);

    panel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    panel.add(label);
    panel.add(input);
    frame.add(panel);

    frame.add(new JTextField());
    frame.pack();
    frame.setVisible(true);
}