Panel expansion problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ramola
    New Member
    • Sep 2007
    • 35

    Panel expansion problem

    hi,

    I have a screen JFrame made using borderLayout
    there are 2 panels (placed on a container): 1 to the EAST tht consists of a dice and scorecard.
    2 pnl is a layered pane tht has an image on it

    When I run this prg individually ,it works absolutely fine.

    But since its a part of Client -server, if i run it after integrating it with the other screens , this is what happens :

    You hit the dice button and the panel holding it expands .
    It expands in such a way that it covers some part of the other panel that has the image.

    When you again hit the dice button no more expansion takes place .

    Colud you please tell why such a thing happens ???
    the poosible reasons for such an unusual behaviour ????


    kind regards,
    RM
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by Ramola
    hi,

    I have a screen JFrame made using borderLayout
    there are 2 panels (placed on a container): 1 to the EAST tht consists of a dice and scorecard.
    2 pnl is a layered pane tht has an image on it

    When I run this prg individually ,it works absolutely fine.

    But since its a part of Client -server, if i run it after integrating it with the other screens , this is what happens :

    You hit the dice button and the panel holding it expands .
    It expands in such a way that it covers some part of the other panel that has the image.

    When you again hit the dice button no more expansion takes place .

    Colud you please tell why such a thing happens ???
    the poosible reasons for such an unusual behaviour ????


    kind regards,
    RM
    Can you post the code that is run when the button is clicked.

    Comment

    • Ramola
      New Member
      • Sep 2007
      • 35

      #3
      Originally posted by r035198x
      Can you post the code that is run when the button is clicked.
      Code:
      {
      	    /* generating a random no. as roll */
      		int num;
      	    Random rand=new Random();
      			do
      			{		
      				  num=rand.nextInt(7);
      			}while(num==0); 
      
      			txtdice.setFont(new Font("ARIAL",Font.BOLD,40));
      			txtdice.setForeground(Color.BLACK);
      			
      			txtdice.setText("                  "+num);
      
                  /* placing the marble */
                  
                 
                             
      		   
      	}
      Thats all !
      as in i am simply generating a random no. between 1-6 as the roll of dice !


      When u run this particular JFrame individually it works fine .
      but when u integrate it with the rest of my client server part of the game
      it expands !

      Kind regards,
      RM

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by Ramola
        Code:
        {
        	    /* generating a random no. as roll */
        		int num;
        	    Random rand=new Random();
        			do
        			{		
        				  num=rand.nextInt(7);
        			}while(num==0); 
        
        			txtdice.setFont(new Font("ARIAL",Font.BOLD,40));
        			txtdice.setForeground(Color.BLACK);
        			
        			txtdice.setText("                  "+num);
        
                    /* placing the marble */
                    
                   
                               
        		   
        	}
        Thats all !
        as in i am simply generating a random no. between 1-6 as the roll of dice !


        When u run this particular JFrame individually it works fine .
        but when u integrate it with the rest of my client server part of the game
        it expands !

        Kind regards,
        RM
        That's not too helpful. We need to see more of the code then (even all of it if possible).

        Comment

        • Ramola
          New Member
          • Sep 2007
          • 35

          #5
          Originally posted by r035198x
          That's not too helpful. We need to see more of the code then (even all of it if possible).
          Code:
          	public void actionPerformed(ActionEvent ae)
          	{
          		if(ae.getSource().equals(bttndice))
          		{
          			//bttndice.setEnabled(false);
          			lblstatus.setIcon(new ImageIcon("WAIT.gif"));
          			Move();	
          		}
          		
          		if(ae.getSource().equals(bttnquit))
          		{
          			if(n == 2)
          			{
          				JOptionPane.showMessageDialog((Component)null, "Other player has won the game","Loser",JOptionPane.PLAIN_MESSAGE);	
          			}
          			this.dispose();
          			server.quit(game_no,id);
          		}
          	}
          
          
          
             /* The Move function is used to roll a valid no. n initiate the 
                no. of moves on the map*/
          	public void Move()
          	{
          	    /* generating a random no. as roll */
          		int num;
          	    Random rand=new Random();
          			do
          			{		
          				  num=rand.nextInt(7);
          			}while(num==0); 
          
          			txtdice.setFont(new Font("ARIAL",Font.BOLD,40));
          			txtdice.setForeground(Color.BLUE);
          			txtdice.setText("                "+num);
          			server.sendMove(game_no,id,num);	
          }
          
          private PrintWriter out;
          	void sendMove(int game_no,String the_id, int moves)
          	{
          		out.println("move" + CRLF + game_no + CRLF + the_id + CRLF + moves + CRLF);
          	}
          The action performed and Move functions r in one class.
          and sendMove is in another class...

          these are the only things related to the dice button.

          Comment

          Working...