Results 1 to 4 of 4
Thread: setSize() not working?
- 12-02-2010, 02:50 AM #1
Member
- Join Date
- Oct 2010
- Posts
- 22
- Rep Power
- 0
setSize() not working?
I need a JPanel to be the given size. The applet starts at 200x200 but then expands to the correct size; however the JPanel never resizes to the correct size... I have looked everywhere for the solution to the this, and they all say the same thing, "Use setPreferredSize instead of setSize". I have done this and it still doesn't work... Any help will be sooo helpful.
Java Code:import java.awt.BorderLayout; import java.awt.Container; import java.awt.Dimension; import javax.swing.JApplet; public class Applet extends JApplet { /** * */ private static final long serialVersionUID = 1L; public static final int DEFAULT_FPS = 80; private World mWorld; //private JTextField mFPS; public void init() { this.setPreferredSize(new Dimension(1200, 800)); String str = getParameter("fps"); int fps = (str != null) ? Integer.parseInt(str) : DEFAULT_FPS; long period = (long) 1000.0/fps; System.out.println("fps: "); //+ fps + "; period: " + period + " ms"); makeGUI();//period); } private void makeGUI() {//long period) { Container c = getContentPane(); c.setLayout(new BorderLayout()); // World Extends JPanel mWorld = new World(this); mWorld.setMinimumSize(new Dimension(1200, 800)); mWorld.setPreferredSize(new Dimension(1200, 800)); c.add(mWorld); } }Last edited by AedonetLIRA; 12-02-2010 at 02:58 AM.
-
I don't really do applet coding, but as far as I understand it, the applet size is set by the HTML code calling the applet, not by the applet itself.
- 12-02-2010, 04:19 AM #3
Member
- Join Date
- Oct 2010
- Posts
- 22
- Rep Power
- 0
As I understand it, that is true, but all of the frames inside of the applet are not. It's the JPanel inside that I'm struggling with.
- 12-02-2010, 05:17 AM #4
Similar Threads
-
When to use setSize()
By Lil_Aziz1 in forum New To JavaReplies: 7Last Post: 05-29-2010, 03:26 PM -
Why is my Do/While Not working?
By Meta in forum New To JavaReplies: 1Last Post: 05-11-2010, 06:05 PM -
working with JC
By yuhobebbho in forum New To JavaReplies: 0Last Post: 02-10-2010, 11:22 PM -
[Help] setSize work wrong ???
By dawp in forum New To JavaReplies: 7Last Post: 11-05-2009, 09:30 AM -
Java mail problem(working in intranet,but not working in iternet)
By sundarjothi in forum Advanced JavaReplies: 8Last Post: 05-28-2008, 07:00 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks