Page 1 of 2 12 LastLast
Results 1 to 20 of 35

Thread: Java Applet

  1. #1
    WillHorne is offline Member
    Join Date
    Nov 2011
    Posts
    27
    Rep Power
    0

    Default Java Applet

    I'm trying to write a segment of code that will take text from a textbox and print out some info about what was in the textbox. and have it print out somewhere on the applet


    E.G.

    Restaurant entered in textbox
    search button clicked
    print out underneath - All restaurants have air-conditioning


    there will be several things that can be entered into the textbot to get different info about all of them




    Any Help is welcome



    Thanks

    Will

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

    Default Re: Java Applet

    So....what did you try? Where are you stuck? Do you know how to create an applet?

  3. #3
    WillHorne is offline Member
    Join Date
    Nov 2011
    Posts
    27
    Rep Power
    0

    Default Re: Java Applet

    ive got the applet made its just this little bit that needs finishing

    ive got the text box and the button made and can get it to print out preset text in the console in eclipse
    what i cant work out how to code is
    if "A" is entered into the textbox print "a" next to the textbox
    if "B" is entered into the textbox print "b" next to the textbox

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,755
    Rep Power
    19

    Default Re: Java Applet

    So you need to get the value from the Text box.

    Are you able to do that and print that to the console?
    If so can you then put that value into a JLabel next to the text box?
    Once you can do that, then you just need to find a way to lowercase a character.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    WillHorne is offline Member
    Join Date
    Nov 2011
    Posts
    27
    Rep Power
    0

    Default Re: Java Applet

    this is the code ive got for the text box and button

    {
    Button okButton;
    TextField nameField;
    {
    setLayout(null);
    okButton = new Button("Search");
    nameField = new TextField("",100);
    }

    {
    okButton.setBounds(140,20,160,25);
    nameField.setBounds(20,20,100,25);
    }

    {
    add(okButton);
    add(nameField);
    }

    }

    ive taken out all the ActionListener events as they weren't working properly.

    im not clued up on the AWT of JAVA 2.0 so dont know how jlables work


    could you walk me through it with some examples

    thanks Will

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,755
    Rep Power
    19

    Default Re: Java Applet

    For starters you should be using Swing.
    AWT is old, to say the least.

    But you said you had the button printing to the console.
    That's your start point then.
    Get an ActionListener on the button that prints something to the console.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  7. #7
    WillHorne is offline Member
    Join Date
    Nov 2011
    Posts
    27
    Rep Power
    0

    Default Re: Java Applet

    this is what i hat to start with but now its now working for some reason

    {
    Button okButton;
    TextField nameField;
    {
    setLayout(null);
    okButton = new Button("Search");

    nameField = new TextField("",100);
    }

    {
    okButton.setBounds(140,20,160,25);
    nameField.setBounds(20,20,100,25);
    }

    {
    add(okButton);
    add(nameField);
    okButton.addActionListener(this);
    }


    public void actionPreformed(ActionEvent e)
    {
    System.out.println("Hello");
    }
    }

  8. #8
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

    Default Re: Java Applet

    but now its now working for some reason
    Word of advice: you really have to be a lot more informative with your posts. Saying 'not working' is as useful to us as us saying 'then fix it' is to you, and posting small code snippets in lieu of an SSCCE leaves us guessing. Does it compile? Exceptions? Misbehave?

  9. #9
    WillHorne is offline Member
    Join Date
    Nov 2011
    Posts
    27
    Rep Power
    0

    Default Re: Java Applet

    this is the entire applet now

    I worked out what i had done wrong

    this now prints out to the console when the button is clicked

    how do i make it so it prints to the applet

    and so that depending on what is entered into the textbox is printed out

    Java Code:
    import java.applet.*;
    import java.awt.*;
    import java.awt.geom.CubicCurve2D;
    import java.awt.event.*;
    
    public class Map extends Applet  implements ActionListener
    {
    	Color b = new Color(0, 209, 0);
    	Color c = new Color(19,0,158);
    	Color d = new Color(104,42,42);
        
         public void paint (Graphics g)
         {Graphics2D g2 = (Graphics2D) g;
         Graphics2D g2d = (Graphics2D)g;
        	
         {    
        	 {
        	 int x = 50, y = 80, width = 100, height = 100;
             setSize(800,800);
             setBackground(b);
        	 } 
        	 
        	 
        	 //RIVER
        	 {
        		 g.setColor(c);
        		 g2.setStroke(new BasicStroke (15));
        		// create new CubicCurve2D.Double
        		 CubicCurve2D c = new CubicCurve2D.Double();
        		 // draw CubicCurve2D.Double with set coordinates
        		 c.setCurve(0, 0, 20, 726, 426, 50, 600, 800);
        		 g2.draw(c);
        	 }
         
         							//INITIALS AND PATHS
    						     {
    						    	// W
    						    	g.setColor (Color.black);
    						    	g2.setStroke(new BasicStroke (15));
    						    	g.drawLine(30,100,100,300);
    						    	g.drawLine(100,300,150,100);
    						    	g.drawLine(150,100,200,300);
    						    	g.drawLine(200,300,250,100);
    						    	
    						     	}
    						     	{
    						    	//H
    						    	g.setColor (Color.black);
    						    	g2.setStroke(new BasicStroke (15));
    						    	g.drawLine(350,100,350,300);
    						    	g.drawLine(350,250,550,120);
    						    	g.drawLine(550,100,550,300);
    						    	}
    						     	
    						     	//PATHS
    						     	{
    						     		g.setColor(Color.black);
    						     		g2.setStroke(new BasicStroke (12));
    						     		g.drawLine(270,375,200,300);
    						    		CubicCurve2D c = new CubicCurve2D.Double();
    						    		c.setCurve(275, 410, 20, 726, 426, 500, 200, 800);
    						    		g2.draw(c);
    						    		g.drawLine(550,300,600,470);
    						    		g.drawLine(600,470,220,600);
    						     	}
    						     	//BRIDGE
    						     	{
    						     		g.setColor(d);						     		
    						     		g.drawLine(275,380,275,410);
    						     		g.drawLine(500,505,465,515);
    						     		g.setColor(Color.black);
    						     	}											{
    																			     	//KEY
    																			     	{
    																			     		g2.setStroke(new BasicStroke ((float) 1.5));
    																			     		g.drawRect(640, 400, 150, 250);
    																			     	}
    																			     	{
    																			     		g.setFont (new Font ("Comic Sans MS", Font.PLAIN, 18));
    																			     		g.drawString ("Key", 645, 420);
    																			     		
    																			     	}
    																			     	
    																			     		//PICKNIC AREA
    																			     			{
    																			     				g2.setStroke(new BasicStroke ((float) 1.5));
    																			   					 {
    																			   						 g.setColor (Color.black);
    																			   						 g2d.drawLine(645, 430, 655, 440);
    																			   						 g2d.drawLine(655, 430, 655, 440);
    																			   						 g2d.drawLine(665, 430, 655, 440);
    																			   						 g2d.drawLine(655, 440, 655, 450);
    																			   					 }
    																			   					 {
    																			   						 g2d.drawLine(670,440,690,440);
    																			   						 g2d.drawLine(680,440,670,450);
    																			   						 g2d.drawLine(680,440,690,450);
    																			   					 }
    																			   					 {
    																			   						g.setFont (new Font ("Comic Sans MS", Font.PLAIN, 12));
    																			   						g.drawString("Picnic Area",700,450);
    																			   					 
    																			   					 }	
    																			   				}
    																			     			// LAKE
    																			     			{
    																			     				g2.setStroke(new BasicStroke ((float) 1.5));
    																			     				g.setColor(c);
    																			     				g.fillOval(645,540,45,20);
    																			     				g.setColor(Color.black);
    																			     				g.drawString("Lake",700,555);
    																			     			}
    																			     			//PLAYAREA
    																			     			{
    																			     				g2.setStroke(new BasicStroke ((float) 2));
    																			     				g2d.drawLine(655,570,645,590);
    																			     				g2d.drawLine(655,570,665,590);
    																			     				g2.setStroke(new BasicStroke ((float) 1.5));
    																			     				g2d.drawLine(655,570,655,588);
    																			     				g2d.drawLine(650,588,660,588);
    																			     				g2d.drawLine(670,590,672,570);
    																			     				CubicCurve2D c = new CubicCurve2D.Double();								     	    		 
    																			     	    		c.setCurve(672,570,677,582,682,588,690,590);
    																			     	    		g2.draw(c);
    																			     	    		g.drawString("Play Area",700,590);
    																			     			}
    																			     			//PATHS
    																			     			{
    																			     				g2.setStroke(new BasicStroke (3));
    																			     				g.drawLine(645,615,690,615);
    																			     				g.drawString("Path",700,620);
    																			     			}	
    																			     			//RESTAURANT
    																			     			{
    																			     				
    																			     				g2.setStroke(new BasicStroke (1));
    																			     				g2d.drawLine(650,505,650,509);
    																			     				g2d.drawLine((int) 652.5,505,(int) 652.5,509);
    																			     				g2d.drawLine(655,505,655,509);
    																			     				g2d.drawLine(650,509,655,509);
    																			     				g2d.drawLine(652,507,(int) 651.5,517);
    																			     				g2d.drawLine(653,507,(int) 653.5,517);
    																			     				g2d.drawLine((int)651.5,517,(int)653.5,517);
    																			     				g2d.drawLine(657,501,657,517);
    																			     				g2d.drawLine(657,517,658,517);
    																			     				g2d.drawLine(658,517,658,509);
    																			     				g2d.drawLine(658,501,659,502);
    																			     				g2d.drawLine(659,502,658,503);
    																			     				g2d.drawLine(658,503,659,504);
    																			     				g2d.drawLine(659,504,658,505);
    																			     				g2d.drawLine(658,505,659,506);
    																			     				g2d.drawLine(659,506,658,507);
    																			     				g2d.drawLine(658,507,659,508);
    																			     				g2d.drawLine(659,508,658,509);
    																			     				g2.setStroke(new BasicStroke ((float) 1.5));
    																			     				g2d.drawLine(680,500,670,510);
    																			     				g2d.drawLine(670,510,670,520);
    																			     				g2d.drawLine(680,500,690,510);
    																			     				g2d.drawLine(690,510,690,520);
    																			     				g2d.drawLine(670,510,690,510);
    																			     				g2d.drawLine(670,520,690,520);
    																			     				g.drawString("Restaurant",700,520);
    																			     				g.setColor(Color.black);
    																			     				g2.setStroke(new BasicStroke ((float) 2));
    																			     				g2d.drawOval(645,497,20,25);
    																			     											     				
    																			     			}
    																			     			
    																			     				
    																			     			}
    																			     			//RIVER
    																			     			{
    																			     				g.setColor(c);
    																			     				g2.setStroke(new BasicStroke (2));
    																			     	    		CubicCurve2D c = new CubicCurve2D.Double();								     	    		 
    																			     	    		c.setCurve(645, 470, 650, 490, 670, 460, 690, 490);
    																			     	    		g2.draw(c);
    																			     	    		g.setColor(Color.black);
    																			     	    		g.drawString("River",700,480);
    																			     			}
    																			     			//PATHS
    																			     			{
    																			     				g2.setStroke(new BasicStroke (3));
    																			     				g.setColor(d);
    																			     				g.drawLine(645,635,690,635);
    																			     				g.drawString("Bridge",700,640);
    																			     			}	
    																			     			
         																	}
    								     		
    	//MAP SYMBOLS
    						     			{
    						     				//PLAY AREA
    						     				g2.setStroke(new BasicStroke ((float) 2));
    						     				g2d.drawLine(055,570,045,590);
    						     				g2d.drawLine(055,570,065,590);
    						     				g2.setStroke(new BasicStroke ((float) 1.5));
    						     				g2d.drawLine(055,570,055,588);
    						     				g2d.drawLine(050,588,060,588);
    						     				g2d.drawLine(070,590,072,570);
    						     				CubicCurve2D c = new CubicCurve2D.Double();								     	    		 
    						     	    		c.setCurve(072,570,77,582,82,588,90,590);
    						     	    		g2.draw(c);
    						     			}
    						     			{
    						     				//PLAY AREA
    						     				g2.setStroke(new BasicStroke ((float) 2));
    						     				g2d.drawLine(455,70,445,90);
    						     				g2d.drawLine(455,70,465,90);
    						     				g2.setStroke(new BasicStroke ((float) 1.5));
    						     				g2d.drawLine(455,70,455,88);
    						     				g2d.drawLine(450,88,460,88);
    						     				g2d.drawLine(470,90,472,70);
    						     				CubicCurve2D c = new CubicCurve2D.Double();								     	    		 
    						     	    		c.setCurve(472,70,477,82,482,88,490,90);
    						     	    		g2.draw(c);
    						     			}
    						     			{
    						     				//RESTAURANT
    							     			
    							     				
    							     				g2.setStroke(new BasicStroke (1));
    							     				g2d.drawLine(550,505,550,509);
    							     				g2d.drawLine((int) 552.5,505,(int) 552.5,509);
    							     				g2d.drawLine(555,505,555,509);
    							     				g2d.drawLine(550,509,555,509);
    							     				g2d.drawLine(552,507,(int) 551.5,517);
    							     				g2d.drawLine(553,507,(int) 553.5,517);
    							     				g2d.drawLine((int)551.5,517,(int)553.5,517);
    							     				g2d.drawLine(557,501,557,517);
    							     				g2d.drawLine(557,517,558,517);
    							     				g2d.drawLine(558,517,558,509);
    							     				g2d.drawLine(558,501,559,502);
    							     				g2d.drawLine(559,502,558,503);
    							     				g2d.drawLine(558,503,559,504);
    							     				g2d.drawLine(559,504,558,505);
    							     				g2d.drawLine(558,505,559,506);
    							     				g2d.drawLine(559,506,558,507);
    							     				g2d.drawLine(558,507,559,508);
    							     				g2d.drawLine(559,508,558,509);
    							     				g2.setStroke(new BasicStroke ((float) 1.5));
    							     				g2d.drawLine(580,500,570,510);
    							     				g2d.drawLine(570,510,570,520);
    							     				g2d.drawLine(580,500,590,510);
    							     				g2d.drawLine(590,510,590,520);
    							     				g2d.drawLine(570,510,590,510);
    							     				g2d.drawLine(570,520,590,520);
    							     				
    							     				g.setColor(Color.black);
    							     				g2.setStroke(new BasicStroke ((float) 2));
    							     				g2d.drawOval(545,497,20,25);
    							     											     				
    							     			
    						     			}
    						     			{
    						     				//RESTAURANT
    							     			
    							     				
    							     				g2.setStroke(new BasicStroke (1));
    							     				g2d.drawLine(450,205,450,209);
    							     				g2d.drawLine((int) 452.5,205,(int) 452.5,209);
    							     				g2d.drawLine(455,205,455,209);
    							     				g2d.drawLine(450,209,455,209);
    							     				g2d.drawLine(452,207,(int) 451.5,217);
    							     				g2d.drawLine(453,207,(int) 453.5,217);
    							     				g2d.drawLine((int)451.5,217,(int)453.5,217);
    							     				g2d.drawLine(457,201,457,217);
    							     				g2d.drawLine(457,217,458,217);
    							     				g2d.drawLine(458,217,458,209);
    							     				g2d.drawLine(458,201,459,202);
    							     				g2d.drawLine(459,202,458,203);
    							     				g2d.drawLine(458,203,459,204);
    							     				g2d.drawLine(459,204,458,205);
    							     				g2d.drawLine(458,205,459,206);
    							     				g2d.drawLine(459,206,458,207);
    							     				g2d.drawLine(458,207,459,208);
    							     				g2d.drawLine(459,208,458,209);
    							     				g2.setStroke(new BasicStroke ((float) 1.5));
    							     				g2d.drawLine(480,200,470,210);
    							     				g2d.drawLine(470,210,470,220);
    							     				g2d.drawLine(480,200,490,210);
    							     				g2d.drawLine(490,210,490,220);
    							     				g2d.drawLine(470,210,490,210);
    							     				g2d.drawLine(470,220,490,220);
    							     				
    							     				g.setColor(Color.black);
    							     				g2.setStroke(new BasicStroke ((float) 2));
    							     				g2d.drawOval(445,198,20,25);
    							     											     				
    							     			
    						     			}
    						     			
    						     			// LAKE
    							     			{
    							     				g2.setStroke(new BasicStroke ((float) 1.5));
    							     				g.setColor(c);
    							     				g.fillOval(20,500,80,50);
    						     			}
    							     		// LAKE
    							     			{
    							     				g2.setStroke(new BasicStroke ((float) 1.5));
    							     				g.setColor(c);
    							     				g.fillOval(245,540,50,30);
    							     			}
    							     		// LAKE
    							     			{
    							     				g2.setStroke(new BasicStroke ((float) 1.5));
    							     				g.setColor(c);
    							     				g.fillOval(645,140,100,50);
    							     			}
    							     		// LAKE
    							     			{
    							     				g2.setStroke(new BasicStroke ((float) 1.5));
    							     				g.setColor(c);
    							     				g.fillOval(645,180,150,100);
    							     			}
    							     			//PICKNIC AREA
    							     			
    							     				g2.setStroke(new BasicStroke ((float) 1.5));
    							   					 {
    							   						 g.setColor (Color.black);
    							   						 g2d.drawLine(645, 100, 655, 110);
    							   						 g2d.drawLine(655, 100, 655, 110);
    							   						 g2d.drawLine(665, 100, 655, 110);
    							   						 g2d.drawLine(655, 110, 655, 120);
    							   					 }
    							   					 {
    							   						 g2d.drawLine(670,110,690,110);
    							   						 g2d.drawLine(680,110,670,120);
    							   						 g2d.drawLine(680,110,690,120);
    							   					 }
    							   				//PICKNIC AREA
    									     			
    								     				g2.setStroke(new BasicStroke ((float) 1.5));
    								   					 {
    								   						 g.setColor (Color.black);
    								   						 g2d.drawLine(265, 100, 275, 110);
    								   						 g2d.drawLine(275, 100, 275, 110);
    								   						 g2d.drawLine(285, 100, 275, 110);
    								   						 g2d.drawLine(275, 110, 275, 120);
    								   					 }
    								   					 {
    								   						 g2d.drawLine(290,110,310,110);
    								   						 g2d.drawLine(300,110,290,120);
    								   						 g2d.drawLine(300,110,310,120);
    								   					 }
    								   				//PICKNIC AREA
    										     			
    									     				g2.setStroke(new BasicStroke ((float) 1.5));
    									   					 {
    									   						 g.setColor (Color.black);
    									   						 g2d.drawLine(245, 500, 255, 510);
    									   						 g2d.drawLine(255, 500, 255, 510);
    									   						 g2d.drawLine(265, 500, 255, 510);
    									   						 g2d.drawLine(255, 510, 255, 520);
    									   					 }
    									   					 {
    									   						 g2d.drawLine(270,510,290,510);
    									   						 g2d.drawLine(280,510,270,520);
    									   						 g2d.drawLine(280,510,290,520);
    									   					 }
    
    						//TEXT BOX AND BUTTON
    									   					 
    									   					{
    									   					     Button okButton;								   					
    									   					     TextField nameField;
    									   					     {
    									   					    	setLayout(null);
    									   					        okButton = new Button("Search");
    									   					        
    									   					        nameField = new TextField("",100);
    									   					     }
    
    									   					        {
    									   					          okButton.setBounds(140,20,160,25);
    									   					          nameField.setBounds(20,20,100,25);
    									   					        } 
    
    									   					        {
    									   					      add(okButton);
    									   					      add(nameField);
    									   					   okButton.addActionListener(this);
    									   					     }
    									   					    
    									   					      
    									   					     {
    									   					    	
    									   					     }
    									   					        }
    									   					    
    									   					 }
    
    	
    	public void actionPerformed(ActionEvent e) {
    		
    		System.out.println("Hello"); 
    	}
         }
    Last edited by Norm; 02-28-2012 at 09:20 PM. Reason: added code tags

  10. #10
    Diargg is offline Senior Member
    Join Date
    Feb 2012
    Posts
    117
    Rep Power
    0

    Default Re: Java Applet


  11. #11
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

    Default Re: Java Applet

    this is the entire applet now
    My post above was there to help, not to be ignored. That is NOT an SSCCE, and to be blunt expecting someone to wade through all that code can be considered rude.

  12. #12
    WillHorne is offline Member
    Join Date
    Nov 2011
    Posts
    27
    Rep Power
    0

    Default Re: Java Applet

    sorry

    there is no need for an SSCCE as the only bit i need help with is the text box and button. there is nothing else in the applet that affects them.

    this is the coding i have for the button.


    {
    Button okButton;
    TextField nameField;
    {
    setLayout(null);
    okButton = new Button("Search");

    nameField = new TextField("",100);
    }

    {
    okButton.setBounds(140,20,160,25);
    nameField.setBounds(20,20,100,25);
    }

    {
    add(okButton);
    add(nameField);
    okButton.addActionListener(this);
    }


    {

    }
    }

    }


    public void actionPerformed(ActionEvent e) {


    System.out.println("Hello");

    }
    }

    what i would like to know is if there is a way to print out onto the applet
    and if there is a way to print out something relevant to the text put into the textbox

  13. #13
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

    Default Re: Java Applet

    there is no need for an SSCCE as the only bit i need help with is the text box and button. there is nothing else in the applet that affects them.
    That is the exact purpose of an SSCCE, which makes me think you need to read the link that Diargg kindly provided above.

    what i would like to know is if there is a way to print out onto the applet
    Define 'print'. If you mean display to a user, the use some other appropriate Component (JTextField, JLabel, etc..) and set its appropriate value to be displayed.

  14. #14
    WillHorne is offline Member
    Join Date
    Nov 2011
    Posts
    27
    Rep Power
    0

    Default Re: Java Applet

    i did read that link and there was nothing there that applied to the work i'm doing

    and yea i meant to display it to a user

    i'm not familiar with Jlables.

    could you give me an example of how they work

    Thanks

  15. #15
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

    Default Re: Java Applet

    i did read that link and there was nothing there that applied to the work i'm doing
    You then don't understand its purpose - it applies to help others understand the problem, phrasing code concisely without the mess of everything else, and hence help yourself get help.

    could you give me an example of how they work
    Did you try a web search? This should be the top hit, as well as the first place to go for tutorials and Links to the API: How to Use Labels (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)

  16. #16
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: Java Applet

    Quote Originally Posted by WillHorne View Post
    i'm not familiar with Jlables.

    could you give me an example of how they work
    Presumably you mean JLabel. Please take care to capitalize class names correctly, also to use a capital letter at the start of each sentence and for the first person singular "I" -- and use apostrophes and other punctuation to make your posts easier to read.

    Have you gone through this How to Use Labels (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components) ? It's linked from the JLabel API. You have read the API -- or haven't you?

    db

    edit A minute too late!
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  17. #17
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,755
    Rep Power
    19

    Default Re: Java Applet

    So now you;re on step 2 of my little list above.
    Putting the value you are currently printing to the console into a JLabel.

    As has been said, do an SSCCE. That is produce some code that simply has a JButton, a JTextField and a JLabel.
    Add the ActionListener to the JButton and get it to set the value in the JLabel.

    Note I am referring to Swing classes here.
    If you are insisting on using AWT ones then you'll have to dig out the equivalent ones. I've been doing this for over a decade now I've I've never written an AWT app. That should tell you how dated that is as a technology.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  18. #18
    WillHorne is offline Member
    Join Date
    Nov 2011
    Posts
    27
    Rep Power
    0

    Default Re: Java Applet

    ive been looking at the Swing tutorials and there not making any scene to me

    either i'm looking at them in the wrong way or it going right over my head

    how do you get the JLabel to display when you click the action button?

    thanks

  19. #19
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,755
    Rep Power
    19

    Default Re: Java Applet

    You don't.
    You have an empty JLabel already there and then set the value of it and repaint (actually that last part may not be necessary).
    The JLabel will always be displayed...it'll just not have anything in it until you set the value.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  20. #20
    WillHorne is offline Member
    Join Date
    Nov 2011
    Posts
    27
    Rep Power
    0

    Default Re: Java Applet

    how do you set a value to the JLabel

    and can you use Jlabel to show something different depending on what is entered into the text box?

    Thanks

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 8
    Last Post: 12-14-2011, 12:40 PM
  2. Replies: 30
    Last Post: 08-26-2011, 09:05 PM
  3. Java Applet to Applet communication
    By jsman in forum Java Applets
    Replies: 3
    Last Post: 04-05-2011, 02:23 PM
  4. applet class inside java.applet.* or java.awt.*
    By Manish87 in forum Java Applets
    Replies: 1
    Last Post: 09-27-2010, 02:15 PM
  5. Replies: 3
    Last Post: 07-23-2008, 08:07 AM

Tags for this Thread

Posting Permissions

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