Java Code Examples for javax.swing.JLabel.setComponentPopupMenu()
The following are Jave code examples for showing how to use
setComponentPopupMenu() of the
javax.swing.JLabel
class.
You can vote up the examples you like. Your votes will be used in our system to get
more good examples.
+ Save this method
Example 1
Project: Cognizant-Intelligent-Test-Scripter File: PropertyEditor.java View Source Code | 6 votes |
private void initReferenceLabel() { imageChooser.setFileFilter(new FileNameExtensionFilter("Image", "jpg", "png", "gif", "bmp")); referenceLabel = new JLabel() { @Override public void paint(Graphics grphcs) { super.paint(grphcs); paintPage(grphcs); } }; referenceLabel.setHorizontalAlignment(SwingConstants.CENTER); referenceLabel.setComponentPopupMenu(referencePopup); jScrollPane2.setViewportView(referenceLabel); offsetAdapter = new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { setOffsetMarker(e); } }; referenceLabel.addMouseListener(offsetAdapter); }
Example 2
Project: openjdk-jdk10 File: TestPopupMenu.java View Source Code | 5 votes |
private JPanel getContainerPanel() { JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); label = new JLabel("Test Label"); JPopupMenu popup = new JPopupMenu(); JMenuItem menuItem1 = new JMenuItem("Item 1"); JMenuItem menuItem2 = new JMenuItem("Item 2"); JMenuItem menuItem3 = new JMenuItem("Item 3"); JMenuItem menuItem4 = new JMenuItem("Item 4"); JMenuItem menuItem5 = new JMenuItem("Item 5"); menuItem1.setOpaque(false); menuItem2.setOpaque(false); menuItem3.setOpaque(false); menuItem4.setOpaque(false); menuItem5.setOpaque(false); popup.add(menuItem1); popup.add(menuItem2); popup.add(menuItem3); popup.add(menuItem4); popup.add(menuItem5); label.setComponentPopupMenu(popup); popup.setBackground(Color.CYAN); panel.add(label, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); panel.setBackground(Color.CYAN); return panel; }