I just started IB computer science and the programming language is java which I had only use a few times to do very simple variable programs. I knew c++ fairly all of the basics I needed to make a program , I did an allegro game with basic movement. (Just some background)
First I don't want my homework done for me not even near done, but I do need some references besides the ones I get in school well here is what I need to do.
A panel which greets the user with a message like "typer your name and then press enter"
and after that make the previous prompt be replsce with something like hi how are you + name.
Does anyone know how can I center the items aswell?
here is what I got some far....
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class HelloWorldPanel extends JPanel
{
JLabel helloMsg;
public HelloWorldPanel(){
setLayout(new FlowLayout());
JLabel helloMsg = new JLabel("Hello World");
add(helloMsg);
TextField enterName = new TextField("Enter name here");
add(enterName);
Button Enter = new Button("Enter");
add(Enter);
}
public static void main(String[] args)
{
JFrame frame = new JFrame("Assignment1");
frame.setSize(250, 100);
frame.setLocation(200, 100);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setContentPane(new HelloWorldPanel());
frame.setVisible(true);
}
}


Sign In
Create Account


Back to top









