I was trying to position a JProgressBar to the bottom of the window's screen. I have tried using setVerticalAlignment and setHorizontalAlignment. When doing so a syntax error appears.
To make it clear my goal is to put a progress bar at the bottom of the window.
An easy way is to set the parent container to have a BorderLayout, then panel.add(progressBar, BorderLayout.PAGE_END); will make the progress bar appear at the bottom.
Related
I would like to scroll through the contents of my JFrame up and down, preferably with a scroll bar. I don't want to wrap the contents inside a JPanel or JScrollPane, because this causes some visual glitches with my application.
Any idea on how to do this?
JScrollPane would be the easiest way; you say there are glitches, but that probably indicates a problem in your code that will still be a problem even without using a JScrollPane.
If you're absolutely set on not using a JScrollPane, you should create a JPanel using BorderLayout, add a JPanel (call it 'center') with BorderLayout.CENTER and layout set to null. Add your content within 'center', and add another JScrollBar to BorderLayout.EAST, add an AdjustmentListener to the JScrollBar. When the adjustmentListener triggers, you need to move your content (Component.setLocation(...)) that's in center to the relative y offset of the JScrollBar and call repaint on 'center'
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'm having problem with the "dock" in java panel. I have UI like
the panel has a slide bar, a button and a scroll view, i.e. the while area above, with GirdBagLayout, (I also tried BorderLayout but won't work either). below it is another panel, both panel are placed in a parent panel with GridBagLayout.
When I click the "more" button, I want to extend the height of the panel to 3*original height to let the scrollview show more stuff vertically. and of course I want the slide bar and button still at the bottom of the panel. I call resize on the panel but I got this:
it shows that the scrollview is longer than before but was cut, and the bar and button remain at the same place. and my question is how I can put the slide bar and button always at the botton of the panel and show the scrollview correctly.
well, answer to my own question:
have to set up the layout again and call revalidate() and repaint().
Designed a popup which is draggable, works as designed. Now Popup panel contains the ScrollPanel it is having vertical scroll bars, but while trying to scroll with dragging is not working
The following link gives u a window box implementation which is draggable. You can add scroll panel to it. I have tried it. It works. Have a look at it.
http://svn.clazzes.org/svn/gwt/branches/gwt-extras-0.1-branch/src/main/java/org/clazzes/gwt/extras/dialog/WindowBox.java
I have a popup menu that displays dynamically created custom JPanel objects in a JPanel in a JScrollPane. The popup menu displays recommendations to the user and the topmost element is the most relevant recommendation. I am using JPopupMenu to display the window:
JPanelTemplatePopup jptep = new JPanelTemplatePopup();
JPopupMenu popup = new JPopupMenu();
popup.add(jptep);
popup.show(this, 500, 100);
The problem is, I can't make the JScrollPane scroll to the topmost element to display it first. I have tried:
.getViewPort().setViewPosition(new
Point(0,0));
.scrollRectToVisible(firstelement.getBounds());
before and after validate()s. No matter what I do, when the window pops up, the scroll pane always stays at the same place.
I have even suspected that the operations that took place before displaying the window were ignored, so I created and called a public method from the class to make the window scroll it up after being displayed. Nothing changed.
Please help,
Emre
Yeah, well, found a workaround for this.
I have narrowed the problem down to a JEditorPane that was in the custom JPanel objects. Its contents were dynamically updated by the program. While generating the objects, I was setting JEditorPanes' contents by their setText methods. Updating the caret position by setting the text to a string forced the scroll pane to scroll below.
I just inserted this to the constructor and the problem was fixed:
DefaultCaret caret = (DefaultCaret) jEditorPaneContents.getCaret();
caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);