Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-15-2008, 12:42 AM
Member
 
Join Date: Sep 2008
Posts: 8
fritz1474 is on a distinguished road
Grid layout frames GUI
I am having a problem with creating a calculator. I using JFrames to create a non working calculator that has the text box and the number grid, but the numbers are not coming into the frame. If I remove the text box lines, the numbers are shown. Any help is appreciated...

Here is the code:

Last edited by fritz1474 : 10-15-2008 at 05:29 AM. Reason: unknown reason
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-15-2008, 04:04 AM
Senior Member
 
Join Date: Jul 2007
Posts: 1,266
hardwired is on a distinguished road
Code:
import java.awt.BorderLayout; import java.awt.GridLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTextField; public class GLF extends JFrame { private JTextField textField1; private JButton[] buttons; private final String[] names = { "7", "8", "9", "/", "4", "5", "6", "*","1","2","3","-","0",".","=","+" }; public GLF() { super( "Calculator" ); System.out.println("default layout manager for JFrame = " + getLayout().getClass().getName()); textField1 = new JTextField( 10 ); textField1.setHorizontalAlignment(JTextField.RIGHT ); // same as getContentPane().add(textField1,... add( textField1,BorderLayout.NORTH ); JPanel center = new JPanel( new GridLayout(4,4,1,1) ); buttons = new JButton[ names.length ]; // create array of JButtons for ( int count = 0; count < names.length; count++ ) { buttons[ count ] = new JButton( names[ count ] ); //buttons[ count ].addActionListener( this ); center.add( buttons[count]); } add(center, BorderLayout.CENTER); pack(); setVisible(true); } public static void main(String[] args) { new GLF(); } }
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
What are the hot java frames works on demand mallaravi Web Frameworks 1 10-28-2008 03:34 PM
Help needed in Frames text alignment ravjot28 Java Applets 2 06-27-2008 06:42 PM
Editing video frames in JMF russ2620 Networking 0 05-31-2008 01:26 AM
Help with Grid Layout coco AWT / Swing 1 08-06-2007 10:03 PM
will java webBrowser work with frames elipford New To Java 2 06-04-2007 05:26 PM


All times are GMT +3. The time now is 11:58 AM.


VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org