I have a component "graphEditorPane" which extends from JGraph. Now I have this code :
graphEditorPane.setBackgroundComponent(situationLabel);
the problem is that this situationLabel is always aligned to the top left at the background of the pane. Is there a way to set it at the center of(the background of) the pane?
Related
I want scrollable panes.
Please, have a look at the picture
As you can see at the Navigator, I used Tabbed Pane, then placed Scroll Panes on it. Then placed Panel on it. And then added Lables. Looks like I'm trying to reach my left ear with my right foot. But without the jPanel1 my lable occupied the whole panel size.
Well now my scrollable panel doesn't work well.
It is visible at this .
Well, I made the window narrow. But the scroll bar at the bottom doesn't allow me to reach what is behind the border further on the right. And this scrollbar seems strange. It has only t left arrow. No right one. And no vertical scroll bar if I make the window less high.
Could you give me a hint how to make scrollable windows?
I'm not sure what you're doing wrong this is the results I get when I do only this and nothing more.
Drag and drop a tabbed pane to the frame
Drag and drop a scroll pane to the tabbed pane
Drag and drop a panel to the scroll pane
Drag and drop a label to the panel, and another label to the bottom.
Resize to smaller frame and scroll bars appear
Navigator Window
I have a UI requirement in java swing wherein I need to achieve the below:
The 2 buttons on the top are placed in a JPanel. I need to draw a line through the center of that panel, upto the beginning of the 2 buttons. The panel below is a container of panels arranged in a card layout. As and when the button is clicked, the card is switched showing another panel.
So in all respects this looks like a JTabbedPane, with one difference, the tabs are buttons arranged in the center of the tabbed pane. I need this difference for the UI I am building.
As of now, the buttons and card layout panel, looks like the below
As you can see, the buttons and panels appear and look separate, instead it would be nice if they are made to appear like they represent one unit.
As you can see, the buttons and panels appear and look separate, instead it would be nice if they are made to appear like they represent one unit.
Put the Border around the outer panel. That is use a panel with a BorderLayout. This panel can have a LineBorder. Then you add your button panel to the NORTH and the panel with the CardLayout to the CENTER.
The line won't be drawn through the buttons but the buttons and panel will appear like they represent on unit.
I have a border pane and there are components in its top, left and right side. I want to remove the components of its right side by using id of the borderPane through a mouse event. How do I do that?
Just do
borderPane.setRight(null);
I've always been a little fuzzy on the difference between the glass pane and a layered pane. Is the glass pane essentially just "the very top layer of the root pane," or does it behave differently? When would you use a layered pane instead of the glass pane?
They are two different things:
the layered pane is the destination of all the contents that are added or shown inside a JFrame. For example, every normal component like JLabels, JTextFields, JTable etc.. in addition it implictly handles z-ordering of elements that are added to it so it can handles popup menus, or drag and drop effects: this because a popup menu is added to the layered pane with a z higher than the normal components, with the final effect to stay on top of other things. See here to understand the behaviour better.
the glass pane is an optional layer that is hidden by default and stays in any case on top of the layer pane. So basically everything you draw onto the glass pane will be always visible: you can think of it as a trasparent sheet that is applied on the top of a normal JFrame that you can choose to use you need special effects.
Both the layered pane and the glass pane are placed on the root pane that is the basis from which every frame is built up.
I have a vertically split JSplitPane and when I move the divider down, it shifts the bottom component and the bottom gets cut off. Is there a way to specify the resize behavior of a JSplitPane so the top (of the bottom component) gets covered by the split pane and the bottom is the last thing to get covered?
thanks,
Jeff
The components are painted at the "(0,0)" position for each part of the split pane.
I guess you could create your own custom UI that does whatever you want.
A simpler approach might be to add the component to a scroll pane. You could then just let the scrollbars appear if required.
Or, if you really want only the bottom part of the component to be shown you could control the viewport position whenever the divider is moved. You can handle this by listening for a "dividerLocation" PropertyChangeEvent.
I think you might need to attach an event to the JSplitPane's resize event (I forget exactly what it's called). The event should then move the content up to suit.