本文整理匯總了Java中javax.swing.JLabel.setComponentPopupMenu方法的典型用法代碼示例。如果您正苦於以下問題:Java JLabel.setComponentPopupMenu方法的具體用法?Java JLabel.setComponentPopupMenu怎麽用?Java JLabel.setComponentPopupMenu使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.JLabel
的用法示例。
在下文中一共展示了JLabel.setComponentPopupMenu方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initReferenceLabel
import javax.swing.JLabel; //導入方法依賴的package包/類
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);
}
示例2: getContainerPanel
import javax.swing.JLabel; //導入方法依賴的package包/類
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;
}