• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Some text issues with drawString

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok I'm having some problems with drawString.
Here are parts of the code:
//g.setColor(new Color(0xffffff));
//g.fillRect(0, 35,400,230);
----------
if (Start == null)
doStart(g); <- does a drawString, works fine.
if (Sort == null)
g.drawString( "Sorted Employee Names", 20,60);

---------------
class MyMouseAdapter extends MouseAdapter{
public void mouseReleased(MouseEvent event) {
JButton b = (JButton)event.getSource();
if(b == Start)
Start = null;

else if (b == Sort)
Sort = null;

repaint();
}

Ok so my first problem is when Start is pressed and it goes to goStart to write the text using drawString, it loops endlessly.. so instead of having 4 lines of text it just loops and fills the whole screen. I can put some sort of counter in there but would like to know if its something technical that I missed.
My second problem is that when the Sort button is pressed it does not clear what Start put on screen. So the text in sort is placed on top of whats there before. i tried placing repaint() in a couple of spots but it did not help.
Lastly, the first two lines I commented out. If I uncomment them the screen flickers when I view the applet, so all the text mainly flickers..
I've been at this for a couple hours and will continue figuring it out after I hit submit. Any help is apprciated!
 
Jacob H
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok I've seem to solve the flickering and the filling up of the screen with text.
The one problem I have is switching between buttons.
First time I run I can switch fine from Start to Sort but after that nothign works and it stays on Sort.
Here's the code:
if (Start == null && Sort != null)
doStart(g);
else if (Sort == null)
doSort(g);
-------------
class MyMouseAdapter extends MouseAdapter{
public void mouseReleased(MouseEvent event) {
JButton b = (JButton)event.getSource();
if(b == Start)
Start = null;
else if (b == Sort)
Sort = null;

else if (b == Clear)
Clear = null;

repaint();
}
[ November 24, 2003: Message edited by: Jacob H ]
 
Jacob H
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All solved.
 
reply
    Bookmark Topic Watch Topic
  • New Topic