Results 1 to 4 of 4
Like Tree1Likes
  • 1 Post By Fubarable

Thread: netbeans jframe access problem

  1. #1
    delican is offline Member
    Join Date
    Aug 2011
    Posts
    13
    Rep Power
    0

    Default netbeans jframe access problem

    Hi everyone, I'm new to java development. I want to access one frame which was created in same project but I can not do this. also access different variables or components value from different frames. please help me, I know it is easy but takes lots of time of me.


    edit: I opened the same thread but I could not delete opened thread, sorry.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Your other thread has been deleted.

    Regarding your question, you have one ojbect access other objects in Swing same way as any other Java program: One object needs a reference to the other, often held in a variable in order to be able to call methods on the other object. So for instance,

    Java Code:
    class JFrame1 extends JFrame {
       public void methodInJframe1() {
          System.out.println("in JFrame1");
       }
    }
    
    class JFrame2 extends JFrame {
       private JFrame1 frame1; // my JFrame1 reference variable
    
       // pass a JFrame1 object into the constructor
       public JFrame2(String title, JFrame1 frame1) {
          super(title);
          this.frame1 = frame1; // set the reference
       }
    }
    Also, if you're just learning Swing and especially if you're just learning Java, I strongly urge you not to use NetBean's drag-and-drop Swing code generation to create your Swing GUI's. It's not really a tool for beginners as there are a lot of traps, and you're much better off first learning to create Swing GUI's by hand.
    delican likes this.

  3. #3
    delican is offline Member
    Join Date
    Aug 2011
    Posts
    13
    Rep Power
    0

    Default

    I must write in java cos of lack of library support in csharp. gui is more complex than gui of csharp but events and delegation is so complicated to write manually in java so I use swing of netbeans . thank you Fubarable it works :))
    Last edited by delican; 08-05-2011 at 05:16 PM.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by delican View Post
    I must write in java cos of lack of library support in csharp.
    No one here is advising you not to write this in Java.


    gui is more complex than gui of csharp but events and delegation is so complicated to write manually in java so I use swing of netbeans . thank you Fubarable it works :))
    I'm not advising you to avoid using NetBeans either, just not to use its drag-and-drop code generator. You will not regret learning to code the Java Swing GUI by hand.

Similar Threads

  1. Access Child Components of JFrame?
    By PrinceSendai in forum New To Java
    Replies: 5
    Last Post: 06-22-2011, 03:18 PM
  2. Trouble adding JPanel to JFrame with NetBeans IDE
    By ozzyman in forum New To Java
    Replies: 1
    Last Post: 05-23-2011, 10:35 PM
  3. differnece between jframe and customizer in netbeans
    By theprernasharma in forum Advanced Java
    Replies: 3
    Last Post: 07-23-2010, 03:44 PM
  4. File access outside Netbeans
    By TimHuey in forum NetBeans
    Replies: 6
    Last Post: 08-30-2009, 08:52 PM

Posting Permissions

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