jscrollpane

JScrollPane words wrap

筅森魡賤 提交于 2020-01-02 06:43:08
问题 I have a problem. In the JScrollPane I use inheritor of the JPanel as viewPort. The inheritor can contain labels, radio buttons, check boxes and other elements (depending on the implementation). In the JScrollPane set HORIZONTAL_SCROLLBAR_NEVER. It is necessary that contents in the inheritor of the JPanel scrolling in the vertical and horizontal words wrap. When displaying long texts in the labels (special in html tags) there is no word wrap, despite HORIZONTAL_SCROLLBAR_NEVER. If don't use

JScrollPane words wrap

假装没事ソ 提交于 2020-01-02 06:43:02
问题 I have a problem. In the JScrollPane I use inheritor of the JPanel as viewPort. The inheritor can contain labels, radio buttons, check boxes and other elements (depending on the implementation). In the JScrollPane set HORIZONTAL_SCROLLBAR_NEVER. It is necessary that contents in the inheritor of the JPanel scrolling in the vertical and horizontal words wrap. When displaying long texts in the labels (special in html tags) there is no word wrap, despite HORIZONTAL_SCROLLBAR_NEVER. If don't use

How to auto scroll to bottom in Java Swing

感情迁移 提交于 2020-01-02 04:52:14
问题 I have a simple JPanel with a JScrollPane (with vertical scrollbar as needed) on it. Things get added to (or removed from) the JPanel and when it goes beyond the bottom of the panel, I want the JScrollPane to scroll down to the bottom automatically as needed or scroll up if some components go away from the panel. How shall I do this? I am guessing I need some kind of listener which gets called whenever the JPanel height changes? Or is there something as simple as JScrollPanel.setAutoScroll

paintComponent() is drawing on other components

独自空忆成欢 提交于 2020-01-01 12:31:12
问题 I'm using a custom class, based on the code in this answer, to draw a background shaped like a speech bubble. Whenever I resize the window of my application enough to make a component poke out at the top or bottom, the outlines of the said component is drawn outside the JScrollPane on top of other components; in this case the JPanel . In the left-side image, the border of the component at the bottom of the JScrollPane is drawn, due to the component still being visible; while in the right-side

jScrollPane 2.0 height problem in chrome

柔情痞子 提交于 2020-01-01 02:34:09
问题 I am using a div with class scroll-pane (height 100%) within an absolute positioned div. The scroll-pane div contains some text first, followed by an image and followed by some text again. The image height is set to 200px. Problem is! If I view the scrollpane in Chrome (latest Version) I sometimes can scroll the complete content and sometimes, after refreshing the site in the browser, not. Not does mean that I can only see a part of the second text and not more. So the actual scrolling height

Swing: creating a JScrollPane that displays its component centered?

寵の児 提交于 2020-01-01 02:33:44
问题 If you create a JScrollPane that has a viewport larger than the JScrollPane's component, it displays that component in the upper left. Is there any way to change this behavior so it displays the component centered? example program below. clarification : I have a component which has (width, height) = (cw,ch). I have a JScrollPane with a viewport which has (width, height) = (vw, vh). The component may become larger or smaller. I would like a way to use the scrollbars to position the component's

Making a JScrollPane automatically scroll all the way down

六月ゝ 毕业季﹏ 提交于 2019-12-31 19:20:08
问题 I am trying to implement a JScrollPane with a JTextArea. The JTextArea is being appended to, and I want the JScrollPane to keep scrolling down as more text is added. How can this be achieved? 回答1: For (what I think is) a simpler answer check out: Text Area Scrolling. Prior to JDK5, you would have to manually change the caret's position after each append. You can now give this behaviour as a default like this : JTextArea textArea = new JTextArea(); DefaultCaret caret = (DefaultCaret)textArea

JScrollPane formatting to show Pascals Triangle

依然范特西╮ 提交于 2019-12-31 06:20:15
问题 so I want to make my Jscrollpane to show Pascals triangle. I have this: labelPanel= new JPanel(); lRows = new JLabel[n]; for (int i=0;i<n;i++){ lRows[i]=new JLabel(Arrays.toString(tri.tri[i])); labelPanel.add(lRows[i]); } But it's not what I want and I am not sure how to fix that, picture included. Any help? 回答1: By default, JPanel uses a flow layout. To get the vertical arrangement you are looking for, you should be able to do this by using a BoxLayout with a vertical orientation on your

Adding JPanel to JScrollPane

谁说胖子不能爱 提交于 2019-12-31 04:02:34
问题 I have a gui which has a Panel that contains a sequence of labels and TextFields and uses a spring layout(this is the mainPanel) and another Panel that just contains a button(buttonPanel). I am trying to make my mainPanel to have a vertical scrollbar as well. I would like to implement my GUI such that within the JFrame I have 2 panels. The mainPanel appears on the top of the frame and the buttonPanel appears below the mainPanel. My problem is I am not able to make the Panels appear such that

How to add horizontal/vertical scrollbars to JScrollPane

回眸只為那壹抹淺笑 提交于 2019-12-31 02:49:11
问题 I want to add horizontal scrollbars to my JScrollPane, because my table right now looks like the one below: Here is my code to create the table: this.table = new JTable(); this.table.setShowGrid(false); this.table.getTableHeader().setFont(ReportViewConstants.TABLE_FONT); this.table.setFont(ReportViewConstants.TABLE_FONT); this.scrollPane = new JScrollPane(this.table); Dimension size = new Dimension(300, 400); this.scrollPane.setPreferredSize(size); this.scrollPane.setMinimumSize(size); this