Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to call JDialog  RSS feed

 
ricky shaw
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have written a separate class for a JDialog. I was wondering how do we call that class in a JApplet??
 
Rob Spoor
Sheriff
Posts: 21048
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instantiate and call setVisible(true)?
 
ricky shaw
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did that but im just getting the dialog without its contents. I had added a panel and buttons to the JDialog. But these are not being displayed.
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To get better help sooner, post a SSCCE that clearly demonstrates your problem.
 
ricky shaw
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok will include the program
 
ricky shaw
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


This is the code for the JDialog
 
ricky shaw
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


This is how i call it in the JApplet.
 
Rob Spoor
Sheriff
Posts: 21048
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You never add anything to the JDialog1 instance. It has an internal JDialog with the contents, but that never gets shown. Get rid off keyDialog completely:
 
ricky shaw
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much....that worked....I have one more question....Suppose i want to perform an action from a JButton of JDialog class on the JTextField of the JApplet...how should that be done?
 
Rob Spoor
Sheriff
Posts: 21048
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The ActionListener should get a reference to that text field, or (better) get a reference to your JApplet which gets a method to do the updating. This is better so you don't get full control over the text field, which would enable you to change the colour, font, etc. I doubt you want that.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!