本文整理匯總了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();
}
}
}
}