Example usage for javax.swing.border TitledBorder setTitleColor

List of usage examples for javax.swing.border TitledBorder setTitleColor

Introduction

In this page you can find the example usage for javax.swing.border TitledBorder setTitleColor.

Prototype

public void setTitleColor(Color titleColor) 

Source Link

Document

Sets the title-color of the titled border.

Usage

From source file:Main.java

public static JPanel placeInTitledEtchedJPanel(Component c, String title, Color titleColor) {
    JPanel parent = new JPanel(new BorderLayout());
    parent.add(c, BorderLayout.CENTER);
    TitledBorder tb = new TitledBorder(title);
    tb.setBorder(BorderFactory.createEtchedBorder());
    tb.setTitleColor(titleColor);
    parent.setBorder(tb);/*ww  w  .j  av  a 2  s  .  c  o m*/
    return parent;
}

From source file:com.intel.stl.ui.common.view.ComponentFactory.java

public static TitledBorder createTitledBorder(String title) {
    TitledBorder res = BorderFactory.createTitledBorder(title);
    res.setTitleColor(UIConstants.INTEL_DARK_GRAY);
    // res.setTitleFont(UIConstants.H4_FONT);
    return res;/*from w w  w .  j a  va2 s.  co  m*/
}

From source file:BoxAlignmentDemo.java

protected JPanel createLabelAndComponent(boolean doItRight) {
    JPanel pane = new JPanel();

    JComponent component = new JPanel();
    Dimension size = new Dimension(150, 100);
    component.setMaximumSize(size);/* www. ja  va  2  s. c  o m*/
    component.setPreferredSize(size);
    component.setMinimumSize(size);
    TitledBorder border = new TitledBorder(new LineBorder(Color.black), "A JPanel", TitledBorder.CENTER,
            TitledBorder.BELOW_TOP);
    border.setTitleColor(Color.black);
    component.setBorder(border);

    JLabel label = new JLabel("This is a JLabel");
    String title;
    if (doItRight) {
        title = "Matched";
        label.setAlignmentX(CENTER_ALIGNMENT);
    } else {
        title = "Mismatched";
    }

    pane.setBorder(BorderFactory.createTitledBorder(title));
    pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS));
    pane.add(label);
    pane.add(component);
    return pane;
}

From source file:BoxAlignmentDemo.java

protected JPanel createYAlignmentExample(boolean doItRight) {
    JPanel pane = new JPanel();
    String title;/*from  www .j ava 2s .co m*/

    JComponent component1 = new JPanel();
    Dimension size = new Dimension(100, 50);
    component1.setMaximumSize(size);
    component1.setPreferredSize(size);
    component1.setMinimumSize(size);
    TitledBorder border = new TitledBorder(new LineBorder(Color.black), "A JPanel", TitledBorder.CENTER,
            TitledBorder.BELOW_TOP);
    border.setTitleColor(Color.black);
    component1.setBorder(border);

    JComponent component2 = new JPanel();
    size = new Dimension(100, 50);
    component2.setMaximumSize(size);
    component2.setPreferredSize(size);
    component2.setMinimumSize(size);
    border = new TitledBorder(new LineBorder(Color.black), "A JPanel", TitledBorder.CENTER,
            TitledBorder.BELOW_TOP);
    border.setTitleColor(Color.black);
    component2.setBorder(border);

    if (doItRight) {
        title = "Matched";
    } else {
        component1.setAlignmentY(TOP_ALIGNMENT);
        title = "Mismatched";
    }

    pane.setBorder(BorderFactory.createTitledBorder(title));
    pane.setLayout(new BoxLayout(pane, BoxLayout.X_AXIS));
    pane.add(component1);
    pane.add(component2);
    return pane;
}

From source file:com.att.aro.ui.view.menu.tools.RegexWizard.java

private JTextArea createTextAreaAndProperties(String title) {
    JTextArea textArea = new JTextArea();
    textArea.setLineWrap(true);/*w  w w  .j a  v  a2  s  .  c  o m*/
    TitledBorder ttlBorder = BorderFactory.createTitledBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder()), title);
    ttlBorder.setTitleColor(Color.BLUE);
    ttlBorder.setTitleFont(ttlBorder.getTitleFont().deriveFont(Font.BOLD));
    textArea.setBorder(ttlBorder);
    textArea.addFocusListener(this);
    return textArea;
}

From source file:org.genedb.jogra.plugins.TermRationaliser.java

/**
 * Return a new JFrame which is the main interface to the Rationaliser.
 *///from w  w w. ja  va2 s.c  o m
