Example usage for javax.swing JLabel setBorder

List of usage examples for javax.swing JLabel setBorder

Introduction

In this page you can find the example usage for javax.swing JLabel setBorder.

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The component's border.")
public void setBorder(Border border) 

Source Link

Document

Sets the border of this component.

Usage

From source file:org.dwfa.ace.classifier.CNFormsLabelPanel.java

public CNFormsLabelPanel(I_GetConceptData conceptIn, List<I_Position> cEditPathPos,
        List<I_Position> cClassPathPos, SnoTable cSnoTable) {
    super();//from www .j  a  va  2  s  .co m
    this.theCBean = conceptIn;
    this.cEditPathPos = cEditPathPos;
    this.cClassPathPos = cClassPathPos;
    this.cSnoTable = cSnoTable;

    setLayout(new GridBagLayout()); // CNFormsLabelPanel LayoutManager
    GridBagConstraints c = new GridBagConstraints();
    c.anchor = GridBagConstraints.NORTHWEST; // Place
    // CNFormsLabelPanel

    // TOP ROW
    c.gridy = 0; // first row
    c.gridx = 0; // reset at west side of row
    c.weightx = 0.0; // no extra space
    c.weighty = 0.0; // no extra space
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;

    // ADD CHECK BOXES
    c.gridy++;// next row
    c.gridx = 0;
    c.gridwidth = 5;
    JLabel label = new JLabel("Normal Forms Expanded View:");
    label.setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 0));
    add(label, c);
    c.gridx++;
    add(showDistFormCB, c);
    c.gridx++;
    add(showAuthFormCB, c);
    c.gridx++;
    add(showLongFormCB, c);
    c.gridx++;
    add(showShortFormCB, c);

    // FORM SELECTION CHECKBOX ROW
    c.gridy++; // next row
    c.gridx = 0; // first cell in row
    c.gridwidth = 1;
    c.weightx = 0.0;
    c.fill = GridBagConstraints.NONE;

    label = new JLabel("Information:");
    label.setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 0));
    add(label, c);

    c.gridx++;
    add(showDetailCB, c);
    c.gridx++;
    add(showStatusCB, c);

    // SETUP CHECKBOX VALUES & LISTENER
    showStatusCB.setSelected(false);
    showStatusCB.addActionListener(this);
    showDetailCB.setSelected(false);
    showDetailCB.addActionListener(this);
    showDistFormCB.setSelected(false);
    showDistFormCB.addActionListener(this);
    showAuthFormCB.setSelected(false);
    showAuthFormCB.addActionListener(this);
    showLongFormCB.setSelected(false);
    showLongFormCB.addActionListener(this);
    showShortFormCB.setSelected(false);
    showShortFormCB.addActionListener(this);

    // COMMON & DIFFERENT PANELS ROW
    c.gridy++;
    c.gridx = 0;
    c.gridwidth = 2;
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 0;
    commonJPanel = newMinMaxJPanel();
    commonJPanel.setLayout(new GridLayout(0, 1));
    commonJPanel.setName("Common Panel");
    commonJPanel.setBorder(BorderFactory.createTitledBorder("Common: "));
    add(commonJPanel, c);

    c.gridx = c.gridx + 1;
    deltaJPanel = newMinMaxJPanel();
    deltaJPanel.setLayout(new GridLayout(0, 1));
    deltaJPanel.setName("Differences Panel");
    deltaJPanel.setBorder(BorderFactory.createTitledBorder("Different: "));
    add(deltaJPanel, c);

    // FORMS PANEL ROW
    c.gridy++;// next row
    c.gridx = 0; // reset at west side of row
    c.gridwidth = 2; // number of cells in row
    c.fill = GridBagConstraints.BOTH;
    formsJPanel = new JPanel(new GridBagLayout());
    formsJPanel.setName("Forms Panel");
    formsJPanel.setBorder(BorderFactory.createTitledBorder("Forms: "));
    JScrollPane formJScrollPane = new JScrollPane(formsJPanel);
    formJScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
    add(formJScrollPane, c);

}

