Results 1 to 9 of 9
  1. #1
    jumper19 is offline Member
    Join Date
    Jan 2009
    Posts
    4
    Rep Power
    0

    Question only ~200x200px Applet area visible

    Hi Everybody,

    I'm writing a GUI in Java under Linux (FC 9) using Easy Eclipse Desktop Java 1.2.2.
    I'm still not a Java expert, so I depend much on Visual Editor. I'm planning to embed my GUI on a web page, so I chose Applet.
    The problem is as mentioned in the topic. When I "Run As Java Applet" I see an Applet window with the dimensions I declared, but there's only a limited area (200x200px visible), the rest is just gray:

    212.67.142.162/pub/zrzutekranu.png (sorry for that, but I'm not allowed to post links to photos)
    EDIT:--------
    alternative link: www[dot]fotosik[dot]pl/showFullSize.php?id=ad892da888429074
    ---------------

    And here's my example code:
    Java Code:
    import java.awt.BorderLayout;
    import javax.swing.JPanel;
    import javax.swing.JApplet;
    import javax.swing.JTextPane;
    import javax.swing.JButton;
    import java.awt.Dimension;
    import java.awt.event.KeyEvent;
    
    public class Problem extends JApplet {
    
    	private JPanel jContentPane = null;
    	private JTextPane jTextPane = null;
    	private JButton jButton = null;
    	private JButton jButton1 = null;
    
    	/**
    	 * This is the xxx default constructor
    	 */
    	public Problem() {
    		super();
    	}
    
    	/**
    	 * This method initializes this
    	 * 
    	 * @return void
    	 */
    	public void init() {
    		this.setSize(300, 200);
    		this.setContentPane(getJContentPane());
    	}
    
    	/**
    	 * This method initializes jContentPane
    	 * 
    	 * @return javax.swing.JPanel
    	 */
    	private JPanel getJContentPane() {
    		if (jContentPane == null) {
    			jContentPane = new JPanel();
    			jContentPane.setLayout(new BorderLayout());
    			jContentPane.add(getJTextPane(), BorderLayout.CENTER);
    			jContentPane.add(getJButton(), BorderLayout.SOUTH);
    			jContentPane.add(getJButton1(), BorderLayout.NORTH);
    		}
    		return jContentPane;
    	}
    
    	/**
    	 * This method initializes jTextPane	
    	 * 	
    	 * @return javax.swing.JTextPane	
    	 */
    	private JTextPane getJTextPane() {
    		if (jTextPane == null) {
    			jTextPane = new JTextPane();
    		}
    		return jTextPane;
    	}
    
    	/**
    	 * This method initializes jButton	
    	 * 	
    	 * @return javax.swing.JButton	
    	 */
    	private JButton getJButton() {
    		if (jButton == null) {
    			jButton = new JButton();
    			jButton.setPreferredSize(new Dimension(34, 30));
    			jButton.setMnemonic(KeyEvent.VK_UNDEFINED);
    		}
    		return jButton;
    	}
    
    	/**
    	 * This method initializes jButton1	
    	 * 	
    	 * @return javax.swing.JButton	
    	 */
    	private JButton getJButton1() {
    		if (jButton1 == null) {
    			jButton1 = new JButton();
    			jButton1.setPreferredSize(new Dimension(34, 30));
    			jButton1.setText("ABCDEFGHIJKLMNOP1234567890");
    		}
    		return jButton1;
    	}
    }
    What could be the problem?
    I will appreciate any of your help or hints.

    Best regards

    jumper

    PS. When I do "Applet -> Clone..." from Applet's menu it works fine...
    Last edited by jumper19; 01-29-2009 at 06:44 PM.

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Did you manually added this applet class into a html page. I cannot see your image, tcp error prompt.

  3. #3
    jumper19 is offline Member
    Join Date
    Jan 2009
    Posts
    4
    Rep Power
    0

    Default

    Quote Originally Posted by Eranga View Post
    Did you manually added this applet class into a html page. I cannot see your image, tcp error prompt.
    Ooops, sorry. My server is down today. Here's the new link:
    www[dot]fotosik[dot]pl/showFullSize.php?id=ad892da888429074
    Thanx for helping :)

    --
    jumper

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Seems to me this is something wrong with the applet viewer. Your code is fine. Did you try to add into a html page, you'll see the applet in correct way.

  5. #5
    jumper19 is offline Member
    Join Date
    Jan 2009
    Posts
    4
    Rep Power
    0

    Wink

    Quote Originally Posted by Eranga View Post
    Seems to me this is something wrong with the applet viewer. Your code is fine. Did you try to add into a html page, you'll see the applet in correct way.
    Yepp, you were right! :) However something is still "thinking" the applet is 200x200, because the html code that Eclipse generated was:

    XML Code:
    <html>
    <body>
    <applet code=Covert.class width="200" height="200" >
    </applet>
    </body>
    </html>
    I had to correct it to 800x480.
    Any way to change the applet viewer?

    Thanx a lot
    cheers
    --
    jumper

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Your applet code, I mean the HTML code above, set the size of the applet into 200 X 200. Since I'm not an Eclipse use I don't know the exact way to do this.

    Can you edit the above HTML code? If so try to change them into 800 X 480, size you want to have and try.

  7. #7
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Eclipse uses (I think) the standard java appletviewer. I'm not sure how to set the applet's size using this though. I'm with you Eranga, just create a simple HTML page and adjust the size in the HTML code.

  8. #8
    jumper19 is offline Member
    Join Date
    Jan 2009
    Posts
    4
    Rep Power
    0

    Default

    Quote Originally Posted by Fubarable View Post
    ...just create a simple HTML page and adjust the size in the HTML code.
    Sure, I can do that in HTML and that works (the applet is as big as i wish), but I wonder why it's 200x200 by default even though it's set to be 300x200 (or whatever) in Java source.

  9. #9
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    As Fubarable says, IDE use the standard applet viewer. Somehow because of a reason it not functioning properly. If you change the size of the code, it's effected on the applet viewer. On side side it's working fine.

Similar Threads

  1. Replies: 2
    Last Post: 04-14-2009, 11:01 PM
  2. Address bar not visible
    By Akashchopra521 in forum New To Java
    Replies: 0
    Last Post: 12-03-2008, 08:13 AM
  3. constructor ... is not visible
    By emceenugget in forum New To Java
    Replies: 2
    Last Post: 09-27-2008, 06:12 AM
  4. How do you keep multiple popups visible?
    By Jacob Abernathy in forum New To Java
    Replies: 6
    Last Post: 09-15-2008, 07:35 PM
  5. Replies: 0
    Last Post: 08-04-2008, 01:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •