Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a Java applet which is running on a touchscreen monitor. I want to activate e.g. a button's action even when the user didn't hit it exactly. Maybe in a range of 5 pixel of the click, the nearest clickable object have to trigger his action.
How do I enlarge a button's hit area?
For example, if the size of a button is (width=100, height=25), the clickable area of this button should be a little bit larger than the button itself (width=120, height=45)
What I´m looking for is like TouchDelegate class from Android...
...Helper class to handle situations where you want a view to have a larger touch area than its actual view bounds...
There is padding option for this purpose.
So if you use padding your button looks smaller than the actual clickable area.
Sorry I don't know how to set it in Java applet. Try this post, I suppose Insets correspond to padding OR try this (like stated here):
button.setMargin(new Insets(10,10,10,10));
Edit
If you can use drawable resource to serve in place of a button there is another way - just make border transparent.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
enter image description here
Is it possible to put a button in the table like the attached image?
NatTable is a custom painted table control. Putting real buttons in the table is possible, but actually does not really make sense and could even lead to resource issues in larger tables.
You can actually render anything if you have a corresponding painter. And for a button you of course also need the action binding. NatTable has the ButtonCellPainter to render a cell as a button. But actually the implementation to mimik the button press is a bit outdated IMHO. The corresponding example should give you an idea what you can do and how to do it.
https://git.eclipse.org/c/nattable/org.eclipse.nebula.widgets.nattable.git/tree/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/examples/_102_Configuration/Rendering_cells_as_a_link_and_button.java
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I want to use a JSlider to display my data, and as such I don't want users to be able to move them as then it would no longer display the correct value. At the moment I'm disabling the JSlider so the user can't move the slider, but doing that makes the visibility of the slider really poor.
I would recommend against showing an enabled, but inspirational slider, as it is against typical UI conventions and will likely confuse the users.
Nonetheless, if you really want to do it: The default JSlider is either enabled or not, so you cannot do what you want directly. A workaround would be to have it enabled and add an ActionListener to it. This would be called once the user changes the value. In this ActionListener, you could just reset the value of the slider to its original value, so the slider would snap back. Again, this is very atypical behaviour of UI elements and might confuse users.
In the end, I would suggest coming up with your own component that displays a bar or other slider-like element to visualize your values, but which do not accept any user input.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm a student and still learning a lot about Java, but I have a pretty good grasp on the basics. Right now I am trying to figure out a way to recreate a radio button to mesh with the UI design for an application I have been commissioned to build.
The entire application is meant to be designed around the Star Trek LCARS interface (Bold bars, distinct color changes, no check boxes or radio buttons). I need to incorporate radio buttons into the design, but I have been unable to find any resource that will allow me to design a radio button without that distinctive filled/empty circle.
I already have a good idea of how I need to work the design. The selected item will change to a different display color with the mouse click or touchscreen tap. Selecting another item in the same group would deselect the original and select the new option, while trying to select the same item would unselect all choices (Select an undisplayed, "default option").
The problem is pure aesthetics, but it is important to the customer.
Is it possible to create a label (or other component) and have the ActionListener "transfer" the user interaction with the object to a radio button? In other words, the user clicks on the selection label and it fires off the same commands (change item/text color, play sound) and also fires off a command to set a designated radio button to either on or off?
well first of all... Everything is possible..its just a matter of how much time/effort you want to put in.
If I read that right..You have suggested creating a hidden radio button that gets information passed to it. This would work but is probably not the best way to design it.
I would personally just make an integer and call it mostRecentLabel or something to that effect and if you have 4 labels you would just keep track of which label was "turned on" with your mostRecentLabel variable. Then just put a function in that responds whenever a label is clicked to update your mostRecentLabel and this would update the display accordingly
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I've been trying to teach myself Java recently and as part of the process I'm working on a Calorie Calculator applet.
Just to make things more fun I was thinking to use the picture of a smartphone as the background image.
What I want to know is: say I also had a picture of a stylus pen; any way I could make that move with the mouse once I've clicked on it? Preferably this image would replace the mouse cursor (though not mandatory). It should stick to the mouse cursor until the applet is closed, regardless of any other events occurring (clicking other images, buttons, text areas etc.)
I appreciate your assistance!
..any way I could make that move with the mouse once I've clicked on it?
The main component needs a MouseListener. See How to Write a Mouse Listener for details.
Preferably this image would replace the mouse cursor (though not mandatory).
Look to the Cursor API for that.
This sounds like a classic XY problem.
What you might actually be looking for is Drag and Drop and Data Transfer.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I would like to have a red filled circle at some place in my window. After the click on the circle, the circle should jump from the original place to a new one (disappear from the old place and appear on the new one). What would be the best way to do it?
I also would like to know how to draw a filled circle in Java. Are there any simple tools to do it? Or may be the easiest way is to use an image created by some other software?
ADDED:
For the beginning I would like to have just a redraw (a circle disappear and at "the same moment" it appears on the new position). I think it will be simple that some visual effects and I would like to start from the simples possible choice.
This can be done using Swing, Graphics2D and a custom JPanel. The tutorial contains a similar example:
http://java.sun.com/docs/books/tutorial/uiswing/painting/step3.html