From source file:org.dwfa.ace.classifier.CNFormsLabelPanel.java

private void setBorder(JLabel tLabel, Color deltaColor) {
    if (deltaColor == null) {
        deltaColor = Color.white;
    }//w w  w .  ja  va2  s . c  o m
    Dimension size = tLabel.getSize();
    tLabel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createRaisedBevelBorder(),
            BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(1, 5, 1, 5, deltaColor),
                    BorderFactory.createEmptyBorder(1, 3, 1, 3))));
    size.width = size.width + 18;
    size.height = size.height + 6;
    tLabel.setSize(size);
    tLabel.setPreferredSize(size);
    tLabel.setMaximumSize(size);
    tLabel.setMinimumSize(size);
}

From source file:org.eclipse.om2m.ipe.sample.gui.GUI.java

/**
 * Creates the frame.//from w ww .ja  v a 2s .c o m
 */
public GUI() {
    setLocationByPlatform(true);
    setVisible(false);
    setResizable(false);
    setTitle("Sample Simulated IPE");
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    setBounds((screenSize.width - 500) / 2, (screenSize.height - 570) / 2, 497, 570);

    contentPanel = new JPanel();
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPanel);
    contentPanel.setLayout(null);

    // Lamp0 Switcher0
    JPanel panel_Lamp0 = new JPanel();
    panel_Lamp0.setBounds(10, 5, 319, 260);
    contentPanel.add(panel_Lamp0);
    panel_Lamp0.setBorder(new LineBorder(new Color(0, 0, 0), 1, true));
    panel_Lamp0.setLayout(null);
    LABEL_LAMP_0.setIcon(iconLampOFF);
    LABEL_LAMP_0.setHorizontalTextPosition(SwingConstants.CENTER);
    LABEL_LAMP_0.setHorizontalAlignment(SwingConstants.CENTER);
    LABEL_LAMP_0.setBounds(10, 9, 149, 240);
    panel_Lamp0.add(LABEL_LAMP_0);

    // Lamp0 Switch Button
    JButton button_Lamp0 = new JButton();
    button_Lamp0.setOpaque(false);
    button_Lamp0.setPressedIcon(iconButtonON);
    button_Lamp0.setIcon(iconButtonOFF);
    button_Lamp0.setBounds(187, 44, 122, 155);
    panel_Lamp0.add(button_Lamp0);
    button_Lamp0.setMinimumSize(new Dimension(30, 23));
    button_Lamp0.setMaximumSize(new Dimension(30, 23));
    button_Lamp0.setPreferredSize(new Dimension(30, 23));

    JLabel labelSwitcher0 = new JLabel("Switch LAMP_0");
    labelSwitcher0.setFont(new Font("Vani", Font.BOLD | Font.ITALIC, 14));
    labelSwitcher0.setFocusCycleRoot(true);
    labelSwitcher0.setBorder(null);
    labelSwitcher0.setAutoscrolls(true);
    labelSwitcher0.setBounds(187, 199, 118, 29);
    panel_Lamp0.add(labelSwitcher0);
    // Listener for Lamp0 Switch Button
    button_Lamp0.addActionListener(new java.awt.event.ActionListener() {
        // Button Clicked
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            // Change Lamp0 State
            new Thread() {
                public void run() {
                    // Send switch request to switch lamp0 state
                    SampleMonitor.switchLamp(LAMP_0);
                }
            }.start();
        }
    });

    // Lamp1 Switcher 1
    JPanel panel_Lamp1 = new JPanel();
    panel_Lamp1.setBounds(10, 271, 319, 260);
    contentPanel.add(panel_Lamp1);
    panel_Lamp1.setBorder(new LineBorder(new Color(0, 0, 0), 1, true));
    panel_Lamp1.setLayout(null);

    LABEL_LAMP_1.setIcon(iconLampOFF);
    LABEL_LAMP_1.setHorizontalTextPosition(SwingConstants.CENTER);
    LABEL_LAMP_1.setHorizontalAlignment(SwingConstants.CENTER);
    LABEL_LAMP_1.setBounds(10, 9, 154, 240);
    panel_Lamp1.add(LABEL_LAMP_1);

    // Lamp1 Switch Button
    JButton button_Lamp1 = new JButton();
    button_Lamp1.setOpaque(false);
    button_Lamp1.setPressedIcon(iconButtonON);
    button_Lamp1.setIcon(iconButtonOFF);
    button_Lamp1.setBounds(187, 44, 122, 156);
    panel_Lamp1.add(button_Lamp1);
    button_Lamp1.setMinimumSize(new Dimension(30, 23));
    button_Lamp1.setMaximumSize(new Dimension(30, 23));
    button_Lamp1.setPreferredSize(new Dimension(30, 23));

    JLabel labelSwitcher1 = new JLabel("Switch LAMP_1");
    labelSwitcher1.setFont(new Font("Vani", Font.BOLD | Font.ITALIC, 14));
    labelSwitcher1.setFocusCycleRoot(true);
    labelSwitcher1.setBorder(null);
    labelSwitcher1.setAutoscrolls(true);
    labelSwitcher1.setBounds(187, 199, 118, 29);
    panel_Lamp1.add(labelSwitcher1);
    // Listener for Lamp1 Switch Button
    button_Lamp1.addActionListener(new java.awt.event.ActionListener() {
        //Switch Button clicked
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            // Change Lamp1 State
            new Thread() {
                public void run() {
                    // Send switch request to switch lamp1 state
                    SampleMonitor.switchLamp(LAMP_1);
                }
            }.start();
        }
    });

    // Switcher All lamps
    JButton buttonAllLamp = new JButton();
    buttonAllLamp.setOpaque(false);
    buttonAllLamp.setPressedIcon(iconButtonON);
    buttonAllLamp.setIcon(iconButtonOFF);
    buttonAllLamp.setBounds(339, 190, 145, 168);
    contentPanel.add(buttonAllLamp);
    buttonAllLamp.setMinimumSize(new Dimension(30, 23));
    buttonAllLamp.setMaximumSize(new Dimension(30, 23));
    buttonAllLamp.setPreferredSize(new Dimension(30, 23));

    JLabel labelSwitchAll = new JLabel("Switch All");
    labelSwitchAll.setAutoscrolls(true);
    labelSwitchAll.setFont(new Font("Vani", Font.BOLD | Font.ITALIC, 14));
    labelSwitchAll.setFocusCycleRoot(true);
    labelSwitchAll.setBorder(null);
    labelSwitchAll.setBounds(371, 369, 85, 29);
    contentPanel.add(labelSwitchAll);
    // Listener of Switch all Button
    buttonAllLamp.addActionListener(new java.awt.event.ActionListener() {
        // Switch Button Clicked
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            // Change all lamps states
            new Thread() {
                public void run() {
                    // Send switch all request to create a content with the current State
                    SampleMonitor.switchAll();
                }
            }.start();
        }
    });

    lampObserver = new SampleModel.LampObserver() {

        @Override
        public void onLampStateChange(String lampId, boolean state) {
            setLabel(lampId, state);
        }
    };
    SampleModel.addObserver(lampObserver);
}

