-
January 19th, 2012, 10:35 AM
#1
[RESOLVED] swing case-JFrame
can anyone tell me how to attach one JFrame to another one??....
I mean if i have a frame including a button and when i press that button it should take me to the next frame....
-
January 19th, 2012, 12:04 PM
#2
Re: swing case-JFrame
can anyone tell me how to attach one JFrame to another one
JFrames are top level windows and so you can't attach them to other frames. You can however create a new JFrame from the button's action and display it in the same way you created your initial JFrame. If you want to display a new window that is a child of your existing JFrame then use a JDialog.
when i press that button it should take me to the next frame
What do you mean by "take me to the next frame"?
-
January 20th, 2012, 11:53 AM
#3
Re: swing case-JFrame
What do you mean by "take me to the next frame"?
i meant that it should take me to the next window(frame)....
thanks for the advice keang....
Can you tell me some sources for learning the "java GUI"....
-
January 20th, 2012, 12:10 PM
#4
Re: swing case-JFrame
i meant that it should take me to the next window(frame)
Saying the same thing again doesn't make it any more understandable.
Can you tell me some sources for learning the "java GUI"....
Google
The java tutorial
-
January 21st, 2012, 04:23 AM
#5
Re: swing case-JFrame
As you said keang i'm going through the java tutorials....
but i'm stopped for a while because i'm not able to load an image into my program from my computer....
so can you tell me how to load the image....
-
January 21st, 2012, 05:16 AM
#6
Re: swing case-JFrame
Unless you give more information on what you are trying to do it's hard to give specific advice.
Recently I posted code on loading an image into a JPanel. Look back through my recent posts or click on the link in my signature below - where it says "Click here for examples of Java Code"
-
January 21st, 2012, 01:32 PM
#7
Re: swing case-JFrame
i just went through your code "Background image panel"....
in the "usage" section,there's a following code....
Code:
ImagePanel ip = new ImagePanel("myImage.jpg", false);
f.add(ip);
so my question is where did you get the myImage.jpg from?? i mean where it is stored in your computer and how to get it in the program....or do i have to move/copy it to some particular location??....
-
January 22nd, 2012, 06:11 AM
#8
Re: swing case-JFrame
You just have to supply the path to the file. This can be either a relative path or an absolute path ie:
Code:
ImagePanel ip = new ImagePanel("images/myImage.jpg", false);
Or
Code:
ImagePanel ip = new ImagePanel("c:/myProject/images/myImage.jpg", false);
-
January 23rd, 2012, 09:52 AM
#9
Re: swing case-JFrame
i used your code and i got the image....
then i tried another code....it was given in the java tutorial....
Code:
BufferedImage img = null;
try {
img = ImageIO.read(new File("Sample Pictures/Desert.jpg"));
} catch (IOException e) {
}
can you explain me this code and particularly the following code....
Code:
catch (IOException e) {
}
-
January 23rd, 2012, 10:04 AM
#10
Re: swing case-JFrame
Code:
img = ImageIO.read(new File("Sample Pictures/Desert.jpg"));
is slightly easier to understand if rewritten like this
Code:
File imgFile = new File("Sample Pictures/Desert.jpg");
img = ImageIO.read(imgFile);
The code creates a File object for the file specified by the relative path "Sample Pictures/Desert.jpg". It then passes this File object to the ImageIO classes read() method to obtain a BufferedImage object for this file.
Everything else is exception handling - google for Java exception handling.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|