I have a touchscreen interface that I have adjusted the tab, button, and scrollsize but I am uncertain if it is possible to make JComboBox easier to select individual items. Is there someplace that I can find a list of all the UIManager attributes that can be changed with put?
This is what you're looking for:
http://tips4java.wordpress.com/2008/10/09/uimanager-defaults/
You may need to set your own ListCellRenderer. It doesn't seem to have anything to change the default height.
Related
What are the differences between ComboBox and ChoiceBox in JavaFX? I'm not entirely clear on that just from the Javadoc for both classes.
At the end of the day, I need a dropdown control that can be repopulated dynamically at runtime (I've got a database on the backend). For all cases in my application, I only need to select one item from the dropdown menus. The user also shouldn't be able to add an option to the dropdown menu from the screens they are visible on.
My understanding is that ComboBox allows the user to add items to the dropdown list and allows for selecting multiple items, but from the Javadoc it seems like it's possible to setup ComboBox in a way that meets my needs, so it seems like they're interchangeable to some extent. I guess ComboBox has a bit more overhead than I really need in this case, but is there anything else that only a ComboBox could do that would factor into this decision?
Edit
I guess I kind of answered my own question on the key differences, so is there something else I've not mentioned that differentiates the 2?
ComboBox supports a cellFactory which allows essentially an arbitrary UI for displaying the item in each cell. ChoiceBox does not have this functionality and will only display text in each cell (which you can configure using a converter).
See http://docs.oracle.com/javase/8/javafx/user-interface-tutorial/combo-box.htm#BABJCCIB listing 16.5 for an example of a custom cell factory in a combo box.
Well ChoiceBox is of the idea showing you optional choices, and ComboBox well shows you a list of items, ChoiceBox is like ComboBox but ComboBox is for a really lengthy list as you can specify the number of items to display like 10 or more or less, but ChoiceBox does not have the option it list all options and if its very long you wouldn't like the look.
in short ChoiceBox, for small set of list less than 10, for more ComboBox
That is from my perspective the difference, as for styling you can style all.
Combo Box
A combo box is a typical element of a user interface that enables users to choose one of several options. A combo box is helpful when the number of items to show exceeds some limit, because it can add scrolling to the drop down list, unlike a choice box. If the number of items does not exceed a certain limit, developers can decide whether a combo box or a choice box better suits their needs.
Choice Box
This chapter describes choice boxes, the UI controls that provide support for quickly selecting between a few options.
http://docs.oracle.com/javafx/2/ui_controls/jfxpub-ui_controls.htm
We can simply differentiate ComboBox and ChoiceBox by their functionalities.Just have a look on deffintion.
The JavaFX ComboBox control enables users to choose an option from a predefined list of choices, or type in another value if none of the predefined choices matches what the user want to select.
The JavaFX ChoiceBox control enables users to choose an option from a predefined list of choices only.
Apart from the mentioned differences:
ComboBox can show a prompt with setPromptText (ChoiceBox doesn't provide that method)
ComboBox can show more than 10 rows with setVisibleRowCount (ChoiceBox doesn't provide that method)
I want to remove the scrollbar from the combobox and hence increase the height of the combobox when it is open. Meaning, i want to see all the items without scrolling.
Thanks!
If you don't want scrolling and the list options will remain few in number and relatively constant, you might actually want the ChoiceBox UI element. It has relatively the same function as the ComboBox without the scrolling capability.
...
choice boxes, the UI controls that provide support for quickly selecting between a few options.
Check out the Oracle docs on how to use them -- it's very similar to the ComboBox.
I noticed that if I hover over my graphs it shows the tooltips like expected, but after a certain time they disappear. Now I managed to get around this problem by using setDismissDelay of the ChartPanel and setting it to a very high number, but this doesn't look like best practise.
Is there a better way to do this, maybe disable the method that hides the tooltip?
Instead of altering the tooltip parameters, add a ChartMouseListener that updates an adjacent component in its chartMouseMoved() handler. You can display the same data as the tooltip generator, and it won't change until the mouse moves. There's a related example here.
I have a list of entities where each entity render into widget based on JPanel. Widgets have dynamic behaviour - once placed on panel it can be changed by underlying entity. This happens automaticaly. Moreover some widgets can be resized by different actions, on button click for example.
The question is how to organise them into something like JList but without rubber stamp technics. In other words I wanna JList where each item rendered with cellrenderer stay "alive".
Right now I have implemented quick-and-dirty component based on JPanel with vertical BoxLayout, it uses JList's renderer component and it's model... but my implementation is too dirty...
Um.. yeah, using JTable is not suitable too.
Do you have some ideas?
If you don't want rubber stamping to take place then you'll have to create your own JList implementation that uses actual components.
You could try and work around the rubber stamping effect by caching each component for each row in your renderer and bind values into it and return that instance when JList asks the renderer for it. This is pretty risky because if you have 20 rows being displayed you'll have to cache 20 instances in your renderer, and only when the row isn't visible can you reuse one. That would mean if you had 5 unique configurations (A,B,C,D,E) of components you might have 10 of type A, 5 of type B, 2 of type C, and 3 of type D, and 0 of type E being displayed. However, you can't simply reuse one of those components without knowing if its being displayed or not. So you'd have to take into account if the row is being displayed and if it's the right type for the row you are rendering. And you'll have to clean up after the row is hidden.
Another option is make a single component for the row that encapsulates all X variations you have and put those on a CardLayout. Then you can simply cache one per row being displayed, and simply swap the card being displayed upon rendering that row. I think that might be the simplest option for you.
The harder part is going to be routing events click mouse clicks, keyboard events, etc to those active components to have them respond like normal components. Re-rendering the buttons when the user clicks them, and so forth is going to be challenging. Not impossible, but tedious.
Finally, variable row height JList is a pain. Especially in your calculations to figure out if a row is displayed or not because you can't simply do easy math like: int rowHeight = jlist.getHeight / model.size(). It doesn't work. You have to calculate each row's height and them up to figure out if a row is visible or not.
Doing what you're talking about is a lot of work, and very tricky coding to work around some of the assumptions of JList to make it work. In the end you might find it easier just to implement your own List control that makes different design decisions. Either way its going to require you are good at Swing to get it to work.
Ok. I don't find any implementation of such component. Let it be first one.
https://github.com/wertlex/JActiveList
P.S. I don't think this is proper way implementation... but it works.
use JList and ActionListener XD
In the application that I am working on, there is tabular data (for the record, it is a Java Swing app using JTables). In some cases the data is sortable by clicking on the column headers.
What I want to know is what is a good way to indicate to the user if a given column is sortable or not?
I have come up with the following possibilities.
1) Put an icon in each sortable column indicating it is sortable. I personally do not like this option.
2) Change the mouse cursor into something else when it hovers over the header to indicate it is sortable.
3) Put a note in the tooltip text when hovering over the column saying that it is sortable.
Does anyone have any other suggestions?
Update:
I think a clarification is in order.
My question is not how does one indicate that a given column is currently sorted. That is already implemented via the up/down sort triangle paradigm.
I want to give the user a clue as to which columns can be sorted before they click on the header to sort it.
Update 2:
I think I should explain why I'm not entirely sold on option #1. It seems to me that if one is going to put an icon to indicate which columns are sortable then this will add to visual clutter. In such cases, sometimes the UI changes on "mouse over". Case in point: Windows Vista and 7 allows one to add a filter on a column yet the indicator for this does not appear until you hover over the header with the mouse.
When you're dealing with the UI, you have to put your mind into what the user will expect. I would almost always recommend staying with the paradigms that your users will expect. Therefore I would recommend a version of option 1)
RememberME's post describes how this could work - You can still use arrows in column headers - one option would be to put an arrow icon in the header, but change the state of that icon if it was sorted (e.g. highlight the up or down button if the dataset is currently sorted by this column.)
Edit:
A Windows Explorer example may not be the best example here. My original text quoted below:
In Windows Explorer and almost all
form datagrids there is a small icon,
usually an up or down arrow, that
indicates that a column is sortable.
Experiment with Windows Explorer to
see the way in which this works.
In many apps, triangles indicate sortable so I think that's the best way to convey the information to the user b/c it's a standard they're most likely familiar with.
I think the jquery plugin from DataTables.Net is a good example. You could take a look and see if you like the look/functionality of that and emulate it. Both an up and a down indicate sortable. Just one or the other indicate that it is being sorted. If they column is not sortable, there is no icon at all. Their example also changes the pointer from an arrow to the hand pointer to indicate that you can click on the header.
I think the standard way is essentially option 1: either display the data initially sorted with a little arrow pointing either up or down (ascending/descending), or sort+display the icon as soon as the column header is clicked.
I think having a little arrow or triangle icon below the column heading, which you can click to sort by that column is the best option, as it is easy to see visually and very intuitive to use.
Little triangular up/down sort icons are pretty much standard for sortable table views in desktop applications and web pages. You may not like them, but your users are probably used to them (even if they don't realize it).
You should of course change the mouse cursor over clickable elements.
You should always do 2 for anything clickable.
Number 1 is not bad, typically a triangle pointing up or down depending on the sort order.
To indicate clickability, you could also use blue, underlined text on sortable columns and plain dark gray text on nonsortables -- the http link appearance is a well-known device to virtually all users, but it would not convey sortability, per se. Rather, a user might expect clicking that to take them to some other screen or list, as a hyperlink typically does.
I may be a little dense, but what kinds of columns are not sortable?
Pretty much anything can be sorted; even if there is no strict "greater than" relationship, at least there will be an "equals", and then sorting simply means "bring equal things together".
Strings? Try alphabetical ordering. Images? Sort by percentage of red, green, blue (or if you want to get fancy, compare color histograms). Locations? Use distance to Rome or any other arbitrary location.
Sorting on some columns may be much more useful than sorting on others; but I have a hard time finding a column type were it is important to avoid sorting from taking place.