From source file:org.eclipse.om2m.ipu.sample.GUI.java

/**
 * Creates the frame./*from  ww w . j a  v  a 2s.  c  om*/
 */
public GUI() {
    setLocationByPlatform(true);
    setResizable(false);
    setTitle("Sample Simulated IPU");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    setBounds((screenSize.width - 500) / 2, (screenSize.height - 570) / 2, 497, 570);

    contentPanel = new JPanel();
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPanel);
    contentPanel.setLayout(null);

    // Lamp0 Switcher0
    JPanel panel_Lamp0 = new JPanel();
    panel_Lamp0.setBounds(10, 5, 319, 260);
    contentPanel.add(panel_Lamp0);
    panel_Lamp0.setBorder(new LineBorder(new Color(0, 0, 0), 1, true));
    panel_Lamp0.setLayout(null);
    LABEL_LAMP_0.setIcon(iconLampOFF);
    LABEL_LAMP_0.setHorizontalTextPosition(SwingConstants.CENTER);
    LABEL_LAMP_0.setHorizontalAlignment(SwingConstants.CENTER);
    LABEL_LAMP_0.setBounds(10, 9, 149, 240);
    panel_Lamp0.add(LABEL_LAMP_0);

    // Lamp0 Switch Button
    JButton button_Lamp0 = new JButton();
    button_Lamp0.setOpaque(false);
    button_Lamp0.setPressedIcon(iconButtonON);
    button_Lamp0.setIcon(iconButtonOFF);
    button_Lamp0.setBounds(187, 44, 122, 155);
    panel_Lamp0.add(button_Lamp0);
    button_Lamp0.setMinimumSize(new Dimension(30, 23));
    button_Lamp0.setMaximumSize(new Dimension(30, 23));
    button_Lamp0.setPreferredSize(new Dimension(30, 23));

    JLabel labelSwitcher0 = new JLabel("Switch LAMP_0");
    labelSwitcher0.setFont(new Font("Vani", Font.BOLD | Font.ITALIC, 14));
    labelSwitcher0.setFocusCycleRoot(true);
    labelSwitcher0.setBorder(null);
    labelSwitcher0.setAutoscrolls(true);
    labelSwitcher0.setBounds(187, 199, 118, 29);
    panel_Lamp0.add(labelSwitcher0);
    // Listener for Lamp0 Switch Button
    button_Lamp0.addActionListener(new java.awt.event.ActionListener() {
        // Button Clicked
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            // Change Lamp0 State
            new Thread() {
                public void run() {
                    // Send switch request to switch lamp0 state
                    Switchs.switchLamp(LAMP_0, !SampleMonitor.LAMPS.get(LAMP_0).getState());
                }
            }.start();
        }
    });

    // Lamp1 Switcher 1
    JPanel panel_Lamp1 = new JPanel();
    panel_Lamp1.setBounds(10, 271, 319, 260);
    contentPanel.add(panel_Lamp1);
    panel_Lamp1.setBorder(new LineBorder(new Color(0, 0, 0), 1, true));
    panel_Lamp1.setLayout(null);

    LABEL_LAMP_1.setIcon(iconLampOFF);
    LABEL_LAMP_1.setHorizontalTextPosition(SwingConstants.CENTER);
    LABEL_LAMP_1.setHorizontalAlignment(SwingConstants.CENTER);
    LABEL_LAMP_1.setBounds(10, 9, 154, 240);
    panel_Lamp1.add(LABEL_LAMP_1);

    // Lamp1 Switch Button
    JButton button_Lamp1 = new JButton();
    button_Lamp1.setOpaque(false);
    button_Lamp1.setPressedIcon(iconButtonON);
    button_Lamp1.setIcon(iconButtonOFF);
    button_Lamp1.setBounds(187, 44, 122, 156);
    panel_Lamp1.add(button_Lamp1);
    button_Lamp1.setMinimumSize(new Dimension(30, 23));
    button_Lamp1.setMaximumSize(new Dimension(30, 23));
    button_Lamp1.setPreferredSize(new Dimension(30, 23));

    JLabel labelSwitcher1 = new JLabel("Switch LAMP_1");
    labelSwitcher1.setFont(new Font("Vani", Font.BOLD | Font.ITALIC, 14));
    labelSwitcher1.setFocusCycleRoot(true);
    labelSwitcher1.setBorder(null);
    labelSwitcher1.setAutoscrolls(true);
    labelSwitcher1.setBounds(187, 199, 118, 29);
    panel_Lamp1.add(labelSwitcher1);
    // Listener for Lamp1 Switch Button
    button_Lamp1.addActionListener(new java.awt.event.ActionListener() {
        //Switch Button clicked
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            // Change Lamp1 State
            new Thread() {
                public void run() {
                    // Send switch request to switch lamp1 state
                    Switchs.switchLamp(LAMP_1, !SampleMonitor.LAMPS.get(LAMP_1).getState());
                }
            }.start();
        }
    });

    // Switcher All lamps
    JButton buttonAllLamp = new JButton();
    buttonAllLamp.setOpaque(false);
    buttonAllLamp.setPressedIcon(iconButtonON);
    buttonAllLamp.setIcon(iconButtonOFF);
    buttonAllLamp.setBounds(339, 190, 145, 168);
    contentPanel.add(buttonAllLamp);
    buttonAllLamp.setMinimumSize(new Dimension(30, 23));
    buttonAllLamp.setMaximumSize(new Dimension(30, 23));
    buttonAllLamp.setPreferredSize(new Dimension(30, 23));

    JLabel labelSwitchAll = new JLabel("Switch All");
    labelSwitchAll.setAutoscrolls(true);
    labelSwitchAll.setFont(new Font("Vani", Font.BOLD | Font.ITALIC, 14));
    labelSwitchAll.setFocusCycleRoot(true);
    labelSwitchAll.setBorder(null);
    labelSwitchAll.setBounds(371, 369, 85, 29);
    contentPanel.add(labelSwitchAll);
    // Listener of Switch all Button
    buttonAllLamp.addActionListener(new java.awt.event.ActionListener() {
        // Switch Button Clicked
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            // Change all lamps states
            new Thread() {
                public void run() {
                    // Send switch all request to create a content with the current State
                    Switchs.switchAll(!(SampleMonitor.LAMPS.get(LAMP_0).getState()
                            && SampleMonitor.LAMPS.get(LAMP_1).getState()));
                }
            }.start();
        }
    });
}

