Example usage for javax.swing.border TitledBorder RIGHT

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

Introduction

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

Prototype

int RIGHT

To view the source code for javax.swing.border TitledBorder RIGHT.

Click Source Link

Document

Position title text at the right side of the border line.

Usage

From source file:net.minelord.gui.panes.IRCPane.java

public void disconnect() {
    status = "Disconnecting...";
    TitledBorder title = BorderFactory
            .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), status);
    title.setTitleJustification(TitledBorder.RIGHT);
    if (userScroller != null)
        userScroller.setBorder(title);//from w ww .j  a v  a2  s . com
    else
        scroller.setBorder(title);
    input.setEnabled(false);
}

From source file:net.minelord.gui.panes.IRCPane.java

public void connect() {
    text.setText("");
    status = "Connecting...";
    TitledBorder title = BorderFactory
            .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), status);
    title.setTitleJustification(TitledBorder.RIGHT);
    scroller.setBorder(title);//from   ww w . j a v a2 s  . co  m
    if (topic != null && topic.getParent() == this) {
        showTopic(false);
        remove(topic);
    }
    if (userScroller != null && userScroller.getParent() == this) {
        showUserList(false);
        remove(userScroller);
    }
}

From source file:net.minelord.gui.panes.IRCPane.java

public void quit() {
    status = "Disconnected";
    lastNick = null;//from  w ww.j  a  va  2 s . c  om
    TitledBorder title = BorderFactory
            .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), status);
    title.setTitleJustification(TitledBorder.RIGHT);
    if (userScroller != null)
        userScroller.setBorder(title);
    else
        scroller.setBorder(title);
    input.setText("");
    input.setEnabled(false);
    remove(scroller);
    remove(input);
    if (topic != null && topic.getParent() == this)
        remove(topic);
    if (userScroller != null && userScroller.getParent() == this)
        remove(userScroller);
    add(nickSelectPane);
    quit = false;
    repaint();
}

From source file:net.minelord.gui.panes.IRCPane.java

public void connected() {
    SwingUtilities.invokeLater(new Runnable() {

        @Override//from w w  w  . j  a  va2 s .c  om
        public void run() {
            scroller.setBounds(scrollerWithoutTopicWithUserlist);
            scroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
            status = "Connected";
            client.connectAlertListener();
            TitledBorder title = BorderFactory
                    .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Connected");
            title.setTitleJustification(TitledBorder.RIGHT);
            userList = new JList(client.getUserList().toArray());
            userScroller = new JScrollPane(userList);
            userScroller.setBounds(userScrollerWithoutTopic);
            userList.setBounds(0, 0, 210, 250);
            userList.setBackground(Color.gray);
            userList.setForeground(Color.gray.darker().darker().darker());
            userScroller.setBorder(title);
            userScroller.getVerticalScrollBar().setUnitIncrement(5);
            scroller.setBorder(BorderFactory
                    .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), ""));
            if (client.getTopic().trim().length() > 0) {
                topic = new JLabel(client.getTopic());
                scroller.setBounds(scrollerWithTopicWithUserlist);
                userScroller.setBounds(userScrollWithTopic);
                userList.setBounds(0, 0, 210, 225);
                title = BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),
                        "Topic set by " + client.getTopicSetter());
                title.setTitleJustification(TitledBorder.LEFT);
                topic.setBorder(title);
                topic.setBounds(topicBounds);
                add(topic);
            } else
                topic = new JLabel("");
            input.setEnabled(true);
            input.requestFocus();
            final JPopupMenu userPopup = new JPopupMenu();
            JLabel breakLine = new JLabel("____");
            JLabel help = new JLabel("Politely ask for help");
            JLabel message = new JLabel("Message");
            JLabel sortNormal = new JLabel("Normal");
            JLabel sortAlphabetical = new JLabel("Alphabetical");
            JLabel sortRoles = new JLabel("Roles");

            help.addMouseListener(new MouseAdapter() {
                public void mousePressed(MouseEvent e) {
                    userPopup.setVisible(false);
                    sendMessage("/me kicks " + userList.getModel().getElementAt(userList.getSelectedIndex())
                            + " in the shins");
                    sendMessage("I need help you pleb");
                }

                public void mouseReleased(MouseEvent e) {
                }
            });
            message.addMouseListener(new MouseAdapter() {

                @Override
                public void mouseReleased(MouseEvent paramMouseEvent) {
                    userPopup.setVisible(false);
                    input.setText("/msg " + userList.getModel().getElementAt(userList.getSelectedIndex())
                            + (input.getText().length() > 0 && input.getText().charAt(0) == ' '
                                    ? input.getText()
                                    : " " + input.getText()));
                    input.select(0, ("/msg " + userList.getModel().getElementAt(userList.getSelectedIndex())
                            + (input.getText().length() > 0 && input.getText().charAt(0) == ' ' ? "" : " "))
                                    .length());
                    input.requestFocus();
                }
            });
            sortNormal.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseReleased(MouseEvent paramMouseEvent) {
                    userPopup.setVisible(false);
                    updateUserList(0);
                }
            });
            sortAlphabetical.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseReleased(MouseEvent paramMouseEvent) {
                    userPopup.setVisible(false);
                    updateUserList(1);
                }
            });
            sortRoles.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseReleased(MouseEvent paramMouseEvent) {
                    userPopup.setVisible(false);
                    updateUserList(2);
                }
            });
            userPopup.add(help);
            userPopup.add(message);
            userPopup.add(breakLine);
            userPopup.add(sortNormal);
            userPopup.add(sortAlphabetical);
            userPopup.add(sortRoles);

            userList.addMouseListener(new MouseAdapter() {
                public void mousePressed(MouseEvent e) {
                    check(e);
                }

                public void mouseReleased(MouseEvent e) {
                    check(e);
                }

                public void check(MouseEvent e) {
                    userList.setSelectedIndex(userList.locationToIndex(e.getPoint()));
                    userPopup.show(userList, e.getX(), e.getY());
                }
            });
            add(userScroller);

            final JPopupMenu textPopup = new JPopupMenu();
            JLabel copy = new JLabel("Copy");
            copy.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseReleased(MouseEvent paramMouseEvent) {
                    textPopup.setVisible(false);
                    if (text.getSelectedText() != null && text.getSelectedText().length() != 0) {
                        StringSelection selection = new StringSelection(text.getSelectedText());
                        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
                        clipboard.setContents(selection, selection);
                    }
                }
            });
            textPopup.add(copy);
            text.addMouseListener(new MouseAdapter() {
                public void mousePressed(MouseEvent e) {
                }

                public void mouseReleased(MouseEvent e) {
                    if (SwingUtilities.isRightMouseButton(e))
                        textPopup.show(text, e.getX(), e.getY());
                }
            });
            add(userScroller);
            repaint();
        }
    });
}

