Hello fellow Java programmers,
I have a problem with focusing a JFrame on top. I'll be really gald if anyone can help me out.
I created a JButton on a JPanel(which inturn is a part of another JPanel). I would like to have a window pop up when this button is clicked. Unfortunately the window I created(JFrame) pops, but stays behind this JPanel and I can only see it after I close this JPanel. I used the setAlwaysOnTop(true), but to no use. Infact, doing so is causing the JPanel to stay always on top. Here is the code for action performed event of the button
mButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { startMetadataEdit(); } }); } private void startMetadataEdit() { MarkerMetadata mmd = getMetadata(); MetadataEditPanel mMep = new MetadataEditPanel(mmd); mMep.setVisible(true); }
The constructor of MetadataEditPanel contains a function initComponents(), which declares and defines the components of the pop-up window. I tried putting all sorts of function calls in initCompnents(), like setAlwaysonTop(true), setFocusable(true), but nothing worked out. I created this UI on netbeans and i'm using this code in Eclipse(Yes, I'm a bit lazy to write GUI code).
So, does anyone have any suggestions/solutions? Thanks in advance