NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

getting a JPanel to work

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users
View previous topic :: View next topic  
Author Message
xcoulon



Joined: 23 Jan 2009
Posts: 7
Location: Bakersfield, CA

PostPosted: Thu Jan 29, 2009 3:40 pm    Post subject: getting a JPanel to work Reply with quote

I created a JPanel form with only a single button just to test, but I cannot get it to work. Compiling and building are successful, but running or debugging shows nothing. I can't figure out how to get the gui interface to appear. I put in a main method, but even right-clicking on the java file and doing a run file does nothing. This is the main method:

public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Test_JPanel().setVisible(true);
}
});
}

Any clues as to how to get this to work?

Thanks

Chris
Back to top
HandyGeek
Posted via mailing list.





PostPosted: Sat Jan 31, 2009 5:28 am    Post subject: getting a JPanel to work Reply with quote

Hello Christopher,
Did you build your JPanel and command button using the GUI builder, or
are you hand-coding? Please give a few more specifics on just how you
are building this app.

Best, David

xcoulon wrote:
Quote:
I created a JPanel form with only a single button just to test, but I cannot get it to work. Compiling and building are successful, but running or debugging shows nothing. I can't figure out how to get the gui interface to appear. I put in a main method, but even right-clicking on the java file and doing a run file does nothing. This is the main method:



public static void main(String args[]) {

java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {

new Test_JPanel().setVisible(true);

}

});

}



Any clues as to how to get this to work?



Thanks



Chris

------------------------
Christopher Coulon, Ph.D.






Back to top
xcoulon



Joined: 23 Jan 2009
Posts: 7
Location: Bakersfield, CA

PostPosted: Sat Jan 31, 2009 3:44 pm    Post subject: Reply with quote

Hi David, thanks for the reply!

I used the GUI builder. Created a New Project using the Java Project with Existing Sources in order to utilize ImageJ -- I create automated image analysis applications to help researchers (mostly medical and biological) automate their research. I want to build a GUI for some applications to greatly simplify its use by the researcher.

I right-click one of the packages in my project and create a JFrame class. That class has a Source and Design tab at the top of the Netbeans window containing the code. If I start with just a button (drag the button to the design area) and compile and run the JFrame class (by right-clicking its java file and selecting Run File from the drop-down menu), I get a Build Successful in the output and the name of the class momentarily appears in the Apple menu -- as if a new application has started -- but no frame appears and the name disappears after a second or two.

I am using a MacBook Pro 2.4 gHz Intel duo with OS X 10.5.6 and java 1.5
Back to top
HandyGeek
Posted via mailing list.





PostPosted: Sun Feb 01, 2009 4:03 am    Post subject: getting a JPanel to work Reply with quote

Hi Christopher,
It sounds as if you are doing everything correctly. So, what if you try
creating a plain Java Application, where NetBeans creates the Ant
script, and not utilizing ImageJ? If that works, then there must be
something with either ImageJ, or the existing Ant script. I would also
recommend that you use the latest NetBeans, and Java6, which I think is
at U11 now. Hope something here helps. Best, David

xcoulon wrote:
Quote:
Hi David, thanks for the reply!



I used the GUI builder. Created a New Project using the Java Project with Existing Sources in order to utilize ImageJ -- I create automated image analysis applications to help researchers (mostly medical and biological) automate their research. I want to build a GUI for some applications to greatly simplify its use by the researcher.



I right-click one of the packages in my project and create a JFrame class. That class has a Source and Design tab at the top of the Netbeans window containing the code. If I start with just a button (drag the button to the design area) and compile and run the JFrame class (by right-clicking its java file and selecting Run File from the drop-down menu), I get a Build Successful in the output and the name of the class momentarily appears in the Apple menu -- as if a new application has started -- but no frame appears and the name disappears after a second or two.



I am using a MacBook Pro 2.4 gHz Intel duo with OS X 10.5.6 and java 1.5

------------------------
Christopher Coulon, Ph.D.






Back to top
TheBigFish



Joined: 30 Jan 2009
Posts: 19

