Java: Creating a scrolling submenu - java

I have a program in which I have a large amount of items listed under a specific submenu. I am looking for a way to scroll through them, as the menu is now larger then the screen. Previously i have seen menus in which the top and bottom icons are arrows which, when the mouse hovers over, scroll up or down respectively. Can someone please explain to me how to do this? Or else simply how to add a scrollbar to my submenu?
Thanks!

Another option might be Darryl's Menu Scroller.

Related

Adding a 'Minimize' button to JTabbedPane Tab Bar

I've searched extensively to solutions for this but haven't found anything that really achieves what I'm trying to do, the closest thing I could find was the solution posted at the bottom of this thread: http://www.java-forums.org/awt-swing/12267-how-add-jbutton-tabbed-pane-headder.html .
However because the JTabbedPane I'm using is inside a JSplitPane, it's size can increase/decrease, so using that solution doesn't work as the button stays static.
Below is an image of where I would like the place the component, similar to how eclipse has a minimize button on it's pop out views.
Is this possible without creating a custom JTabbedPane component?
Do you really need this button to hide?
Why don't you set splitpane.setOneTouchExpandable(true);?
With this line you can hide the bottom with an arrow of the splitpane.

Java PopUp Menu & Floating BOX on the Top

I'm currently in a stagnant (stuck) point here.
First of all, let me clearly telling you about my case here.
I have Java Swing App that use a Pop Up menu.
I create some 'N' items of Menu Items There.
I wanted to have 1 Box area at the top of it, it will show 1 Single Image.
I'm planning to use either another JPopup Menu over there, or maybe... Floating JPanel.... I'm not sure which one is good.
Thus, I need the fixed coordinate to placed them on. Now i'm confused.
Anyway, Here is the Screenshot.
My Question is...
How do I make the GreenBox appeared on the top of Those Menus?
Should I calculate how many 'N" menu Items multiply by Font Size as
the fixed coordinate?
Or...
Something else I forgotten? What is the appropriate step to overcome
this case?
I'm still
Digging for answers...
Use JWindow (required JFrame, this JFrame never couldn't be visible), this container is undecorated by default, or maybe un_decorated JDialog, with ModalityTypes or setModal

Scrolling functionality in Blackberry

I have 4 buttons 1)left 2)video 3)technical insight 4)right..as seen in the below image.Now I want to provide functionlity to this image.The functionality is
If i click on the left arrow the video technical insight have to scroll to the left and similarly if I click on the right arrow the the two buttons have to scroll to the right and show two more video names..in Blackberry Simulator
Can anyone please help me in writing the code.I would be happy If I can get the code to provide this functionality in Blackberry..
I have some ideas regarding this.Do tell me if this can be done or not..
I created left button ,videos button,technicalinsight button and right button in a manager called hfm
When i click on the left button the entire things in hfm will get deleted using hfm.deleteAll() and then repaint it with the hfm which we get after scroll.
Is this idea good or any better approach for this??
you can Override the paint() method and use graphics.drawBitmap to redraw the screen.

Rectangular Java Swing Radio buttons?

I'd like to create a set of buttons in a Java Swing application like you get in a typical tool palette in a paint program. That is, a set of small square buttons, each containing an icon, only one of which is pressed down, and when you press another button, the first is deselected. I've thought of a number of solutions and none of them seem very easy/elegant.
This sounds like a job for JRadioButton, but if you add an Icon to that, you still get the small circle, which is fairly space inefficient. I guess an option would be finding an alternative Look and Feel or painting code for JRadioButton.
Another alternative might be to add JButton to a ButtonGroup, maybe setting a JToggleButton.ToggleButtonModel as the model, but that doesn't have the desired effect, as the painting code for a standard JButton does not keep it depressed when selected. Possibly the JButton code could be modified to do this. Like making it painting "selected" the same way as "pressed".
A third alternative would be to use normal JButton's, and add a common mouse listener that keeps them pressed or not, and communicates the changes between the buttons.
Can anyone advise on the best way to achieve the aim please? A simple method I've missed would be best, but advice on which of these three alternatives would be best and pointers on how to get started would be useful too.
What about a plain JToggleButton in a ButtonGroup? It is not abstract, you can instantiate one with an Icon, and it stays depressed while selected.
See the SwingSet2 demo:
http://java.sun.com/products/plugin/1.4/demos/jfc/SwingSet2/SwingSet2.html
Click the second icon on the toolbar (the one twith the check box and radio button) then tab "Radio buttons". Then click on "Paint Border" on the right panel, under "Display Options".
Source code of the demo is under your JDK install dir, so for example on my PC it's under \jdk1.6.0_01\demo\jfc\SwingSet2\src

Java: big popup menu with additional panels

I want to create a popup menu which has a few "big" (special) items.
These "big" items should somehow behave like submenus, but they are large panels (with buttons, labels, combo boxes, etc.). These panels should all appear when the mouse is over (or pressed at) the corresponding menu items, and they all should appear in the same screen area just next to the popup menu, beneath the topmost item entry, not aligned to their corresponding item). The last-selected of them can remain visible as long as the popup is visible.
Basically, I believe this feels like (A) putting a JLayeredPane next to the popup menu, and switching the layers according to some mouse events. Probably this would require to fake the whole popup menu using a single large JPanel inside a JPopupMenu having just this one entry (i.e. also all "ordinary" menu items would in fact have to be buttons.)
So, on the other hand (B), it seems probably smarter to use standard swing submenu items, add the big panels as submenu items, and then force all the submenu items to the same location and size. Though, I am not sure if this will work and whether there will be such problems like the menu getting instantly hidden as soon as the user clicks a combo box inside one of the big panels.
Would you recommend going for either (A) or (B) — or perhaps (C) ?
Any experiences / known pitfalls doing such things?
Kind regards,
Philipp
I don't have experience with A or B, but between the two I would try B first.
Another option that might be better is to use a JDialog. Set to to be undecorated and hide it when it loses focus. (This might just be an easier way to do A).

Categories

Resources