Jump to content
  • Advertisement
Sign in to follow this  
dojo

I need help fixing some code i made with java

This topic is 4836 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i am new to j2sdk and hava begin to insted some od the basic.i have coded something but when i compile it it always comes up with erors mostley 'class' or 'interface expected.I am about to show you the code but before i do that i should tell you what i was hoping the output would be,i wanted it so you endterd a name clicked log in and came up with text saying welcome + username. and under it saynig something else THE CODE!!!!! import java.awt.*; import java.awt.event.*; import java.applet.*; public class login extends Applet implements ActionListner { string username public void init(); } g.drawstring("enter your name and press enter!then click log in!" ,50 ,40); name=(int) system.in.read() G.drawstring("So your name is " + usernamename, 60, 30); g.drawstring("Know click the log in button to see latest news!") Button btnClick = new Button btnClick.addActionlistner(that); add(btnClick;) } string butname = e.getActionCommand(); { g.drawstring("Welcome " + username, 70, 20); repaint(); } g.drawstring("Xbox 360 news see at reviews, 80, 10"); public void paint (Graphics g) } g.setFont(new Font("impact" ,Font.ITALIC,30)); } } }

Share this post


Link to post
Share on other sites
Advertisement
See the source code. I suggest you either buy a book on Java or follow some tutorials, because the code you wrote it, errm... Pretty much messed up and broken.


import java.awt.*;
import java.awt.event.*;
import java.applet.*;

public class login extends Applet implements ActionListener // It's ActionListener, you made a type
{
string username; // <- You forgot a ;

public void init(); // <- Where is the function body???!??!

}

// Whoa, this is OUTSIDE the class. Move it into a function INSIDE the class.
g.drawstring("enter your name and press enter!then click log in!" ,50 ,40);

name=(int) system.in.read()

G.drawstring("So your name is " + usernamename, 60, 30);
g.drawstring("Know click the log in button to see latest news!")

Button btnClick = new Button
btnClick.addActionlistner(that);
add(btnClick;)
}

string butname = e.getActionCommand();

{
g.drawstring("Welcome " + username, 70, 20);
repaint();
}
g.drawstring("Xbox 360 news see at reviews, 80, 10");

public void paint (Graphics g)

}
g.setFont(new Font("impact" ,Font.ITALIC,30));
}


}
}



Toolmaker

Share this post


Link to post
Share on other sites
Is that the actual code?? Quite a few typos..

- change string to String
- add a ; after string username
- don't have a ; after public void init() (you're not writing an interface or an abstract class)
- have a { after public void init()
- change system to System
- okay I give up, there's too many

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!