Home arrow static arrow Java Programming [Archive] - applet help
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - applet help
This topic has 3 replies on 1 page.

Posts:23
Registered: 1/9/03
applet help  
Jul 29, 2004 9:09 AM



 
hi

i using an applet to display a set of results from a database
i m trying to display the results one below each other, the problem i am having is that the results
are overlapping each other can someone help

public void paint( Graphics g ){ try{     while (rs.next())     {       Title = rs.getString("pageTitle");        Url = rs.getString("pageUrl");       		        g.setFont(Serif);        g.setColor(Color.blue);        g.drawString(Title,50,50+20);		        g.setFont(Roman);        g.setColor(Color.green);        g.drawString(Url,50,70+20);      }}catch (Exception e){System.out.println(e.getMessage());}}    
 

Posts:49
Registered: 2/5/04
Re: applet help  
Jul 29, 2004 9:12 AM (reply 1 of 3)



 
Just try increasing the y coordinate a bit.
instead of 70 + 20 use 100
karthik
 

Posts:23
Registered: 1/9/03
Re: applet help  
Jul 29, 2004 9:14 AM (reply 2 of 3)



 
i tried it, it didnt work
 

Posts:316
Registered: 4/7/04
Re: applet help  
Jul 29, 2004 9:58 AM (reply 3 of 3)



 
the problem i am having is that the results
are overlapping each other can someone help

Either use a JTable or:
public void paint( Graphics g ){ try{     final int Y_INCREMENT = 20;     int y = 50;     while (rs.next())     {       Title = rs.getString("pageTitle");        Url = rs.getString("pageUrl");       		        g.setFont(Serif);        g.setColor(Color.blue);        g.drawString(Title,50,y);         y += Y_INCREMENT;		        g.setFont(Roman);        g.setColor(Color.green);        g.drawString(Url,50,y);        y += Y_INCREMENT;      }}catch (Exception e){System.out.println(e.getMessage());}}

You are not changing your Y in the loop
 
This topic has 3 replies on 1 page.