jscrollpane

Line wrap in a JTextArea causes JScrollPane to missbehave with MiGLayout

心不动则不痛 提交于 2019-12-03 08:04:40
I am having trouble with the same thing as this guy: MigLayout JTextArea is not shrinking when used with linewrap=true and I used the solution described in one of the answers; to set the minimum size explicitly. This works fine if one places the JPanel which contains the JTextArea directly in a JFrame, and then resizes the window. However, when placing the panel which contains the JTextArea inside a JScrollPane, the same problem occurs again. Why is this, and how can one fix it? Cheers EDIT: An example public class MiGTest2 extends JFrame{ public MiGTest2(){ setDefaultCloseOperation(JFrame

How can I create a JTable where the first column is always in the JScrollPane viewport?

邮差的信 提交于 2019-12-03 07:24:12
What's the best way to set up a table in a JScrollPane such that the first column is always on the screen in the same position regardless of horizontal scrolling and overlaps columns that pass underneath? When the scrollbar is at the farthest left, the columns look normal, but as the user scrolls to the right, the secondary columns (2 and on) move underneath the first until the last column appears on the far right of the viewport? I found a sample taken from Eckstein's "Java Swing" book that sort of does this, but it doesn't allow resizing of the first column. I was thinking of some scheme

jScrollPane 2.0 height problem in chrome

橙三吉。 提交于 2019-12-03 06:11:13
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 shrinks. If I refresh again I might be able to see it all complete again and so on. It changes every

Swing: creating a JScrollPane that displays its component centered?

人盡茶涼 提交于 2019-12-03 06:01:43
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 centerpoint relative to the viewport's center point, so if the one or both of the component's

Horizontal scrollbar is not working with JTable in Java Swing

那年仲夏 提交于 2019-12-03 05:02:01
I have a JTable which I am passing in JScrollPane . The vertical scrollbar is showing up and working good, but the horizontal scrollbar is not working. The code I provided is compilable, just put your path in InputFile1 string and create a long file on that location. I have tried many solutions but nothing is working. I have a table with only one column, that column contains lines from a document. I need both vertical and horizontal scrollbars. Please suggest some solution. Other attempts: Case1 : tab.setPreferredSize(new Dimension(400,400)); If I am setting this ,vertical scrollbar doesn't

How to get rid of the border with a JTable / JScrollPane

大憨熊 提交于 2019-12-03 04:15:13
If you run the small sample below you'll see a border around the center region. I'm not sure why this border is showing. It happens when a JTable is in a JScrollPane. I tried various things to remove it but so far no luck. A JTable without the JScrollPane shows no border. See sample below. TIA. public class TestScrollPane extends JFrame { public static void main(String[] args) { JFrame frame = new TestScrollPane(); JPanel panel = new JPanel(); JTable table = new JTable(); panel.setLayout(new BorderLayout()); panel.add(new JLabel("NORTH"), BorderLayout.NORTH); panel.add(new JLabel("SOUTH"),

Making a JScrollPane automatically scroll all the way down

拜拜、爱过 提交于 2019-12-03 02:49:30
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? camickr 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.getCaret(); caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); The advantage of this is that you don

Zoomable JScrollPane - setViewPosition fails to update

廉价感情. 提交于 2019-12-03 00:24:27
I'm trying to code a zoom-able image in a JScrollPane. When the image is fully zoomed out it should be centered horizontally and vertically. When both scroll bars have appeared the zooming should always happen relative to the mouse coordinate, i.e. the same point of the image should be under the mouse before and after the zoom event. I have almost achieves my goal. Unfortunately the "scrollPane.getViewport().setViewPosition()" method sometimes fails to update the view position correctly. Calling the method twice (hack!) overcomes the issue in most cases, but the view still flickers. I have no

Can't see components in JScrollPane

坚强是说给别人听的谎言 提交于 2019-12-02 19:47:43
问题 I'm using a JScrollPane to hold a JTextArea for a large area of text. I add the TextArea directly to the JFrame, it works fine. But I add it to the scrollpane and add the scrollpane, I don't see the textarea. Here's my SSCCE: public class foo extends JFrame{ //gui elements JTextArea chatMonitor = new JTextArea(); JScrollPane textPane = new JScrollPane(); ChatFrame(final String nickname, final String login, final String server, final String channel){ setSize(500,500); chatMonitor.setEditable

JTable in JScrollPane fixed size with resizeable JFrame?

六月ゝ 毕业季﹏ 提交于 2019-12-02 17:15:01
问题 I have a JTable inside of a JScrollPane . I want to get the columns to stay fixed when I resize it. The rows stay the same size, and there is a scrollbar to move up and down. I can't get the scrollbar to work the same way on the vertical though. Here is a picture of my project, where the y axis of Duke is perfectly normal, and has a scrollbar to scroll to the bottom of the image, the horizontal part is clearly messed up, and should not have expanded that far. Also, if the frame was made