Need Java Help
Page 1 of 1
Need Java Help Make a menu bar, and change line thickness
#2
Posted 08 May 2009 - 04:57 PM
cmoney12051, on 8 May, 2009 - 04:39 PM, said:
i am making a paint application and need to have a menu bar at the top, how do you make one? it is a java JFrame. also how do you change the thickness of a g.drawLine. thanks
For the menu bar look at JMenuBar
http://java.sun.com/...g/JMenuBar.html
as far as the thickness of the drawLine this a feature of Paint programs not a feature of the GUI. You will have to implement it yourself...by invoking drawLine as often as required for the thickness to want to represent
it is easy for perfectly horizontal and vertical lines (just draw thickness lines one beside the other or even draw a filled rectangle) but when lines have different orientation it becomes a challenge
#4
Posted 08 May 2009 - 05:38 PM
cmoney12051, on 8 May, 2009 - 05:32 PM, said:
ok thanks for that, i got the menu bar working, and am working on the line thickness. how would i go about making an eraser? thanks
you have to store independantly the data of what you have to draw
erasing is simply updating what as to be drawn and call repaint()
the same way if another window occludes yours. When the other window will be iconified your paint() method will be called and you have to be able to redraw everything that need to be drawn (not erased and erased parts)
This is a lot of work... if you have a draw rectangle feature the user can draw a rectangle and you can feel like saving the data: there is a rectangle at X,Y width = height =
Then the user earse part of the rectangle... the rectangle is NOT a rectangle anymore.. it is now a bunch of lines or even pixels
Easiest way is to have an array of pixels the size of your screen and to optimize the way you repaint them... not pixel by pixels :-)
This post has been edited by pbl: 08 May 2009 - 05:42 PM
#6
Posted 08 May 2009 - 06:11 PM
cmoney12051, on 8 May, 2009 - 05:54 PM, said:
ok thanks, last question, how do you do mouseovers, like a mouseover for a jbutton? thanks
You won't beleive the number of times somebody replied with a phrase starting by "ok thanks, last question"
OK I wrote a Code Snippet on how to track mouse over JLabel but it would apply to any JComponent
Just click on "My contributionms" under my sexy picture and go to the snippet talking about listener over JLabels
#10
Posted 09 May 2009 - 05:37 PM
cmoney12051, on 9 May, 2009 - 03:50 PM, said:
alright so i found your thing is your contributions page, but i cant figure out how to make it display text when the mouse is over the label. how would i implement this using your snippet? thanks
A ToolTipText ?
http://java.sun.com/...va.lang.String)
Page 1 of 1

Start a new topic
Add Reply




MultiQuote
| 


