I have added checkboxes inside combo box in Java. But when I open drop down menu and check one check box, the drop down menu closes. So to select each check box I have to open it every time.
Is there any way so that I can keep the drop down list opened till the time I dont click outside so that I can select any number of check boxes at one time only.
Please help!!
I have added checkboxes inside combo box in Java. But when I open drop
down menu and check one check box, the drop down menu closes. So to
select each check box I have to open it every time. Is there any way
so that I can keep the drop down list opened till the time I dont
click outside so that I can select any number of check boxes at one
time only.
no there isn't, this is default property of (BasicXxx)Popup implemented in Swing API, workaround for series of Bugs in Java1.4_xxx
no_way, only by using dirty hacks, usage of can be Java Version sensitive, or required left mouse button as accelerator
don't do that, another way (and proper of possible ways) is usage of JWindow/undecorated JDialog but required to override ESC Key and Focus lost in Windows three (as you can see in good Java JCalandars/JDatePickers),
I recommend that you to use the Japura API to deal with this, check this link:
http://www.japura.org/checkcombobox
Best Regards :)
Related
I need to select appropriate option from the popup window. Unfortunately, it is not the popup displayed by the web page, so I cannot use Selenium framework for that purpose.
As I checked, it is possible to navigate to different option by pressing arrow keys. Thus keyPress and keyRelease from Java AWT Robot should work for me perfectly to select option and confirm the selection by pressing Enter key.
Unfortunately, I do not see a method to read currently selected item text. Without that I cannot find appropriate option. Is it possible to read item label using Java AWT Robot?
If the target application is another java application, then you should be able to get a reference to the component hierarchy and traverse it until you find the text field & label in question.
Assuming it's not a java application, then I don't believe it's possible to do this - at least directly. Robot just provides mouse / keyboard input, but you could use it combined with other classes in the toolkit to at least partially solve your problem.
Use the Robot methods keyPress & keyRelease to input CTRL-A. Then CTRL-C.
Once the text is in the clipboard, you could read it using Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor)
You might be able to use the same approach for a text label, assuming it is selectable.
This question is talking about using java.awt.Robot to alter text in another program (MS excel), but it might provide you some additional ideas for tackling the problem:
How can I select text in another application with java.awt.robot (example: shift+home)
I'm working on a java project in NetBeans. I have put 5 checkboxMenuItems in 1 Menu (First Class) (see picture). Now I want to be able to check or uncheck multiple items at the same time. Meaning that I want to open the menu once, check and uncheck what I want & then use a function that looks which are selected or not. I know I can do 'actionPerformed' on each separate checkboxMenuItem, but that's not what I need here.
How should I handle this instead?
I am looking for a way to create a popup dialog box when a user double clicks a textinput field that will contain a scroll-able list (from database table) where the user can select a field, hit ok, and have it placed into the textbox when popup closes.
The other major requirement is to have a filter/ or search field in the popup to aid the user in finding the correct option to select from quicker.
What is the best way to implement this?
Modification to gwt's popup panel? maybe a JOptionPane? are there any simple solutions already designed for free commercial use?
You could implement this with a com.google.gwt.user.client.ui.PopupPanel. You can make a PopupPanel that contains a ListBox with your data from the database, along with a OK button. When a user selects a value and hits OK, you should utilize an EventBus along with a custom Event that will pass the value to the field on the page. The page will have an event handler that will catch the event and put it into the field.
Another option is to use a com.google.gwt.user.client.ui.SuggestBox. It is a box that autocompletes / suggests values as you type, kind of like the Youtube search bar.
I can offer more resources to help you accomplish this, if you'd like.
For those who are familiar with SwingX's AutoCompleteDecorator, I have a question regarding handling of JComboBox's Popup Visibility. I used AutoCompleteDecorate.decorate(JComboBox combobox) in my current project which I already mentioned in my previous posts, the problem I encountered is when ever the user type a keyword that doesn't match any of the combobox items, the popup remains visible. For the convenience of the users, I would like to hide combobox's popup if the keyword typed doesn't match any of combobox items.
If you want the autocompletion feature, but you don't want to have a popup in the way (especially, as you mention, when entered text doesn't match any item) you might like to try the opensource JIDE Common Layer. It has a very useful (I use it a lot myself) autocompletion feature that you can apply to JComboBoxes, JTextFields, etc..
You can see a Java Web Start overview of the components by clicking on the "RUN IT" link on the above page, or by clicking here. Navigate to
Demos->AutoCompletion Demo->AutoCompletion combo box and text field->AutoCompletion JTextField with a hidden data
to try it out. You can also see the source code by clicking on Browse Source Code.
You can enable/disable a strict flag in order to prevent/allow user to enter text not matched with items.
However, as far as I have tested, JIDE's combo boxes with autocompletion also have the "issue" that keep their popup open even if no match is found, but what I'm suggesting here is to try an autocompleting textfield which has no popup at all (they autocomplete in place, highlighting the part of the matched text that you didn't manually type-in).
What is the name of this dialog? I cannot use plugin spy as this dialog does not stay open very long. This is the dialog to switch editor.
Ctrl+F6 — Switch between last used files.
It shows you the list of last used files. If you hold Ctrl and press F6 more than once - you will iterate on this list.
Firstly, the word 'dialog' might be misleading. This 'popup list' interface doesn't have window decorations, so it's hard to say whether it's a dialog, frame or something else. This might mean you're looking in the wrong places.
FYI, Switch Editor (CTRL+F6), Switch View (CTRL+F7) and Switch Perspective (CTRL+F8) all use the same type of popup so finding one of their class names should help you find what you're looking for.
This SWT spy might help you find the component. To get around the issue with it not being open long, press and release the SHIFT key while the list is open, and it will now stay open if you release all the keys, and will only close if you click away or use ESC/ENTER.