getText() question
From: nu b (yrnuthin_at_yahoo.com)
Date: 10/26/03
- Next message: lcan: "Re: Java games - how to start"
- Previous message: nu b: "question about code editing"
- Next in thread: nu b: "Re: getText() question"
- Reply: nu b: "Re: getText() question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 25 Oct 2003 23:00:24 -0700
Can somebody tell me where I went wrong on this. I just want to take the
input from the textbox and display it with the paint method when the user
clicks the button.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class practice5 extends JApplet implements ActionListener
{
JLabel fLbl = new JLabel("First Name");
JTextField fText = new JTextField("",12);
String fIn = fText.getText();
JButton pu**** = new JButton("Push");
public void init()
{
Container con = getContentPane();
con.setLayout(new FlowLayout() );
con.add(fLbl);
con.add(fText);
con.add(pu****);
pu****.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
Object source = e.getSource();
if (source == pu****)
{
Graphics msg = getGraphics();
msg.drawString(fIn,10,190);
}
}
}
__________________
- Next message: lcan: "Re: Java games - how to start"
- Previous message: nu b: "question about code editing"
- Next in thread: nu b: "Re: getText() question"
- Reply: nu b: "Re: getText() question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]