Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Swings help

 
Sarah Singh
Greenhorn
Posts: 11
1
C++
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Can someone help me...


//I am unable to add the textfield on to my container..like it adds but it doesnt display...Can someone decipher as to why..Thanks! ^.^
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To start with SwingIsAProperNoun (It is Swing and not Swings)

Do you realize you have 2 JFrame instances?
  • FormFrame1 extends JFrame
  • JFrame f;



  • Line 1 gets the contentPane for the Frame f;
    Line 2 gets the contentPane for FormFrame1 extends JFrame

    Then you add the pane to #1 and you go on to add the 2nd content pane to the pane! Very confusing


    The correct way to do it
    Create a JPanel instance
    Set proper layout
    Add child components to the instance
    Add the panel instance to the frame content pane
    Also, make sure the call to frame.setVisible(true) comes at the very end.

    Recommended reading: https://docs.oracle.com/javase/tutorial/uiswing/components/frame.html
     
    I think I'll just lie down here for a second. And ponder this tiny ad:
    the new thread boost feature: great for the advertiser and smooth for the coderanch user
    https://coderanch.com/t/674455/Thread-Boost-feature
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!