From source file:org.executequery.gui.editor.LobDataItemViewerPanel.java

private void init() {

    Border emptyBorder = BorderFactory.createEmptyBorder(2, 2, 2, 2);

    JPanel textPanel = new JPanel(new BorderLayout());
    textPanel.setBorder(emptyBorder);//w  ww  . jav a 2 s  .  c o m

    textArea = createTextArea();
    textArea.setLineWrap(false);
    textArea.setMargin(new Insets(2, 2, 2, 2));
    textPanel.add(new JScrollPane(textArea), BorderLayout.CENTER);

    JPanel imagePanel = null;

    imagePanel = new JPanel(new BorderLayout());
    imagePanel.setBorder(emptyBorder);

    if (isImage()) {

        ImageIcon image = loadImageData();
        if (image != null) {

            JLabel imageLabel = new JLabel(image);
            imagePanel.add(new JScrollPane(imageLabel), BorderLayout.CENTER);
        }

        setTextAreaText(textArea, CANNOT_DISPLAY_BINARY_DATA_AS_TEXT);

    } else {

        imagePanel.add(new JLabel("Unsupported format", JLabel.CENTER));

        loadTextData();
    }

    JPanel binaryPanel = new JPanel(new BorderLayout());
    binaryPanel.setBorder(emptyBorder);

    binaryStringTextArea = createTextArea();
    binaryPanel.add(new JScrollPane(binaryStringTextArea), BorderLayout.CENTER);

    tabbedPane = new JTabbedPane();
    tabbedPane.addChangeListener(this);
    tabbedPane.addTab("Text", textPanel);
    tabbedPane.addTab("Image", imagePanel);
    tabbedPane.addTab("Binary", binaryPanel);

    JPanel contentPanel = new JPanel(new BorderLayout());
    contentPanel.setPreferredSize(new Dimension(400, 300));
    contentPanel.add(tabbedPane, BorderLayout.CENTER);

    JLabel descriptionLabel = new JLabel(formatDescriptionString());
    descriptionLabel.setBorder(BorderFactory.createEmptyBorder(5, 2, 5, 0));

    contentPanel.add(descriptionLabel, BorderLayout.SOUTH);

    JButton closeButton = new JButton("Close");
    closeButton.setActionCommand("close");

    JButton saveButton = new JButton("Save As");
    saveButton.setActionCommand("save");

    saveButton.addActionListener(this);
    closeButton.addActionListener(this);

    addActionButton(saveButton);
    addActionButton(closeButton);

    setPreferredSize(new Dimension(500, 420));

    addContentPanel(contentPanel);

    textArea.requestFocus();
}

