Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_java thread: Help with frames???


Message #1 by Guerrino Di Minno <GDiMinno@h...> on Wed, 5 Dec 2001 14:12:06 -0500
Hello,
You can not use both Frame and Applet in your program. Frame is 
application(stand-alone) and Applet is run with HTMl. 
Regards,
Anna

>===== Original Message From "Professional Java" <pro_java@p...> =====
>Hi to all.
>
>I have a question. Can someone please look at my code and tell me why my
>labels and textfields and buttons are not appearing on my frame???
>What am I doing wrong?
>
>Can someone please help me?
>
>*** CODE ***
>
>import java.awt.*;
>import java.applet.*;
>import java.awt.event.*;
>
>public class Database extends Applet implements ActionListener
>{
>	Label lblCompanyName = new Label ("Company Name");
>	Label lblStockSymbol = new Label ("Stock Symbol");
>	Label lblStockPrice = new Label ("Stock Price");
>
>	TextField txtCompanyName = new TextField(" ", 25);
>	TextField txtStockSymbol = new TextField(" ", 5);
>	TextField txtStockPrice = new TextField(" ", 10);
>
>	Button btnUpdate = new Button("Update");
>	Button btnDelete = new Button("Delete");
>	Button btnSearch = new Button("Search");
>	Button btnAdd = new Button("Add");
>	Button btnQuit  = new Button("Quit");
>
>	private Panel Panel = new Panel();
>
>	public void init()
>	{
>
>		Panel P1 = new Panel();
>		P1.setLayout(new GridLayout(3,2));
>		P1.add(lblCompanyName);
>		P1.add(txtCompanyName);
>		P1.add(lblStockSymbol);
>		P1.add(txtStockSymbol);
>		P1.add(lblStockPrice);
>		P1.add(txtStockPrice);
>
>		Panel P2 = new Panel();
>		P2.setLayout(new FlowLayout());
>		P2.add(btnUpdate);
>		P2.add(btnDelete);
>		P2.add(btnSearch);
>		P2.add(btnAdd);
>		P2.add(btnQuit);
>
>
>		add(P1, BorderLayout.CENTER);
>		add(P2, BorderLayout.CENTER);
>
>	}
>
>	public static void main(String[] args)
>	{
>		Frame frame = new Frame("Stock Information");
>
>		Database applet = new Database();
>
>		frame.add(applet, BorderLayout.CENTER);
>
>		applet.init();
>		applet.start();
>
>		frame.setSize(400,500);
>		frame.setVisible(true);
>
>	}
>
>	public void actionPerformed(ActionEvent thisEvent)
>	{
>		String cmd = thisEvent.getActionCommand();
>		if (cmd == "Result")
>		{
>			double ResultTotal = 0;
>
>		}
>	}
>}
>
>
>
>Thanking you in advance???
>
>GINO
>
>
>


  Return to Index