I am using Netbeans. I have one JFrame with JMenu, and one JDialog. I want to show the dialog when i click the menu, but it doesn't work. I only wrote this codes to my jframe and i didn't add or change any codes on the dialog:

private void jMenu1ActionPerformed(java.awt.event.ActionEvent evt)
{
   frm_edi ed= new frm_edi(this,true);
   ed.setVisible(true);
}

Help me please. Or if you don't use Netbeans, can you please show me a simple example of a GUI in Java in case of:
The GUI consist of a JFrame with only one button and a JDialog.
When we click the button, it shows the JDialog.

Thank U very much for any help..

Recommended Answers

All 7 Replies

private void mnOneActionPerformed(java.awt.event.ActionEvent evt)
    {
        jDialog1.setVisible(true);
    }

shows the dialog on my netbeans(6.9), depends on what you mean by show?

Krefie

For more precise: I build the JDialog from File-New File-Swing GUI Forms-JDialog Form and I name it: frm_edi
I'm using Netbeans 6.5. I've tried your code and it doesn't work.

-_- could you post ur whole code for me plz

krefie

Sorry for late reply. Those are all codes I wrote, nothing more. I think I have fixed the problem. I added a menu item named jMenuItem9 below the jMenu1 (previously i only had one menu, without any menu item below) and I applied relatively the same code like these in the JFrame:

private void jMenuItem9ActionPerformed(java.awt.event.ActionEvent evt)
{
   frm_entry_indent fei= new frm_entry_indent(this,true);
   fei.setVisible(true);
}

And it succeeded calling the jDialog named frm_entry_indent. In Netbeans we cannot add a menu without menu item below it because when we add code to that menu, it won't run.

hmmmm,

yeah, thats exactly what I did, soz I didnt notice that!

wel atleast you got it working then?

Regards Krefie

what is this true for.... means

frm_entry_indent fei= new frm_entry_indent(this,true);

kindly reply....

what is this true for.... means

frm_entry_indent fei= new frm_entry_indent(this,true);

kindly reply....

He wouldn't know as it is IDE generated code. Obviously another drag&drop NetBeans developer in making that has no clue about coding

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.