Adding a 'Minimize' button to JTabbedPane Tab Bar - java

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.

Related

Which is the Java swing component to realize a window with a smaller X button?

Help me please to find which swing component should I use to display a window, similar to "Styles and Formatting" in Libre Office. It has a smaller "close" button and no icon at the left top. And, what is the most important for me, always remains in front of the main frame.
Such a window I would like to use in my Java application.
Thank you very much!
Seems you've not tried much... Just googling a bit you can find easily the 4 steps you need to achieve your goal:
create a JFrame,
put an X button in your JFrame,
set a listener to X button
put JFrame on top

What is the name of this Swing component?

I want to put one toolbar type component in which there will be one button which when pressed the toolbar should expand, size of the form increases and it contains some components like text area and label that user can see and once again when the button is pressed the toolbar is minimized and the size of the form decreases.
Can anybody tell me how to accomplish this?
e.g; like in windows 7 in my computer there is one toolbar called "Hard Disk Drives". When we press on it it shows all the drives and when we again press it it hides it.
SwingX has a collapsible panel control that I think should do what you want.
Also take a look at How to have Collapsable/Expandable JPanel in Java Swing.
Some alternatives:
You can add a JButon to a JToolBar. In your button's ActionListener, open a JOptionPane containing your components. This example illustrates some possibilities.
For a more advanced view, consider Outline, illustrated here.

how to setup this gui

Im having quite a difficult time setting up this GUI
As you can see in the picture i need to have several clickable items and i dont know how to do it. So i thought i could make one different VerticalFieldManager representing the white background. But it looks impossible to have more than two VerticalFieldManager over the main manager. So i thought i could use a LabelField and change the background color to white (it didnt work either) and on top of it put clickable labels and clickable textField but i dont get the background VerticalFieldManager to repeat it self and put itself under the previous one with a slight margin between them. Anyways, can you guys give me ideas on how to accomplish this GUI, what to use as background.
Thanks in advance and have a nice one.
I would suggest the following layout
Screen delegate should be VerticalFieldManager
Each item should be VerticalFieldManager as well
The body of the item itself should be RichTextField
The rest of the clickable elements you mentioned should be clickable Labels.
You will have to use HorizontalFieldManagers as well. One for the top panel and one for the bottom panel. Check the JustifiedHorizontalFieldManager from the advanced UI libarary.
As for clickable label - it is easy to implement one. Search SO for "[blackberry] clickable label". You can also check the BaseButtonField and BitmapButtonField provided in BlackBerry advanced UI library and available here.

Put new component on JXTaskPane

The JXTaskPane used in Java Swing has a title bar. There is a expand/shrink button in it. I would like to be able to add my own actions in the titlebar that would appear beside
the expand/shrink button.
How can I do this? I try myself many times, but do not get the expected result. I made a new JButton and set its location over the title bar coordinates, but it's added in the element.
I have attached a screenshot that shows a help type action in the title bar to show
you what I mean.
That's not possible. I'd recommend perhaps making a new JFrame pop up when you click the button to extend the dropdown menu. Creating your own JFrame popup would also afford you more creativity and customizability when it comes to the components you can put on it. I've not much experienced with this sort of thing, but you could try to do this. It might not be ideal though.

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

Categories

Resources