Hallo allerseits,
ich habe das Problem, dass das PopupMenu sofort verschwindet sobald ich versuche die Comobox auszuwählen. Es sei denn ich drücke einen der Butons, dann kann ich die Combobox zwar Auswählen aber das PopupMenu verschwindet dann trotzdem. Ich bedanke mich schon mal im vorraus für die Hilfe.
[CODE lang="java" title="Mein Code:"] public class TestField
{
static JFrame frame=new JFrame("Fehlerliste");
static JPopupMenu pm;
static String[] testListe= {"bla", "blo", "bli"};
static JComboBox deleteResult = new JComboBox(testListe);
static JPanel show = new JPanel();
public static void main(String[] args) {
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(550, 400);
frame.setVisible(true);
frame.add(show);
pm = new JPopupMenu("Edit");
// create
JLabel textl = new JLabel("Are you sure you want to delete these entrys?" );
JLabel entry = new JLabel();
JButton yes = new JButton("Yes");
JButton no = new JButton("No");
// add to the popup
pm.add(textl);
pm.add(deleteResult);
pm.add(entry);
pm.add(yes);
pm.add(no);
// add the popup to the frame
int x=frame.getWidth()/2;
int y=frame.getHeight()/2;
pm.show(frame, x, y);
}
}
[/CODE]
ich habe das Problem, dass das PopupMenu sofort verschwindet sobald ich versuche die Comobox auszuwählen. Es sei denn ich drücke einen der Butons, dann kann ich die Combobox zwar Auswählen aber das PopupMenu verschwindet dann trotzdem. Ich bedanke mich schon mal im vorraus für die Hilfe.
[CODE lang="java" title="Mein Code:"] public class TestField
{
static JFrame frame=new JFrame("Fehlerliste");
static JPopupMenu pm;
static String[] testListe= {"bla", "blo", "bli"};
static JComboBox deleteResult = new JComboBox(testListe);
static JPanel show = new JPanel();
public static void main(String[] args) {
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(550, 400);
frame.setVisible(true);
frame.add(show);
pm = new JPopupMenu("Edit");
// create
JLabel textl = new JLabel("Are you sure you want to delete these entrys?" );
JLabel entry = new JLabel();
JButton yes = new JButton("Yes");
JButton no = new JButton("No");
// add to the popup
pm.add(textl);
pm.add(deleteResult);
pm.add(entry);
pm.add(yes);
pm.add(no);
// add the popup to the frame
int x=frame.getWidth()/2;
int y=frame.getHeight()/2;
pm.show(frame, x, y);
}
}
[/CODE]