I appreciate for your help.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class JColor extends JApplet implements ActionListener
{
int width, height;
JButton enlargeButton = new JButton("Enlarge");
Font bigFont = new Font("Helvetica", Font.BOLD, 24);
String hello = "Hello";
Container con = getContentPane();
public void init()
{
con.setLayout(new FlowLayout());
con.add(enlargeButton);
con.setBackground(Color.BLUE);
enlargeButton.addActionListener(this);
width = hello.getTextWidth();
height = hello.getTextHeight();
}
public void actionPerformed(ActionEvent e)
{
width = width * 2;
height = height * 2;
repaint();
}
public void paint(Graphics g)
{
super.paint(g);
g.drawString(hello.getText(), 0, 0, width, height, this);
}
}
Errors:
JColor.java:19: cannot find symbol
symbol: method getTextWidth()
location: class java.lang.String
width = hello.getTextWidth();
JColor.java:19: cannot find symbol
symbol: method getTextHeight()
location: class java.lang.String
width = hello.getTextHeight();
JColor.java:19: cannot find symbol
symbol: method getText()
location: class java.lang.String
width = hello.getText(), 0, 0 width, height, this);

New Topic/Question
Reply




MultiQuote









|