From source file:org.javaswift.cloudie.CloudiePanel.java

private void createLists() {
    containersList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    containersList.setCellRenderer(new DefaultListCellRenderer() {
        @Override/* w w  w  . j  ava 2  s  .  co m*/
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
                boolean cellHasFocus) {
            JLabel lbl = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected,
                    cellHasFocus);
            lbl.setBorder(LR_PADDING);
            Container c = (Container) value;
            lbl.setText(c.getName());
            lbl.setToolTipText(lbl.getText());
            return lbl;
        }
    });
    containersList.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            enableDisableContainerMenu();
            updateStatusPanelForContainer();
        }
    });
    //
    storedObjectsList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    storedObjectsList.setCellRenderer(new DefaultListCellRenderer() {
        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
                boolean cellHasFocus) {
            JLabel lbl = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected,
                    cellHasFocus);
            lbl.setBorder(LR_PADDING);
            StoredObject so = (StoredObject) value;
            lbl.setText(so.getName());
            lbl.setToolTipText(lbl.getText());
            return lbl;
        }
    });
    storedObjectsList.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            enableDisableStoredObjectMenu();
            updateStatusPanelForStoredObject();
        }
    });
}

From source file:org.languagetool.gui.LanguageToolSupport.java

private void showPopup(MouseEvent event) {
    if (documentSpans.isEmpty() && languageTool.getDisabledRules().isEmpty()) {
        //No errors and no disabled Rules
        return;/*from w ww.j a  v a2 s  .c  o m*/
    }

    int offset = this.textComponent.viewToModel(event.getPoint());
    Span span = getSpan(offset);
    JPopupMenu popup = new JPopupMenu("Grammar Menu");
    if (span != null) {
        JLabel msgItem = new JLabel("<html>"
                + span.msg.replace("<suggestion>", "<b>").replace("</suggestion>", "</b>") + "</html>");
        msgItem.setToolTipText(span.desc.replace("<suggestion>", "").replace("</suggestion>", ""));
        msgItem.setBorder(new JMenuItem().getBorder());
        popup.add(msgItem);

        popup.add(new JSeparator());

        for (String r : span.replacement) {
            ReplaceMenuItem item = new ReplaceMenuItem(r, span);
            popup.add(item);
            item.addActionListener(actionListener);
        }

        popup.add(new JSeparator());

        JMenuItem moreItem = new JMenuItem(messages.getString("guiMore"));
        moreItem.addActionListener(e -> showDialog(textComponent, span.msg, span.desc, span.rule, span.url));
        popup.add(moreItem);

        JMenuItem ignoreItem = new JMenuItem(messages.getString("guiTurnOffRule"));
        ignoreItem.addActionListener(e -> disableRule(span.rule.getId()));
        popup.add(ignoreItem);
        popup.applyComponentOrientation(ComponentOrientation.getOrientation(Locale.getDefault()));
    }

    List<Rule> disabledRules = getDisabledRules();
    if (!disabledRules.isEmpty()) {
        JMenu activateRuleMenu = new JMenu(messages.getString("guiActivateRule"));
        addDisabledRulesToMenu(disabledRules, activateRuleMenu);
        popup.add(activateRuleMenu);
    }

    if (span != null) {
        textComponent.setCaretPosition(span.start);
        textComponent.moveCaretPosition(span.end);
    }

    popup.addPopupMenuListener(new PopupMenuListener() {
        @Override
        public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
        }

        @Override
        public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
        }

        @Override
        public void popupMenuCanceled(PopupMenuEvent e) {
            if (span != null) {
                textComponent.setCaretPosition(span.start);
            }
        }
    });
    popup.show(textComponent, event.getPoint().x, event.getPoint().y);

}

