Results 1 to 2 of 2
Thread: Grid layout frames GUI
- 10-14-2008, 11:42 PM #1
Member
- Join Date
- Sep 2008
- Posts
- 8
- Rep Power
- 0
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 04:29 AM. Reason: unknown reason
- 10-15-2008, 03:04 AM #2Java 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(); } }
Similar Threads
-
What are the hot java frames works on demand
By mallaravi in forum Web FrameworksReplies: 1Last Post: 10-28-2008, 02:34 PM -
Help needed in Frames text alignment
By ravjot28 in forum Java AppletsReplies: 2Last Post: 06-27-2008, 05:42 PM -
Editing video frames in JMF
By russ2620 in forum NetworkingReplies: 0Last Post: 05-31-2008, 12:26 AM -
Help with Grid Layout
By coco in forum AWT / SwingReplies: 1Last Post: 08-06-2007, 09:03 PM -
will java webBrowser work with frames
By elipford in forum New To JavaReplies: 2Last Post: 06-04-2007, 04:26 PM
Bookmarks