PostPosted: Sun Feb 01, 2009 6:11 am    Post subject: getting a JPanel to work Reply with quote

"I am using a MacBook Pro 2.4 gHz Intel duo with OS X 10.5.6 and java 1.5"

Well there's your problem.

On Sat, Jan 31, 2009 at 9:45 AM, xcoulon <address-removed ([email]address-removed[/email])> wrote:
Quote:
Hi David, thanks for the reply!



I used the GUI builder. Created a New Project using the Java Project with Existing Sources in order to utilize ImageJ -- I create automated image analysis applications to help researchers (mostly medical and biological) automate their research. I want to build a GUI for some applications to greatly simplify its use by the researcher.



I right-click one of the packages in my project and create a JFrame class. That class has a Source and Design tab at the top of the Netbeans window containing the code. If I start with just a button (drag the button to the design area) and compile and run the JFrame class (by right-clicking its java file and selecting Run File from the drop-down menu), I get a Build Successful in the output and the name of the class momentarily appears in the Apple menu -- as if a new application has started -- but no frame appears and the name disappears after a second or two.



I am using a MacBook Pro 2.4 gHz Intel duo with OS X 10.5.6 and java 1.5

------------------------
Christopher Coulon, Ph.D.







--
Wm. Jaye Bass
Torch Technologies
office phone: 256-876-4895

"Simplicate, then add lightness"
Back to top
xcoulon



Joined: 23 Jan 2009
Posts: 7
Location: Bakersfield, CA

PostPosted: Sun Feb 01, 2009 4:12 pm    Post subject: Re: getting a JPanel to work Reply with quote

Thanks for the suggestion David. I was not creating the JFrame correctly. I had selected the new JPanel instead of the JFrame, so I was unable to get a frame to hold my components. Now I can create and see a test frame, but it is displayed as a separate application. If I run the java file, I see the frame, but if I run or debug the project, which brings up an instance of ImageJ, I cannot see my frame. I put in a main method and was able to see my JFrame class in the ImageJ Plugins pull down menu, but trying to run it from there does nothing.

It must be something in the Ant project of ImageJ that doesn't allow the Swing components to be displayed. I am over my head here, which is why I am asking for help. I know dialogs can be build from AWT containers and components, but is it possible to use Swing? And if not, can the GUI build ANT components, or is it limited to Swing?

Thanks again,

Chris
Back to top
Tibbs, Richard
Posted via mailing list.





PostPosted: Mon Feb 02, 2009 8:41 pm    Post subject: getting a JPanel to work Reply with quote

I am a customer
Richard =
Back to top
Tibbs, Richard
Posted via mailing list.





PostPosted: Mon Feb 02, 2009 8:42 pm    Post subject: getting a JPanel to work Reply with quote

I am a customer
Richard =
Back to top
Tibbs, Richard
Posted via mailing list.





PostPosted: Mon Feb 02, 2009 8:42 pm    Post subject: getting a JPanel to work Reply with quote

I am a customer
Richard =
Back to top
Tibbs, Richard
Posted via mailing list.





PostPosted: Mon Feb 02, 2009 9:34 pm    Post subject: getting a JPanel to work Reply with quote

I am a customer
Richard =
Back to top
Tibbs, Richard
Posted via mailing list.





PostPosted: Mon Feb 02, 2009 9:35 pm    Post subject: getting a JPanel to work Reply with quote

I am a customer
Richard =
Back to top
Tibbs, Richard
Posted via mailing list.





PostPosted: Mon Feb 02, 2009 9:35 pm    Post subject: getting a JPanel to work Reply with quote

I am a customer
Richard =
Back to top
xcoulon



Joined: 23 Jan 2009
Posts: 7
Location: Bakersfield, CA

PostPosted: Fri Mar 17, 2017 5:03 pm    Post subject: Getting a JPanel to work Reply with quote

Thanks for all the help and suggestions! The matter has been resolved by Curtis Reuden, thank you very much. I didn't realize I needed a JFrame as well as a Panel, so I created a JFrame and now everything works! Live and learn! Smile
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo