ztriviz's Profile User Rating: -----

Reputation: 1 Apprentice
Active Posts:
18 (0.03 per day)
31-December 12
Profile Views:
Last Active:
User is offline Jan 16 2013 03:00 PM

Previous Fields

Who Cares
OS Preference:
Who Cares
Favorite Browser:
Who Cares
Favorite Processor:
Who Cares
Favorite Gaming Platform:
Who Cares
Your Car:
Who Cares
Dream Kudos:
Icon   ztriviz has not set their status

Posts I've Made

  1. In Topic: JFrame to JApplet

    Posted 13 Jan 2013

    View Postpbl, on 11 January 2013 - 07:20 PM, said:

    Actually, as you don't call the init() method yourself, you do not have any control on the context of which thread it is called.



    with JFrame i use Dispose and call again the game

    That is a very poor design :)/> Why wasting a JFrame if it is already existing ? You can always removeAll() component from it.

    If you want to continue with this bad design, as you JApplet as a BorderLayout, adding a component to any of the region of this BorderLayout will simply remove the one that was there and replace it by the new one you add to that region.

    ok you have a point with jframe , the time is pressing and i couldn't think of that . As far as the applet what you proposing to do ? which is the right way to do that?
  2. In Topic: JFrame to JApplet

    Posted 11 Jan 2013

    View Postpbl, on 11 January 2013 - 06:03 PM, said:

    This is a very bad idea and will not work anyhow. And you call repaint() at the end of your method, deleting what you have done before.

    First never do this:
    Graphics g = getGraphics();

    always call repaint() and use the Graphicsa object that is provided to you by the paint() or paintComponent() method

    The way to clear is:

        class MyPanel extend JPanel {
            private boolean shouldBeCleared = false;
            void someMethod() {
                shouldBeCleared = true:
            public void paintComponent(Graphics g) {
    }           if(shouldBeCleared)         // if nothing to do
                    return;                // exit
               .. ok draw what I have to draw

    i use repaint to repaint components inside my applet . i have a game and i want at the second round everything on the applet to start again which i do with this
    public Test extends Applet {
    public void game(String str1,String Str2 ){
    //game code 
    //when done some things and win  i want to restart game(str1,str2);
    public void init(){
    //names str1,str2 

    with JFrame i use Dispose and call again the game
  3. In Topic: JFrame to JApplet

    Posted 11 Jan 2013

         public void clear() 
    Graphics g = getGraphics(); 
    Dimension d = getSize(); 
    Color c = getBackground(); 

    i used this but it clears only one panel of the applet
  4. In Topic: JFrame to JApplet

    Posted 11 Jan 2013

    guys thank you , i made it work .but now i dont know how to clear japplet's screen and draw again i want at some point of the game reset the screen and start a new round , i read that i must overload update but i want to erase all the contents and start again
  5. In Topic: JFrame to JApplet

    Posted 10 Jan 2013

    ok i did this

    public class Game extends JApplet  {
    public game(){}
    public Game(String str1,String str2){
                myContainer.setLayout(new BorderLayout());
    //code here with jpanels,jlabels etc into myContainer
     and some confirmdialogs 
    public void init(){
     Game new =new Game(String str1,String str2 );

    now only i can see when i run it like an applet are the confirm dialogs . my container not showing at all

My Information

Member Title:
New D.I.C Head
Age Unknown
Birthday Unknown

Contact Information



ztriviz has no profile comments yet. Why not say hello?