From source file:org.lnicholls.galleon.gui.MainFrame.java

protected JComponent createContentPane() {

    JPanel panel = new JPanel(new BorderLayout());

    mOptionsPanelManager = new OptionsPanelManager(this);

    mOptionsPanelManager.setMinimumSize(new Dimension(200, 100));

    mOptionsPanelManager.setPreferredSize(new Dimension(400, 250));

    InternalFrame navigator = new InternalFrame("Apps");

    mAppTree = new AppTree(this, getAppsModel());

    navigator.setContent(createScrollPane(mAppTree));

    navigator.setSelected(true);/*from   ww  w .j a va  2s.  co m*/

    navigator.setMinimumSize(new Dimension(100, 100));

    navigator.setPreferredSize(new Dimension(150, 400));

    JSplitPane mainSplitPane = createSplitPane(1, navigator, mOptionsPanelManager, 0.25D);

    mainSplitPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    panel.add(mainSplitPane, "Center");

    JLabel statusField = new JLabel("Copyright \251 2005, 2006 Leon Nicholls");

    statusField.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    JPanel statusPanel = new JPanel(new BorderLayout());

    statusPanel.add(statusField, "West");

    panel.add(statusPanel, "South");

    panel.setPreferredSize(new Dimension(700, 450));

    return panel;

}

