Archived

This topic is now archived and is closed to further replies.

DKN

[java] Window error

Recommended Posts

DKN    122
I''m trying to make this window and I get these errors. Errors: http://www.sonicfighters.com/rpg/errors.txt Code: http://www.sonicfighters.com/rpg/code.txt What am I doing wrong?

Share this post


Link to post
Share on other sites
DKN    122
Well I when I make it applet, it opens up two windows. One is a big grey window which is what I wanted and the second is a smaller window with the graphics and buttons on it, but I wanted the graphics and buttons to be on the canvas one. What do I do?

[edited by - DKN on May 25, 2004 3:17:02 PM]

Share this post


Link to post
Share on other sites
nonnus29    105
quote:
Original post by DKN
Well I when I make it applet, it opens up two windows. One is a big grey window which is what I wanted and the second is a smaller window with the graphics and buttons on it, but I wanted the graphics and buttons to be on the canvas one. What do I do?

[edited by - DKN on May 25, 2004 3:17:02 PM]


You can start off by reading this:

http://java.sun.com/docs/books/tutorial/uiswing/index.html

And the tutorials here:

http://grexengine.com/sections/externalgames/

I've linked to the sun tute twice and other people have directed you to it. You really need to start helping yourself.



[edited by - nonnus29 on May 26, 2004 8:09:23 AM]

Share this post


Link to post
Share on other sites
DKN    122
quote:
Original post by nonnus29
quote:
Original post by DKN
Well I when I make it applet, it opens up two windows. One is a big grey window which is what I wanted and the second is a smaller window with the graphics and buttons on it, but I wanted the graphics and buttons to be on the canvas one. What do I do?

[edited by - DKN on May 25, 2004 3:17:02 PM]


You can start off by reading this:

http://java.sun.com/docs/books/tutorial/uiswing/index.html

And the tutorials here:

http://grexengine.com/sections/externalgames/

I''ve linked to the sun tute twice and other people have directed you to it. You really need to start helping yourself.



[edited by - nonnus29 on May 26, 2004 8:09:23 AM]

geez don''t tell me to help myself because I am...you don''t know how many hours I spent at this and some people like myself have a really hard time understanding things. And so what if someone has posted about the sun site, people have also told me to just post if I don''t understand something. I do read. So I thank the people who have helped me so far.

Share this post


Link to post
Share on other sites
Koroljov    115
1) It is not a good idea to load images in the paint void.
2) You should make 2 classes, like this

class someClass extends Applet
{

public void init()
{
Image img=getImage(getDocumentBase(),"img.jpg");
//wait till the image is loaded
MediaTracker mt=new MediaTracker(this);
try{
mt.addImage(img,0);
mt.waitForAll();
}catch(Exception ex){}
//create the window
MyWindow w=new MyWindow(img);
}

}

class MyWindow extends JFrame
{
Image img;

public MyWindow(Image img)
{
this.img=img;
//initialise the layout, add some components...
pack();
show();
}

public void paint(Graphics g)
{
//draw the image.
}

}

[edited by - Koroljov on May 26, 2004 12:29:30 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
For starters, you gave us very little code and a no detail description of the problem, its not even clear what you want to do; are you making an applet or an app? Do you understand the difference between an applet and an application? How well do you understand oop programming? Not very well I''m betting after I see this:

JPanel panel = (JPanel) frame.getContentPane();

Its important to start with the basics. Its good to ask questions, but you''re not asking the right questions and its obvious you haven''t studied the links posted. We''ve all been newbies, but you really have to get used to reading other peoples code and learning from examples if you want to make it far in programming.

Don''t get discouraged. Keep asking questions.

Share this post


Link to post
Share on other sites
Strife    374
quote:
Original post by DKN
geez don''t tell me to help myself because I am...you don''t know how many hours I spent at this and some people like myself have a really hard time understanding things. And so what if someone has posted about the sun site, people have also told me to just post if I don''t understand something. I do read. So I thank the people who have helped me so far.


Don''t get upset, you gave us very little to work with. Rather than simply posting errors and code, you should tell us what you have already tried, what you think may be the problem, etc., etc. All of this will help anyone who is willing to help you. When you don''t post what you''ve tried, many people may (wrongfully or not) assume that you haven''t even really tried to fix it yet, so will point you to tutorials. So please, help us help you.

Share this post


Link to post
Share on other sites
DKN    122
Well alright. I''ve just completed a year of a java course and obvisously haven''t gotten that far and I do understand the theory, but that''s basically all I learned out of that course and not how to apply things and I read others people''s code day and night. That''s why my code is the way it is from the examples I find. So in the future I''ll post more detailed posts.

Share this post


Link to post
Share on other sites