Results 1 to 15 of 15
Like Tree1Likes
  • 1 Post By vknehra10

Thread: Open new JFrame

  1. #1
    vknehra10 is offline Senior Member
    Join Date
    Dec 2016
    Posts
    103
    Rep Power
    0

    Default Open new JFrame

    Hey,

    Anybody knows that how to to open new window after clicking on button...

    Thanks

  2. #2
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,989
    Rep Power
    8

    Default Re: Open new JFrame

    Yup, I do. And so does Google.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2™ © 2013

  3. #3
    vknehra10 is offline Senior Member
    Join Date
    Dec 2016
    Posts
    103
    Rep Power
    0

    Default Re: Open new JFrame

    Java Code:
    JTextArea t,t1,t2,t3;
    
    t=new JTextArea("This text is showing");
    t1=new JTextArea("this  text is not showing why?");
    ]

    Thanks
    Last edited by vknehra10; 04-10-2017 at 07:25 PM.

  4. #4
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,989
    Rep Power
    8

    Default Re: Open new JFrame

    First, there is no code that you are showing that adds the JTextAreas to the contentpane. (I am pretty sure you are not showing us all of the code....)
    Second, this is SO totally unrelated to your question, did you even get to solve your first issue?
    Third, try to open spearate threads for separate issues. This makes is better to find for other readers.
    Fourth, remember to use a LayoutManager that supports multiple components. (GridLayout, GridBagLayout, FlowLayout, etc.)
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2™ © 2013

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    25

    Default Re: Open new JFrame

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  6. #6
    vknehra10 is offline Senior Member
    Join Date
    Dec 2016
    Posts
    103
    Rep Power
    0

    Default Re: Open new JFrame

    my first issue is solved
    Second i can;t access my "Post New Thread" even i logged in that's why i ask here
    i want that i am creating user agreement so i am using JTextArea is this right??

    Thanks

  7. #7
    vknehra10 is offline Senior Member
    Join Date
    Dec 2016
    Posts
    103
    Rep Power
    0

    Default Re: Open new JFrame

    i am creating GUI without net beans
    DarrylBurke likes this.

  8. #8
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,989
    Rep Power
    8

    Default Re: Open new JFrame

    Quote Originally Posted by vknehra10 View Post
    my first issue is solved
    Second i can;t access my "Post New Thread" even i logged in that's why i ask here
    i want that i am creating user agreement so i am using JTextArea is this right??

    Thanks
    You're the only one who knows if this is right. It's certainly possible. It doesn't matter if you use Netbeans or not. That trail Darryl has linked is about using the Swing components. That is unrelated to Netbeans.

    You can use a JPanel with a BorderLayout. Put the JTextArea in the center area and another JPanel (with FlowLayout for the I agree/disagree buttons) at the south area.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2™ © 2013

  9. #9
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: Open new JFrame

    Quote Originally Posted by vknehra10 View Post
    i am creating GUI without net beans
    Only one of those links on that page (the second one) deals with the Netbeans GUI builder.
    The rest explain how the various Swing components work.

    And good choice, by the way. Despite what it says on that tutorial page, the GUI builder is not (in my opinion) the easiest way to learn Swing.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  10. #10
    vknehra10 is offline Senior Member
    Join Date
    Dec 2016
    Posts
    103
    Rep Power
    0

    Default Open new JFrame by clicking on button Help!!

    Hey

    i want that if i click on "Next" button then my new window will open. I can't find any code and i am not using Netbeans

    so please don't tell on Netbeans

    Thanks !!

  11. #11
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,989
    Rep Power
    8

    Default Re: Open new JFrame by clicking on button Help!!

    Programming is to divide and conquer. Split your requirements in sub-requirements that are AS SMALL AS POSSIBLE.

    So, "I want my button to open a new window" has several sub-problems to solve:
    1) Place a button somewhere (JButton)
    2) Make the button listen to interactions (add ActionListener, or add Action)
    3) Open a new JFrame (JFrame f = new JFrame() )

    I assume you got 1 done. Now for number 2: research JButton, Actions and ActionListeners. Print out "Hello World" to System.out. Make sure you understand how Actions and/or ActionListeners work.

    Number 3 can be found all over the interwebs. Combine the knowledge of 1, 2 and 3 to get where you want.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2™ © 2013

  12. #12
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Open new JFrame by clicking on button Help!!

    And the solution would be the same whether you are using NetBeans, Eclipse, the IDE du jour, or a text editor.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  13. #13
    vknehra10 is offline Senior Member
    Join Date
    Dec 2016
    Posts
    103
    Rep Power
    0

    Default Re: Open new JFrame by clicking on button Help!!

    No Bro all is set button is set Frame is set ...i want that when i click on button another window will open.....

  14. #14
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: Open new JFrame by clicking on button Help!!

    Did you try what SurfMan suggested in post#2?

    Post the code to show what you have tried. Add some questions about any problems you are having.
    Be sure to wrap the posted code in code tags.
    If you don't understand my response, don't ignore it, ask a question.

  15. #15
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Open new JFrame by clicking on button Help!!

    1. You have to put the button somewhere. At a minimum, that would be a frame.
    2. When you click on the button it generates an event.
    3. The button handler handles the event and opens either a new window or a new frame.

    So you need to understand buttons and events.


    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. JFrame won't open
    By Chri in forum New To Java
    Replies: 9
    Last Post: 11-06-2012, 06:03 PM
  2. Close a JFrame, but keep the original open.
    By nolsen01 in forum AWT / Swing
    Replies: 3
    Last Post: 06-13-2011, 11:28 PM
  3. how to open a new JFrame from a JFrame
    By nashbender in forum AWT / Swing
    Replies: 7
    Last Post: 05-24-2011, 04:57 AM
  4. How do i open JFrame in the same active window
    By Jkiller295 in forum AWT / Swing
    Replies: 35
    Last Post: 06-02-2010, 04:50 PM
  5. Open JFrame
    By AndersBjörnör in forum AWT / Swing
    Replies: 2
    Last Post: 12-01-2009, 09:03 PM

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
  •