Control DiscolsurePanel collapsing by another button instead of header text - java

I went through GWT Showcase and I found disclosure panel.
I want to control disclosure panel collapsing and expanding by clicking on one button.
In certain situations button can be disabled, In that case I want to enable/disable button.
Please refer this for more details:
Please suggest, How to do this?

You could use setOpen, but note that you cannot disable the DisclosurePanel and prevent it from opening when clicking its header.
You might want to build a custom widget instead.

Related

(Accessibility) Change auto focus to other component when using TalkBack

With the TalkBack setting enabled, the accessibility focus shifts to the hamburger icon automatically. (makes sense since it's the upperleft component in the screen).
When a user opens my app with TalkBack enabled, I want the focus to automatically select the text in the toolbar. This way, the name of the screen is spoken out loud, instead of the drawer action.
I have added an example below:
Use this code below on your toolbar (title) object.
android:accessibilityTraversalBefore="#id/drawer"
That will solve your problem.
I managed to set the focus manually on another component by simply adding the the following field:
android:accessibilityTraversalBefore="#id/idOfTheComponentThatHasTheAutoFocus"
In this way, you make sure that this component will be called first in the traversal order.

extended forms in java

I have this form where there are extendable controls like there's a textbox for the user to type and beside it is an add button which the user would use to add another textbox beneath the previous one.
My problem is i don't even know how to make that add button work so that another textarea/textbox would appear just beneath the previous control..im doing it in netbeans ide 7.0 and in design mode...
I have researching for quite a while now and i'm so confused already what to do..at least you could provide me with an idea not really the code.
You should create a Layout.
For your case (Form kinda layout) , it seems that you need GridLayout.
For example, please check this link for all type of layout or directly go to Grid Layout link.
Since you're going to be dynamically adding controls to your form, you'd simply want to put in a panel where you want the textbox and the button. Inside that panel place your textbox and button, you'd probably not want to use netbeans to do this, and use a LayoutManager like GridLayout. Now you'lld want to connect your button to an ActionListener that adds a textfiield to the panel.
See the Nested Layout Example for an example of (amongst other things) adding components to a GUI dynamically.

Adding a scrollable label to an option dialog

I am creating an options dialog using JOptionPane.showOptionDialog(...)
When I click one of the buttons added to this dialog, I need a label to apear underneath on the dialog (and this label should be scrollable if necessary). I have written event handlers for the buttons, but I am not sure how to get this label to appear on the dialog.
Any help would be great.
Update: I realized that it would be ok if I somehow called JOptionPane.showOptionDialog(...) with an initial message, and then when one of the buttons was clicked I would change the message. Is this possible?
JOptionPane static methods are only shortcuts to easily create a dialog with option buttons and a fixed message. If you check the source from it, you will see that all is wrapped in this purpose. It's only a convenience class over a frequent use case of dialogs.
The suggestion from comment is correct, if you want more than this, you will have to create your own JDialog, as it will be easier than trying to change something from this generated dialog.
Edit: You can create your own JDialog yourself, using layout managers. A more simple way, suggested as well in the previous link, is to use a GUI builder, like the one included in Netbeans.

tabs problem in Java Swing

I have created 8 tabs in a tabbed panel using Java Swing. The problem is when I enter data in any tab and click the save button. After clicking it leaves the present tab/panel and goes to the first tab.
I have to retain on the same tab after clicking the save button.
Please help me on this.
I got the answer, just forgot to comment the getFrame().dispose() method.
Thanks for your concern.

How to make a mouseEvent from a Component to be recognized in a subcomponent?

I have a JTabPane, and i have added a MoustListener to it(for tab's title).
When i press right click, a popup menu is created.
i need to make it invisible when i press the mouse button in any place of window. how can i do this??
(the MouseListener is applied only for tab's title.)
i need to make it invisible when i
press the mouse button in any place of
window. how can i do this??
This is the default behavour of a JPopupMenu so you don't have to do anything special.
Read the JPopupMenu API and you will find a link to the Swing tutorial on "How to Use Menus". The tutorial contains a working example of using a popup menu. Compare your code with the tutorial to see whats different. We can't help you because we don't know what your code is like.
If you need more help post your SSCCE.
in the good old days what I did to solve this problem was to register a mouse listener with ALL the components.
you can write a fairly simple function that recursively traverses a top level container and do it.
this was with Java 1.1, so maybe there is a better option today.
One way off the top of my head would be to grab the coordinates of the clicks, and then have another method to determine if the clicks are on the tab, or inside of the content area of the tabs.

Categories