public JFrame getMainPanel() {

    /* JFRAME */
    frame.setTitle(WINDOW_TITLE);
    frame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
    frame.setLayout(new BorderLayout());

    /* MENU */
    JMenuBar menuBar = new JMenuBar();

    JMenu actions_menu = new JMenu("Actions");
    JMenuItem actions_mitem_1 = new JMenuItem("Refresh lists");
    actions_mitem_1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            initModels();
        }
    });
    actions_menu.add(actions_mitem_1);

    JMenu about_menu = new JMenu("About");
    JMenuItem about_mitem_1 = new JMenuItem("About");
    about_mitem_1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            JOptionPane.showMessageDialog(null,
                    "Term Rationaliser \n" + "Wellcome Trust Sanger Institute, UK \n" + "2009",
                    "Term Rationaliser", JOptionPane.PLAIN_MESSAGE);
        }
    });
    about_menu.add(about_mitem_1);

    menuBar.add(about_menu);
    menuBar.add(actions_menu);
    frame.add(menuBar, BorderLayout.NORTH);

    /* MAIN BOX */
    Box center = Box.createHorizontalBox(); //A box that displays contents from left to right
    center.add(Box.createHorizontalStrut(5)); //Invisible fixed-width component

    /* FROM LIST AND PANEL */
    fromList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); //Allow multiple products to be selected 
    fromList.addKeyListener(new KeyListener() {
        @Override
        public void keyPressed(KeyEvent arg0) {
            if (arg0.getKeyCode() == KeyEvent.VK_RIGHT) {
                synchroniseLists(fromList, toList); //synchronise from left to right
            }
        }

        @Override
        public void keyReleased(KeyEvent arg0) {
        }

        @Override
        public void keyTyped(KeyEvent arg0) {
        }
    });

    Box fromPanel = this.createRationaliserPanel(FROM_LIST_NAME, fromList); //Box on left hand side
    fromPanel.add(Box.createVerticalStrut(55)); //Add some space
    center.add(fromPanel); //Add to main box
    center.add(Box.createHorizontalStrut(3)); //Add some space

    /* MIDDLE PANE */
    Box middlePane = Box.createVerticalBox();

    ClassLoader classLoader = this.getClass().getClassLoader(); //Needed to access the images later on
    ImageIcon leftButtonIcon = new ImageIcon(classLoader.getResource("left_arrow.gif"));
    ImageIcon rightButtonIcon = new ImageIcon(classLoader.getResource("right_arrow.gif"));

    leftButtonIcon = new ImageIcon(leftButtonIcon.getImage().getScaledInstance(20, 20, Image.SCALE_SMOOTH)); //TODO: Investigate simpler way to resize an icon!
    rightButtonIcon = new ImageIcon(rightButtonIcon.getImage().getScaledInstance(20, 20, Image.SCALE_SMOOTH)); //TODO: Investigate simpler way to resize an icon!

    JButton rightSynch = new JButton(rightButtonIcon);
    rightSynch.setToolTipText("Synchronise TO list. \n Shortcut: Right-arrow key");

    rightSynch.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            synchroniseLists(fromList, toList);
        }
    });

    JButton leftSynch = new JButton(leftButtonIcon);
    leftSynch.setToolTipText("Synchronise FROM list. \n Shortcut: Left-arrow key");

    leftSynch.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            synchroniseLists(toList, fromList);
        }
    });

    middlePane.add(rightSynch);
    middlePane.add(leftSynch);

    center.add(middlePane); //Add middle pane to main box
    center.add(Box.createHorizontalStrut(3));

    /* TO LIST AND PANEL */
    toList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); //Single product selection in TO list
    toList.addKeyListener(new KeyListener() {
        @Override
        public void keyPressed(KeyEvent arg0) {
            if (arg0.getKeyCode() == KeyEvent.VK_LEFT) {
                synchroniseLists(toList, fromList); //synchronise from right to left
            }
        }

        @Override
        public void keyReleased(KeyEvent arg0) {
        }

        @Override
        public void keyTyped(KeyEvent arg0) {
        }
    });

    Box toPanel = this.createRationaliserPanel(TO_LIST_NAME, toList);

    Box newTerm = Box.createVerticalBox();

    textField = new JTextArea(1, 1); //textfield to let the user edit the name of an existing term
    textField.setMaximumSize(new Dimension(Toolkit.getDefaultToolkit().getScreenSize().height, 10));

    textField.setForeground(Color.BLUE);
    JScrollPane jsp = new JScrollPane(textField); //scroll pane so that there is a horizontal scrollbar
    jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

    newTerm.add(jsp);
    TitledBorder editBorder = BorderFactory.createTitledBorder("Edit term name");
    editBorder.setTitleColor(Color.DARK_GRAY);
    newTerm.setBorder(editBorder);
    toPanel.add(newTerm); //add textfield to panel

    center.add(toPanel); //add panel to main box
    center.add(Box.createHorizontalStrut(5));

    frame.add(center); //add the main panel to the frame

    initModels(); //load the lists with data

    /* BOTTOM HALF OF FRAME */
    Box main = Box.createVerticalBox();
    TitledBorder border = BorderFactory.createTitledBorder("Information");
    border.setTitleColor(Color.DARK_GRAY);

    /* INFORMATION BOX */
    Box info = Box.createVerticalBox();

    Box scope = Box.createHorizontalBox();
    scope.add(Box.createHorizontalStrut(5));
    scope.add(scopeLabel); //label showing the scope of the terms
    scope.add(Box.createHorizontalGlue());

    Box productCount = Box.createHorizontalBox();
    productCount.add(Box.createHorizontalStrut(5));
    productCount.add(productCountLabel); //display the label showing the number of terms
    productCount.add(Box.createHorizontalGlue());

    info.add(scope);
    info.add(productCount);
    info.setBorder(border);

    /* ACTION BUTTONS */
    Box actionButtons = Box.createHorizontalBox();
    actionButtons.add(Box.createHorizontalGlue());
    actionButtons.add(Box.createHorizontalStrut(10));

    JButton findFix = new JButton(new FindClosestMatchAction());
    actionButtons.add(findFix);
    actionButtons.add(Box.createHorizontalStrut(10));

    RationaliserAction ra = new RationaliserAction();
    // RationaliserAction2 ra2 = new RationaliserAction2();
    JButton go = new JButton(ra);
    actionButtons.add(go);
    actionButtons.add(Box.createHorizontalGlue());

    /* MORE INFORMATION TOGGLE */
    Box buttonBox = Box.createHorizontalBox();
    final JButton toggle = new JButton("Hide information <<");

    buttonBox.add(Box.createHorizontalStrut(5));
    buttonBox.add(toggle);
    buttonBox.add(Box.createHorizontalGlue());

    Box textBox = Box.createHorizontalBox();

    final JScrollPane scrollPane = new JScrollPane(information);
    scrollPane.setPreferredSize(new Dimension(frame.getWidth(), 100));
    scrollPane.setVisible(true);
    textBox.add(Box.createHorizontalStrut(5));
    textBox.add(scrollPane);

    ActionListener actionListener = new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            if (toggle.getText().equals("Show information >>")) {
                scrollPane.setVisible(true);
                toggle.setText("Hide information <<");
                frame.setPreferredSize(new Dimension(frame.getWidth(), frame.getHeight() + 100));
                frame.pack();
            } else if (toggle.getText().equals("Hide information <<")) {
                scrollPane.setVisible(false);
                toggle.setText("Show information >>");
                frame.setPreferredSize(new Dimension(frame.getWidth(), frame.getHeight() - 100));
                frame.pack();
            }
        }
    };
    toggle.addActionListener(actionListener);

    main.add(Box.createVerticalStrut(5));
    main.add(info);
    main.add(Box.createVerticalStrut(5));
    main.add(Box.createVerticalStrut(5));
    main.add(actionButtons);
    main.add(Box.createVerticalStrut(10));
    main.add(buttonBox);
    main.add(textBox);

    frame.add(main, BorderLayout.SOUTH);
    frame.pack();
    frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    frame.setVisible(true);
    //initModels();

    return frame;
}

