This is what I have thus far.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class JFontSize extends JFrame implements ActionListener
{
JButton button = new JButton("Press Me");
String aPhrase = new String("This is a phrase.");
Font aFont = new Font("Monospaced", Font.BOLD, 20);
int x = 50, y = 75;
final int GAP = 25;
final int WIDTH= 800;
final int HEIGHT = 600;
public JFontSize()
{
Container con = getContentPane();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
con.setLayout(new FlowLayout());
con.add(button);
button.addActionListener(this);
setSize(WIDTH, HEIGHT);
}
public void actionPerformed(ActionEvent e)
{
Graphics text = getGraphics();
text.drawString(aPhrase, x += GAP, y += GAP);
public void paint(Graphics g)
{
super.paint(g);
g.drawString(aPhrase, x += GAP, y += GAP);
}
public static void main(String[] args)
{
JFontSize jfSize = new JFontSize();
jfSize.setVisible(true);
}
}
The result looks something like this:
Button
This is a phrase.
This is a phrase.
This is a phrase.
This is a phrase.
etc.