-
In .NET a UserControl may be composed of Controls and it may be part of a Form or part of a bigger UserControl. One can design UserControls with a Visual Designer using the ToolBox Palette.
-
I have found out that a java BeanForm is the analouge for a .NET UserControl.
-
I can design a BeanForm with a visual Designer in NetBeans
-
In my Library I can extend a BeanForm from any other Library and I can design the extended BeanForm with a visual Designer in NetBeans.
- In my main Project I can pick all my BeanForms from the Palette onto my frames.
So “BeanForm” is the java pendant for the “UserControl”.
In .Net I can easily shape my UserControl to a Fish or to a Star or to whatever I like
by simply setting this.Region = new Region(graphicsPath).
I know that Java is not as easy as C# and I have found Java Samples that partly describe the necessary steps BUT
I did not find a Shaped non-rectangular BeanForm Sample.
Of course extending the MouseAdapter with a new special mouseClicked(MouseEvent e) — as many Samples do suggest — isnt enough – this is only a first step.
- Did they all forget about the Dragged-Event and the Focus Events and the Mouse-Entered Event and Mouse-Up Event and Mouse-Leave Event and all the other typical JComponent Events ??? – Such Component will SURELY NOT BEHAVE like a real Shaped JComponent should behave.
Please give me a Sample for a OvalComponent-BeanForm that can be taken from the Palette onto my frame and that will behave like a REAL Shaped JComponent
It should cover All the necessary Mouse Events and all the necessary MouseMotion Events and all the Drag-Drop Events and all the Key-Events in case the Oval has the focus or in case the Mouse is over the Oval.
(e.g I should be enabled to use the Oval’s Mouse Events and to extend the Oval Component to a MovingOval Component that can be moved around within the frame …)
If this is too much work for you then, please, outline and describe the steps I would have to implement – like MouseAdapter, KeyAdapter, maybe DragDropAdapter or whatever is necessary.
please, point me what to do!
many thanks in advance.
Every
java.awt.Shapehas acontains()method that you can use for hit testing in yourMouseListenerorMouseadapter.