Problem when displaying JFrame by button click
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Problem when displaying JFrame by button click

Threaded View

  1. #1
    Join Date
    Apr 2009
    Posts
    1

    Problem when displaying JFrame by button click

    Basically, this is my problem. I have two files: NoteFrame.java and Chords.java.

    I'm attempting to make an instance of the NoteFrame dialog appear when I click on a button in the Chords.java class.

    I have the following code in the event handler code for the button "tunerBtn" in the Chords.java class:

    private void tunerBtnActionPerformed(java.awt.event.ActionEvent evt) {
    // TODO add your handling code here:

    NoteFrame newNoteFrame = new NoteFrame();
    newNoteFrame.setVisible(true);
    newNoteFrame.pack();

    }


    This works, as in when I click the button, the NoteFrame dialog appears. However, the NoteFrame dialog is not set up as it is when I run the dialog directly from the NoteFrame class itself.

    Inside the 'main' function in the NoteFrame class I have included a function called 'run' which sets up all the JLabels, Text colours etc.. for the dialog. This doesnt seem to be called when the NoteFrame dialog is created by the button click in the Chords class..

    Is there any way to gain access to 'main' or 'run' through the Chords class in order to ensure the dialog is set up correctly..??

    Any help is appreciated,

    Thanks
    Last edited by bearchild; April 6th, 2009 at 10:18 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center