Results 1 to 11 of 11
Thread: Layout Manager of JApplet
- 06-20-2008, 09:44 AM #1
Member
- Join Date
- Jun 2008
- Posts
- 6
- Rep Power
- 0
Layout Manager of JApplet
Hello to all expect Java developer, i quite new to java developer.
My assignment is want to me code a JApplet without a layout manager which allow me to adjust the location of button or other components.
I know how to create a JButton but not adjust location.
Not only that, i also want to make ImageIcon to the applet.
Please help me. I really need your help.
Thanks for your help.
- 06-20-2008, 11:32 AM #2
Member
- Join Date
- Jun 2008
- Posts
- 6
- Rep Power
- 0
Another requirement is when applet application scale to full screen, all element inside the container should fit properly.
What i want is JApplet ?
Please provide some example and some explanation.
Thanks for your help.
- 06-20-2008, 01:33 PM #3
That may be possible by setting the layout into null....My assignment is want to me code a JApplet without a layout manager which allow me to adjust the location of button or other components.
You may use the setBounds for adjusting...
And have patience on setting its location...
You may compile the program several times just to set the desired location within the container....
Try to browse the JLabel's documentation about on how to do that.... and also the other components.....Not only that, i also want to make ImageIcon to the applet.Last edited by sukatoa; 06-20-2008 at 01:36 PM.
freedom exists in the world of ideas
- 06-21-2008, 05:16 AM #4
Member
- Join Date
- Jun 2008
- Posts
- 6
- Rep Power
- 0
ImageIcon any = new ImageIcon("D:\\Java\\SodaMachine\\cola_5.jpg");/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import java.awt.*;
import javax.swing.*;
import javax.swing.JApplet;
/**
*
* @author nicholas_tse
*/
public class Test extends JApplet {
/**
* Initialization method that will be called after the applet is loaded
* into the browser.
*/
@Override
public void init() {
// TODO start asynchronous download of heavy resources
Container content = getContentPane();
//content.setBackground(Color.white);
content.setLayout(null);
content.add(new JButton("Button 1"));
content.add(new JButton("Button 2"));
content.add(new JButton("Button 3"));
}
// TODO overwrite start(), stop() and destroy() methods
}
JLabel tenCents = new JLabel(any);
content.add(tenCents);
This one is ok.
What is the difference between JPanel and Container ?
I have try the folloing but doesn't get any reusly yet.
Please provide some example to me.
Thanks for your help.Last edited by Peter_APIIT; 06-21-2008 at 06:01 AM.
- 06-24-2008, 11:58 AM #5
Member
- Join Date
- Jun 2008
- Posts
- 6
- Rep Power
- 0
Any help please.
- 06-24-2008, 02:50 PM #6
JPanel's documentationWhat is the difference between JPanel and Container ?
More detailed samples from the net.....Please provide some example to me.freedom exists in the world of ideas
- 06-28-2008, 04:55 AM #7
Member
- Join Date
- Jun 2008
- Posts
- 6
- Rep Power
- 0
The JPanel documentation doesn't provide difference between JPanel and container ?
I don't want to create null layout manager myself.
I want some built in API.
Thanks for your help.
-
This confuses me greatly. There is no "null layout manager" and no need to create one, as a null layout is essentially that -- no layout manager. Maybe I'm missing something here?I don't want to create null layout manager myself.
I want some built in API.
- 06-30-2008, 04:59 AM #9
JPanel extends Container (one level removed) so JPanel is a Container that provides some more functionality. Reading the API doc should show you what JPanel provides that Container doesn't.What is the difference between JPanel and Container ?
You should become familiar with reading the API to help you use and understand java.
If you have the JDK installed, there is a src.zip file in the folder with the JDK that has all the source for the java classes. Pick one of the simpler Layout managers and extract its source from the zip and look at that to see how a layout manager works.
- 07-08-2008, 07:18 PM #10
null is a special value
To get rid of somthing, we can set it to null. LayoutManagers are a special case, trying to set a layout manager to null will likely foul up other built-ins that are expecting it to be there. A JPanel (Java 2 Platform SE 5.0) is close to the base of the class for javax.swing.JFrame
You can add a JPanel to a JFrame, just call add( .... ); with a constructed JPanel being passed into the add()
And the child will be added to the contentPane. The content pane will always be non-null. Attempting to set it to null will cause the JFrame to throw an exception. The default content pane will have a BorderLayout manager set on it. Refer to RootPaneContainer for details on adding, removing and setting the LayoutManager of a JFrame.Introduction to Programming Using Java.
Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor
- 07-19-2008, 05:37 AM #11
Member
- Join Date
- Jun 2008
- Posts
- 6
- Rep Power
- 0
Similar Threads
-
Database to JApplet
By Preethi in forum New To JavaReplies: 0Last Post: 03-26-2008, 05:18 AM -
Another problem in JApplet :S
By juju in forum Java AppletsReplies: 2Last Post: 12-30-2007, 07:46 PM -
help with converting to JApplet
By Simmy in forum AWT / SwingReplies: 2Last Post: 08-09-2007, 08:45 AM -
JApplet and html
By paty in forum Java AppletsReplies: 1Last Post: 08-02-2007, 05:41 PM -
MiG Layout Manager 2.4
By levent in forum Java SoftwareReplies: 0Last Post: 05-16-2007, 05:11 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks