I have a menu bar with many SimpleButtonAction. Some of them need to show if they are pressed or not (for example, the "show grid" button).
I have looked for this feature, but I am not an englishspeaker and I don't even know if this is called "triggering" or anything else.
I found JToggleButton, but it can't be added to a menu bar into a bibliothek.gui.dock.DefaultDockable.
Any hint so I can search better for some info?
JCheckBoxMenuItem ? JToggleButton?
Related
I have a pretty basic interface of a chromotagram viewer. In the menu I allow the user to reverse the viewer with a JCheckboxMenuItem. Functionally, it does exactly what its supposed to do. My interface allows for multiple chromatograms to be open at once. I will post a few example pictures as I get to my question.
Above I have one tab opened and have yet to reverse the chromatogram.
Above I have clicked the option and it worked.
Here is my issue. If I open another tab and move to it, the option is still checked even though I have yet to click that button. The easy way out would be just to make it a normal button but I just want to know if there is a way that each tabbed could keep track of if its been reversed yet. Would this require multiple instances of the button itself? If anybody has any suggestions, please let me know. Thank you.
if(centralPara.getNumOpen() > 1){
centralPanel = centralList.get(centralPara.getCurrentFrame());
JCheckBoxMenuItem reverseItem = centralPara.getReverseItem();
boolean reversed = centralPanel.getReversed();
reverseItem.setSelected(reversed);
}
in my tab change listener I check to see that we have atleast more than one tab open. if so get the frame we are currently viewing and the top level menu item. Force it be be selected if that the current view frame is selected, or else force it be unselected.
I am developing a simple swing application and I would like to have something which can help user with it.
As example a little popup window will appear over "Start" button when user runs app first time and say "Hey, click here to start playing with me!"
Do you know the way to create something like quick doc in Intellij Idea?
Could you please put me on the right way to sources, examples, source codes or anything else which could be useful?
Below is example of how it can look like
PS. I have updated the picture.
As I said in the comment use javax.swing.PopupFactory to show popup for any component (which is probably not pointed by the mouse)
Popup p = PopupFactory.getSharedInstance().getPopup(component, new JLabel("It's a hint!"), 5, 5);
p.show();
component is the widget for which the popup must be shown.
You can also use the javax.swing.Timer to hide this popup automatically.
Tooltips are used in Swing to give the hover-over text that you are looking for. It is very easy to use a tooltip, all you have to do is set the tooltip text on your button
btnStart.setToolTipText("Hey, click here to start playing with me!");
Here is a pretty useful guide that explains the topic in more depth http://docs.oracle.com/javase/tutorial/uiswing/components/tooltip.html
I want to achieve following functionality:
User places the mouse cursor over a text item in the editor and this is being detected automatically, triggering a menu item to be enabled in the menu (when user moves mouse away, the menu item is disabled again).
As I'm a little new to xtext and RCP in general, I don't know where to start. I only don't know how to implement detecting if the cursor is over a certain element in my DSL code. Is there any way to achieve this?
Kind regards,
Marko
Yes, XText support hover detection. There are some sources in internet, that might be helpful for you.
http://christiandietrich.wordpress.com/2011/07/16/hover-support-in-xtext-2-0-tutorial/
http://ckulla.wordpress.com/2011/02/06/hover-support-in-xtext-2-0/
http://www.eclipse.org/forums/index.php/mv/msg/452862/1008201/#msg_1008201
What I want to do is, when my Edit JMenu is clicked on, before it appears I want to set enabled on the undo / redo commands based on whether or not they should be visible.
Is there a way to get such a notification? Is MenuListener what I'm looking for?
You should be able to use a MenuListener, an extended EventListener, and enable the undo/redo items in menuSelected.
Now that I think about it, that probably would've been a better way for me to have done something very similar. I instead enabled/disabled the items in an undo/redo method in my view when my history object reported that there were no more undo/redo commands left.
EDIT: I see you must've quickly edited your post before I had the chance to post this and found MenuListener yourself.
We are building our own Web Browser in Java. It doesn't have to be anything too complicated, we just want several things to do so we could distinguish our project from others.
What we want to know is this:
Is it possible to somehow embed a JTextField object into a JMenuItem?
To be more precise, we want our address bar (text field) to show when we click on a certain item within our menu.
Well, menu items are used for invoking an Action which causes the menu to close.
So you would just have your menu item Action display a popup dialog or something like that.
Or, if you really want to keep the popup open, the you could probably create a sub menu and then just add the JTextField to the sub menu. Remember, you can add any Component to JMenu.
Or, if you just want the text field to display on the main menu, then you just add the text field to the main menu. Of course you would lose functionality like being able to use the keyboard to navigate up and down the menu list.
All the suggestions are a hack at best, so I agree with the original comment to your question.
It's done in the standard OS X "help" menu, so I wouldn't call it an interface "quirk".
A quick google turned up this old link from 2004:
http://coding.derkeiler.com/Archive/Java/comp.lang.java.gui/2004-12/0149.html