本文整理汇总了Java中javax.swing.JPopupMenu.setBackground方法的典型用法代码示例。如果您正苦于以下问题:Java JPopupMenu.setBackground方法的具体用法?Java JPopupMenu.setBackground怎么用?Java JPopupMenu.setBackground使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JPopupMenu
的用法示例。
在下文中一共展示了JPopupMenu.setBackground方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getContainerPanel
import javax.swing.JPopupMenu; //导入方法依赖的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;
}
示例2: actionPerformed
import javax.swing.JPopupMenu; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent ae) {
int index = -1;
if (highlightedChainAnnotsOffsets != null) {
for (int i = 0; i < highlightedChainAnnotsOffsets.length; i += 2) {
if (textLocation >= highlightedChainAnnotsOffsets[i] &&
textLocation <= highlightedChainAnnotsOffsets[i + 1]) {
index = (i == 0) ? i : i / 2;
break;
}
}
}
// yes it is put on highlighted so show the annotationType
if (highlightedChainAnnotsOffsets != null &&
index < highlightedChainAnnotsOffsets.length && index >= 0) {
return;
}
if (highlightedTypeAnnotsOffsets != null) {
for (int i = 0; i < highlightedTypeAnnotsOffsets.length; i += 2) {
if (textLocation >= highlightedTypeAnnotsOffsets[i] &&
textLocation <= highlightedTypeAnnotsOffsets[i + 1]) {
index = (i == 0) ? i : i / 2;
break;
}
}
}
// yes it is put on highlighted so show the annotationType
if (highlightedTypeAnnotsOffsets != null &&
index < highlightedTypeAnnotsOffsets.length && index >= 0) {
textPane.removeAll();
annotToConsiderForChain = highlightedTypeAnnots.get(index);
// now check if this annotation is already linked with something
CorefTreeNode headNode = findOutTheChainHead(annotToConsiderForChain, (String) annotSets.getSelectedItem());
if (headNode != null) {
popup1 = new JPopupMenu();
popup1.setBackground(UIManager.getLookAndFeelDefaults().
getColor("ToolTip.background"));
JLabel label1 = new JLabel("Annotation co-referenced to : \"" +
headNode.toString() + "\"");
popup1.setLayout(new FlowLayout());
popup1.add(label1);
if (popupWindow != null && popupWindow.isVisible()) {
popupWindow.setVisible(false);
}
popup1.setVisible(true);
popup1.show(textPane, (int) mousePoint.getX(), (int) mousePoint.getY());
}
else {
popupWindow.setVisible(false);
List<String> set = new ArrayList<String>(currentSelections.keySet());
Collections.sort(set);
set.add(0, "[New Chain]");
model = new DefaultComboBoxModel<String>(set.toArray(new String[set.size()]));
list.setModel(model);
listEditor.setItem("");
label.setText("Add \"" + getString(annotToConsiderForChain) +
"\" to ");
Point topLeft = textPane.getLocationOnScreen();
int x = topLeft.x + (int) mousePoint.getX();
int y = topLeft.y + (int) mousePoint.getY();
popupWindow.setLocation(x, y);
if (popup1.isVisible()) {
popup1.setVisible(false);
}
popupWindow.pack();
popupWindow.setVisible(true);
listEditor.requestFocus();
if (firstTime) {
firstTime = false;
popupWindow.pack();
popupWindow.repaint();
listEditor.requestFocus();
}
}
}
}