From source file:org.nuclos.client.ui.collect.SubForm.java

private void init() {
    contentPane.add(toolbar,/* w w w  .  j  a va  2s  .com*/
            toolbar.getOrientation() == JToolBar.HORIZONTAL ? BorderLayout.NORTH : BorderLayout.WEST);

    // Configure table
    scrollPane.getViewport().setBackground(subformtbl.getBackground());
    subformtbl.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    subformtbl.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    //      subformtbl.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    scrollPane.getViewport().setView(subformtbl);
    JLabel labCorner = new JLabel();
    labCorner.setEnabled(false);
    labCorner.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 1, Color.GRAY));
    labCorner.setBackground(Color.LIGHT_GRAY);
    scrollPane.setCorner(ScrollPaneConstants.UPPER_LEFT_CORNER, labCorner);

    rowHeader = createTableRowHeader(subformtbl, scrollPane);
    subformtbl.setRowHeaderTable(rowHeader);

    // subformtbl.addMouseListener(newToolbarContextMenuListener(subformtbl, subformtbl));
    addToolbarMouseListener(subformtbl, subformtbl, subformtbl);
    // scrollPane.getViewport().addMouseListener(newToolbarContextMenuListener(scrollPane.getViewport(), subformtbl));
    addToolbarMouseListener(scrollPane.getViewport(), scrollPane.getViewport(), subformtbl);
}

From source file:org.openconcerto.task.TodoListPanel.java

public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
        int row, int column) {
    JLabel label = (JLabel) this.renderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row,
            column);/*www.  j a v a2 s  .  c o m*/
    label.setIcon(this.icon);
    label.setBorder(BorderFactory.createEmptyBorder());
    label.setIconTextGap(0);
    label.setHorizontalTextPosition(0);
    label.setHorizontalAlignment(SwingConstants.CENTER);
    return label;
}