From source file:org.genedb.jogra.plugins.TermRationaliser.java

private Box createRationaliserPanel(final String name, final RationaliserJList rjlist) {

    int preferredHeight = 500; //change accordingly
    int preferredWidth = 500;

    Toolkit tk = Toolkit.getDefaultToolkit();
    Dimension size = tk.getScreenSize();
    int textboxHeight = 10; //change accordingly
    int textboxWidth = size.width;

    Box box = Box.createVerticalBox();
    box.add(new JLabel(name));

    JTextField searchField = new JTextField(20); //Search field on top
    /* We don't want this textfield's height to expand when
     * the Rationaliser is dragged to exapnd. So we set it's
     * height to what we want and the width to the width of
     * the screen  /*from  www.jav  a  2 s.c om*/
     */
    searchField.setMaximumSize(new Dimension(textboxWidth, textboxHeight));
    rjlist.installJTextField(searchField);
    box.add(searchField);

    JScrollPane scrollPane = new JScrollPane(); //scroll pane
    scrollPane.setViewportView(rjlist);
    scrollPane.setPreferredSize(new Dimension(preferredWidth, preferredHeight));
    box.add(scrollPane);

    TitledBorder sysidBorder = BorderFactory.createTitledBorder("Systematic IDs"); //systematic ID box
    sysidBorder.setTitleColor(Color.DARK_GRAY);

    final JTextArea idField = new JTextArea(1, 1);
    idField.setMaximumSize(new Dimension(textboxWidth, textboxHeight));
    idField.setEditable(false);
    idField.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
    idField.setForeground(Color.DARK_GRAY);
    JScrollPane scroll = new JScrollPane(idField);
    scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

    Box sysidBox = Box.createVerticalBox();
    sysidBox.add(scroll /*idField*/);
    sysidBox.setBorder(sysidBorder);
    box.add(sysidBox);

    rjlist.addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            Term highlightedTerm = (Term) rjlist.getSelectedValue();
            if (highlightedTerm != null) {
                /* For each list, call the relevant methods
                 * to get the systematic IDs. Then for the
                 * right list, add the term name in the
                 * text box below
                 */
                if (name.equals(FROM_LIST_NAME)) {
                    idField.setText(StringUtils.collectionToCommaDelimitedString(
                            termService.getSystematicIDs(highlightedTerm, selectedTaxons)));
                } else if (name.equals(TO_LIST_NAME)) {
                    idField.setText(StringUtils.collectionToCommaDelimitedString(
                            termService.getSystematicIDs(highlightedTerm, null)));
                    /* We allow the user to edit the term name */
                    textField.setText(highlightedTerm.getName());
                }

            }
        }
    });

    return box;

}