I have a few radio buttons and then a checkbox, I have tooltip's for the radio buttons but not the checkbox. Which works okay, unless I get a radio to display it's tool tip text and then quickly move to the checkbox, before the tip disappears, and now I have my mouse on the checkbox but it is displaying the tooltip for the previously moused over radio button.
I tried setting a blank ("") tool tip for the checkbox, which works okay except that it displayed a very small tooltip square.
Is there anyway to either force the previous tooltip to go away or to properly set a nothing tooltip for the checkbox?
radioButtonsetText("text");
radioButton.setToolTipText("tooltip text");
checkBox.setText("text");
checkBox.setToolTipText("");
or to properly set a nothing tooltip for the checkbox?
Components don't have a tooltip by default. So don't set the tooltip and your won't have a problem.
If you set the text and want to remove it the try using:
component.setToolTipText(null);
Related
How can I define Java JEditorPane to be able to always read text from the user, include after clicking on button, Now when i typing text and i click on some button on the screen, I need to click again on the JEditorPane so I could be able to typing more text.
Looks like the problem is lost focus. You can make the button not focusable
theClickButton.setFocusable(false);
Or return focus to the JEditorPane in the end of the button's action
editorPane.requestFocus();
Below is the snapshot of the layout I'm trying to achieve.
I have two questions/problems here:
Right now,the page loads with all the accordian panels open. I want it initially to be in the closed state (like in option 1).
On click of the Radio button near the tab, the tab should expand. If I click on another radio button, the new tab associated with the radio button should expand, and the other one should close.
How do we accomplish this ?
I don't see any toggle function or anything associated with PrimeFaces accordian. There is only widgetVar.show() function, but it's not helping me.
To begin with your accordion panel tabs closed try setting activeIndex to -1 (or any value that does not correspond to an existing panel). I have not tested this with multiple tabs in an accordion panel, but it should work:
<p:accordionPanel activeIndex="-1">
I know that JComboBox has three components which are textfield, arrow button and the drop down menu.
My task is that disable the textfied so only the button is shown and when clicking the button we can see the dropdown menu.
Is it possible to do that?
"Dropdown only" is the default behavior. The text field only appears if you set the combo box to be editable.
http://docs.oracle.com/javase/tutorial/uiswing/components/combobox.html
I have a JTextPane sitting in a JFrame, with a popup menu that is assigned to the JTextPane through the JTextPane.setComponentPopupMenu method.
I want to give the JTextPane a "Word-like" popup behavior. By that I mean, if you right click outside of your current text selection, the caret will reposition to where you right clicked, with menu options that affect a text selection (such as cut, copy, or bold) disabled. If you right click within your current text selection, the popup will appear with options that effect text selection enabled, the text selection will persist, and the caret will not move.
The problem is I cannot seem to find where I can put the code that handles the selection change. I tried:
Using the "PopupMenuWillBecomeVisible" event which is triggered before a popup becomes visible. The event passed into this method does not contain any mouse event information so there is no way for me to use viewtomodel to find out how to modify the selection. I could use MouseInfo but that seems dubious at best.
Using MousePressed/MouseReleased events in the JTextPane or JFrame. Apparently, neither of these events are invoked when a popup menu is triggered. In fact, I still can't determine what the parent component of my popup menu is. (I did read that in windows "MouseReleased" is the popup trigger, while in other systems "MousePressed" is the trigger. I tried both and neither worked).
So, I guess the problem is that I can't seem to find a place to put code where it would be called before the popup menu becomes visible, but has awareness of the mouseEvent that triggered the popup menu. I must be missing something here.
with a popup menu that is assigned to the JTextPane through the JTextPane.setComponentPopupMenu method.
You can use the older approach of displaying the popup based on your own custom MouseListener.
See the section from the Swing tutorial on Bringing Up a Popup Menu. Now you have access to the MouseEvent so you can convert that point to a point in the Document so you know where the click was made, on selected or unselected text.
I'm making a fairly simple text editor, and I have a question about my style buttons. When I highlight text and click my "bold" button, the text bolds as expected, but my selection is not longer visible. I can still unbold the selection, italicize it, or underline it, but you just can't see what is selected. So, I'm wondering if there is a setting that will allow me to click the button, but keep my selection? I tried a JMenuItem instead of a JButton, and that seemed to work, but then it made my toolbar look quite bad. Sample code below.
//frame and pane creation up here
JToolBar tool = new JToolBar();
JToggleButton boldButton = new JToggleButton("Bold");
boldButton.addActionListener(new StyledEditorKit.BoldAction());
tool.add(boldButton);
Any help is appreciated.
So, I'm wondering if there is a setting that will allow me to click the button, but keep my selection?
boldButton.setFocusable( false );
As you noticed, the selection is still there but clicking on the toolbar button removes the focus from the text pane and hides the selection. You need to set the focus back using requestFocus. However, you will need to write your own action listener to add the focus code - you could extend BoldAction to do this.