File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Adding a button?

 
James Hambrick
Ranch Hand
Posts: 282
Eclipse IDE Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an applet and I want to add a button that clears the screen. I found some code that has a button to change the text color so I looked at it and added the parts to mine and concerned the button.
Here's the code I have. Right now I just have it setup so that when you click the button is changes the background color to test it out. It will not show the button on the applet..



[ July 08, 2007: Message edited by: James Hambrick ]
[ July 08, 2007: Message edited by: Bear Bibeault ]
 
James Hambrick
Ranch Hand
Posts: 282
Eclipse IDE Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i was just thinking that I should use Swing and not AWT so im going to try and switch it around to use Swing. Any help is appreciated.
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It works fine for me in appletviewer. Could the problem be that the applet tag has a "heigth" attribute, instead of "height"?

BTW, your homepage link is broken.
[ July 08, 2007: Message edited by: Ulf Dittmer ]
 
James Hambrick
Ranch Hand
Posts: 282
Eclipse IDE Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yea, it shows in IE, but using Firefox it does not show up, I guess thats a reason I should use Swing and not AWT. Thanks for pointing that out. I though it looked right but it was not working which is pretty frustrating for me.
 
James Hambrick
Ranch Hand
Posts: 282
Eclipse IDE Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So now that's out of the way, how do I clear the screen. Someone suggested drawing a rectangle the size of my applet and then filling it with my background color. Is there are better way, thats easy but seems like there would be ramifications by doing so.

[ July 08, 2007: Message edited by: James Hambrick ]

[ July 08, 2007: Message edited by: James Hambrick ]
[ July 08, 2007: Message edited by: James Hambrick ]
 
Shoumin Li
Ranch Hand
Posts: 85
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by James Hambrick:
[QB]So now that's out of the way, how do I clear the screen. Someone suggested drawing a rectangle the size of my applet and then filling it with my background color. Is there are better way, thats easy but seems like there would be ramifications by doing so.
I think drawing a rect filled backgroud color may be the easiest way,
And it has a good efficency
 
James Hambrick
Ranch Hand
Posts: 282
Eclipse IDE Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I also now have it made in Swing and also added a button that changes the foreground color to red. But when I click clear screen my Red button does not show up until my mouse goes over it. Why is this???

Also I have this code


If I draw a line, then change the color, that line changes color. I only want the lines to be a different color after I click the button. I zeroed out the PmouseX, PmouseY, RmouseX and RmouseY and that worked except for that when I drew lines too fast the lines would start from the upper left corner(0,0). Any Ideas?
[ July 09, 2007: Message edited by: James Hambrick ]
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One thing that jumps out at me is that string comparison is done using the equals method in Java, so



should be

 
James Hambrick
Ranch Hand
Posts: 282
Eclipse IDE Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the improvement. Ill try and figure out the code some more later about the last line drawn turning the color of the button I click.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic