0
JComboBox
は、add(PopUpMenu)
とadd(JMenuItem)
です。JComboのサブメニュー
私のクラスはJComboBoxを拡張しています。私はJPopUpMenuを作成しますが、JComboBoxをクリックすると表示されません。代わりに何も表示されません。何か案は?
JPopupMenu Pmenu = new JPopupMenu();
JMenu textAndDataMenu = new JMenu("Text and Data");
HashMap textAndData = new HashMap();
public ComboMenu()
{
super();
setUpTextAndData();
add(Pmenu); //----------this is where I add the menu
}
public void setUpTextAndData()
{
textAndData.put("Basic Text Box", TextBox.class);
textAndData.put("Clear Text Box", ClearTextBox.class);
textAndData.put("Table", Table.class);
textAndData.put("Interactive Table", InteractiveTable.class);
textAndData.put("Graph", Graph.class);
Set textAndDataKeys = textAndData.keySet();
JMenuItem newMenuItem;
for(String currKey : textAndDataKeys)
{
newMenuItem = new JMenuItem(currKey);
newMenuItem.addActionListener(this);
textAndDataMenu.add(newMenuItem);
}
Pmenu.add(textAndDataMenu);
}
JMenusをPopUpMenuに追加する前にJMenusを追加して、JMenusがサブメニューになるようにしました。私が達成しようとしているのはJComboBoxです.JComboBoxをクリックすると、ネストされたアイテムにアクセスできます。どのようにこれを達成するための任意のアイデア? – user489041
私の編集を見て、私はそれを見て間違った道を下ったと思う。 –