Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: sending a parameter to a new JDialog

  1. #1
    Junior Member
    Join Date
    Sep 2011
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question sending a parameter to a new JDialog

    Hello everyone, from my main window, I am opening a new JDialog window and I want to send a parameter from the main

    Opening the new window

    ExtensionUI extensionUI = new ExtensionUI(this, true);
    extensionUI.setVisible(true);

    and from the main of this new class,

    ExtensionUI dialog = new ExtensionUI(new javax.swing.JFrame(), true);

    and then the constructor

    public ExtensionUI(java.awt.Frame parent, boolean modal) {
    super(parent, modal);
    initComponents();
    parent.printSomething();
    }

    in the main window I have a method println something, but I cant access thru parent.print();
    isn't that parent the main itself or is it like an instance of the JFrame of the main instead? don't know if I explained myself

    thanks!


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,387
    My Mood
    Hungover
    Thanks
    144
    Thanked 628 Times in 538 Posts

    Default Re: sending a parameter to a new JDialog

    I'm pretty unclear about what you're trying to do. Maybe it would be better if you provided an SSCCE that demonstrates what you're talking about?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Sep 2011
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: sending a parameter to a new JDialog

    I want to send a parameter to the new JDialog opening window from the main JFrame window, ie a String.

  4. #4
    Junior Member
    Join Date
    Sep 2011
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: sending a parameter to a new JDialog

    I couldn't do it thru the constructor, so after I created the new JDialog instance and opened it, I sent the parameter thru a setMethod.
    It also works, so thanks anyway

  5. #5
    Junior Member
    Join Date
    Sep 2011
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: sending a parameter to a new JDialog

    ok I found out my mistake, I was leaving uncommented the main part that calls the constructor inside the new JDialog class, but as I was opening the JDialog from another window, I didn't need the main, so I commented and just passed the value to the constructor and everything fine, Thanks everyone!

Similar Threads

  1. Sending large Strings ?! only sending a line
    By camel in forum Java Networking
    Replies: 2
    Last Post: April 19th, 2011, 12:41 PM
  2. [SOLVED] Click button to open JDialog
    By susieferrari in forum Java Theory & Questions
    Replies: 6
    Last Post: March 30th, 2011, 09:24 AM
  3. [SOLVED] Send and Receive Parameter
    By java_mein in forum JavaServer Pages: JSP & JSTL
    Replies: 2
    Last Post: May 14th, 2010, 02:22 PM
  4. close JDialog on button click
    By Christophe in forum AWT / Java Swing
    Replies: 4
    Last Post: April 4th, 2010, 11:04 PM
  5. How do you pass an Array as a Parameter?
    By Arius in forum Java Theory & Questions
    Replies: 1
    Last Post: January 23rd, 2010, 08:36 PM