Skip to main content
gamedev.net
🔒 Locked

[java] Making a button show?

Started by SticksandStones Apr 1, 2005 at 9:35 AM 0 replies 600+ views
Original Post
SticksandStones
SticksandStones
Ok I'm making a simple Java app, but I can't seem to get the button to show. The API documention isn't helping any, either. Here is the code:
import java.awt.*;
import java.awt.event.*;

class Calculator extends Frame {
	
	public Calculator() {
		addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				dispose();
				System.exit(0);
			}
		});
	}

	public static void main(String args[]) {
		System.out.println("Starting Calculator...");
		Calculator mainFrame = new Calculator();
		mainFrame.setSize(400, 400);
		mainFrame.setTitle("Calculator");
		mainFrame.setVisible(true);
		Button addB = new Button("Add");
		addB.setSize(25,25);
		addB.setLocation(100,100);
		addB.setVisible(true);
	}
}

Am I doing something terribly wrong that the button won't show up? UPDATE: I'm an a bigger idiot than I thought, I didn't call mainFrame.add(add); .... [Edited by - Gunslinger RR on April 1, 2005 9:52:43 AM]
hippopotomonstrosesquippedaliophobia- the fear of big words
phil05
phil05
Button myButton = new Button("Submit");
add(myButton);

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.