From source file:net.sf.jabref.gui.groups.GroupSelector.java

private void setEditMode(boolean editMode) {
    Globals.prefs.putBoolean(JabRefPreferences.EDIT_GROUP_MEMBERSHIP_MODE, editModeIndicator);
    editModeIndicator = editMode;/*from  w ww.j av  a  2 s . c o m*/

    if (editMode) {
        groupsTree.setBorder(
                BorderFactory.createTitledBorder(BorderFactory.createMatteBorder(2, 2, 2, 2, Color.RED),
                        "Edit mode", TitledBorder.RIGHT, TitledBorder.TOP, Font.getFont("Default"), Color.RED));
        this.setTitle("<html><font color='red'>Groups Edit mode</font></html>");
    } else {
        groupsTree.setBorder(BorderFactory.createEmptyBorder(5, 10, 0, 0));
        this.setTitle(Localization.lang("Groups"));
    }
    groupsTree.revalidate();
    groupsTree.repaint();
}

From source file:net.minelord.gui.panes.IRCPane.java

@Override
public void kicked() {
    client.quit();//from www  .  j  a v a 2  s . c  o  m
    status = "Disconnected";
    TitledBorder title = BorderFactory
            .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), status);
    title.setTitleJustification(TitledBorder.RIGHT);
    if (userScroller != null) {
        userScroller.setBorder(title);
        userList.setListData(new Object[0]);
    } else
        scroller.setBorder(title);
    input.setText("");
    input.setEnabled(false);
    quit = true;
}

From source file:net.minelord.gui.panes.IRCPane.java

public static void updateBounds() {
    if (topic.getText().length() == 0)
        showTopic = false;//from  ww w . ja  v a 2  s .c  o  m
    topic.setVisible(showTopic);
    userScroller.setVisible(showUserList);
    if (topic != null && !showTopic && !showUserList)
        scroller.setBounds(scrollerWithoutTopicWithoutUserlist);
    if (topic != null && !showTopic && showUserList) {
        scroller.setBounds(scrollerWithoutTopicWithUserlist);
        userScroller.setBounds(userScrollerWithoutTopic);
    }
    if (topic != null && showTopic && showUserList) {
        scroller.setBounds(scrollerWithTopicWithUserlist);
        userScroller.setBounds(userScrollWithTopic);
    }
    if (topic != null && showTopic && !showUserList)
        scroller.setBounds(scrollerWithTopicWithoutUserlist);
    if (topic != null && !showUserList) {
        TitledBorder title = BorderFactory
                .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), status);
        title.setTitleJustification(TitledBorder.RIGHT);
        scroller.setBorder(title);
    } else
        scroller.setBorder(
                BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), ""));
    userList.repaint();
    scroller.repaint();
}