Your button problem is actually due to the Grid Layout manager. Any component placed in a grid will take up all of the space allocated to it. In this case a full sixth of the frame. If you want a smaller butter use either GridBagLayout, or, more simply add a new panel and place the button in it.
Panel p = new Panel( ); Button b = new Button( "button");
p.add( b ); add( p );
Then then the button will be placed with FlowLayout in the Panel (and thus not increased in size) While the panel will take up the whole chunk of screen.
Good luck
From: "Tim Nicholson" <[EMAIL PROTECTED]> Reply-To: "jdjlist" <[EMAIL PROTECTED]> To: "jdjlist" <[EMAIL PROTECTED]> Subject: [jdjlist] trying to master Buttons.... Date: Tue, 25 Feb 2003 00:00:11 +1000
Hi list,
I am trying to master Buttons -- and have been having a few problems.
First I have 1 or 2 questions :-
1) What is the difference between a Button and a JButton ? Or in the same way, between a Frame and a JFrame ?
Button seems to be a class in the java.awt library. But what about if you put a "J" in front of it ?
2) My problem at the moment is trying to get my Button in the code below to match up to my expectations. I managed to get a GUI going and to incorporate a Button into it -- but the problem is that the Button takes up half of the GUI (the top half). I wanted a nice small Button and in a place where I could choose to put it. Instead what I got was this huge thing that takes up half the screen and I have no say as to where I would like to put it.
Can someone give me some pointers as to how I can modify my code to achieve what I want ?
//--------------------------------------------------------------------
import java.awt.*; import java.awt.event.*;
public class File1 extends Frame implements ActionListener{
//button is a GUI component //GUI (Graphic User Interface
private Button setbutton;
public File1() {
setLayout(new GridLayout(3,2));
setbutton = new Button("SET"); add(setbutton); setbutton.addActionListener(this);
setSize(300,100); setTitle("Kitchen System"); setVisible(true);
}//end of constructor
//--------------------------------------------------------------- //actionPerformed //---------------------------------------------------------------
public void actionPerformed (ActionEvent e) { Button b = (Button)e.getSource();
if (b == setbutton) {
}//end of if
}//end of actionPerf
public static void main(String [] args) { new File1();
}
}//end of class
---
You are currently subscribed to jdjlist as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
http://www.sys-con.com/fusetalk
_________________________________________________________________
MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. http://join.msn.com/?page=features/virus
--- You are currently subscribed to jdjlist as: [EMAIL PROTECTED] To unsubscribe send a blank email to [EMAIL PROTECTED] http://www.sys-con.com/fusetalk
