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....
Printable View
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....
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.Quote:
can anyone tell me how to attach one JFrame to another one
What do you mean by "take me to the next frame"?Quote:
when i press that button it should take me to the next frame
Quote:
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"....
Saying the same thing again doesn't make it any more understandable.Quote:
i meant that it should take me to the next window(frame)
Quote:
Can you tell me some sources for learning the "java GUI"....
The java tutorial
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....
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"
i just went through your code "Background image panel"....
in the "usage" section,there's a following code....
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??....Code:ImagePanel ip = new ImagePanel("myImage.jpg", false);
f.add(ip);
You just have to supply the path to the file. This can be either a relative path or an absolute path ie:
OrCode:ImagePanel ip = new ImagePanel("images/myImage.jpg", false);
Code:ImagePanel ip = new ImagePanel("c:/myProject/images/myImage.jpg", false);
i used your code and i got the image....
then i tried another code....it was given in the java tutorial....
can you explain me this code and particularly the following code....Code:BufferedImage img = null;
try {
img = ImageIO.read(new File("Sample Pictures/Desert.jpg"));
} catch (IOException e) {
}
Code:catch (IOException e) {
}
is slightly easier to understand if rewritten like thisCode:img = ImageIO.read(new File("Sample Pictures/Desert.jpg"));
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.Code:File imgFile = new File("Sample Pictures/Desert.jpg");
img = ImageIO.read(imgFile);
Everything else is exception handling - google for Java exception handling.