Switch to full style
Java2 codes,problems ,discussions and solutions are here
Post a reply

JFrame properties for an Applet to be embedded in website?

Sun Oct 16, 2011 1:17 am

I've been trying to find a way to gain access to all the JFRAME functionality like buttons etc in an applet which is being doublebuffered. Is there any way to have these buttons etc and chat style panes in an applet?

EXAMPLE:

Say I'm making a small game. In this game I am using something like:

Code:
   // The paint function handles all the paint requests to draw things to the screen
   public void paint(Graphics g){

      bg.clearRect(0, 0, appWidth, appHeight);   // Refresh the background first   

      
      // GUI PLACEMENT
      
      bg.setColor(Color.orange);
      bg.fillRect(640, 685, 260, 70);      // PROGRESS QUICKVIEW
      
      bg.setColor(Color.red);
      bg.fillRect(740, 655, 80, 30);      // SERVER TIME

//////// MORE CODE HERE /////////


      // Finally output the prepared screen
      g.drawImage(buffer,0,0,this);
   }

BUT ..... I want to be able to use the JFrame things like buttons to choose items in the game, and I want to be able to implement a little chat client in the game as well ......

What would you recommend I do to accomplish this?

I was thinking about writing it all from scratch, boundary boxes and parsing text to fit inside for the chatbox etc ... and then for the buttons / hotkeys in the game but JFrame buttons in there to do all the actions but I'm starting to think that I'm tackling this in the wrong way entirely.

Any help please? Or would using JFrame properties inside my applet work?

VERY IMPORTANT: This is to be embedded into a website so it cannot have standard windows style borders etc, I just want to utilise the JFrame assets like buttons etc ...

Anyway any help you can offer me would be appreciated.

Regards
gam35guru



Re: JFrame properties for an Applet to be embedded in website?

Fri Nov 11, 2011 10:03 pm

Based on experience, JFrame inside an applet is not recommended (or it wouldn't run at all). It would be redundant to have JFrame elements like title bar, max/min/close buttons as the browser already have these.

You can use JPanel instead and put buttons, textboxes, labels, and other doublebuffered elements inside it. Then, put the JPanel inside the applet.
Hope this helps.

Post a reply
  Related Posts  to : JFrame properties for an Applet to be embedded in website?
 JFrame on applet     -  
 Remove default window icon from JFrame     -  
 links CSS properties     -  
 Change the properties of div tag     -  
 Change CSS Properties from JQuery     -  
 Class static properties     -  
 Java properties utility     -  
 Changing the color and properties of the header tag     -  
 Define boolean Class properties     -  
 demonstrate how to add lighting and material properties     -