jscrollpane

How to know if a JScrollBar has reached the bottom of the JScrollPane?

情到浓时终转凉″ 提交于 2019-12-01 18:28:45
I'd like to know if there is a way to know when a JScrollBar (vertical in my case) has reached the bottom of his containing JScrollPane . At first i have though of using an AdjustmentListener on the scroll bar but i don't know how to interpret the value attribute of the JScrollBar . Also i'm not sure to properly understand what the maximum represents and if i can use with the value to get the information i need. Edit : scrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() { @Override public void adjustmentValueChanged(AdjustmentEvent ae) { System.out.println("Value:

How to know if a JScrollBar has reached the bottom of the JScrollPane?

。_饼干妹妹 提交于 2019-12-01 17:56:08
问题 I'd like to know if there is a way to know when a JScrollBar (vertical in my case) has reached the bottom of his containing JScrollPane . At first i have though of using an AdjustmentListener on the scroll bar but i don't know how to interpret the value attribute of the JScrollBar . Also i'm not sure to properly understand what the maximum represents and if i can use with the value to get the information i need. Edit : scrollPane.getVerticalScrollBar().addAdjustmentListener(new

JScrollPane is not added to JTextArea

这一生的挚爱 提交于 2019-12-01 14:50:34
I saw a few questions like this question, but I couldn't get this solved. I cannot get a JScrollPane visible on JTextArea . Can anyone please point out where I have done my mistake? Thanks. package experiement; import java.awt.Dimension; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTextArea; public class Experiment extends JFrame{ public Experiment(){ JTextArea tarea=new JTextArea(); tarea.setBounds(100,100,200,200); JScrollPane pan= new JScrollPane(); pan.setPreferredSize(new Dimension(100,100)); pan=new JScrollPane(tarea,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS

How to prevent JScrollPane arrow key handling from moving caret when Scroll Pane wraps Text Pane

核能气质少年 提交于 2019-12-01 14:12:13
I have the following requirements: I need a scrollable JTextPane. The user may type into this text pane, or text may be inserted into it that is not typed by the user. Think something like an IM window. Although the window must be scrollable to allow the user to review text previously typed, the caret should never move from its position at the end of the text. Any text entered by the user will always appear at the end. In JTextPane, when the user scrolls with the scroll bar, the caret does not move. The viewport is adjusted. However, when the user presses the up and down arrow keys, the

I need to make my JPanel resize dynamically as new components are being added to it

不问归期 提交于 2019-12-01 13:03:39
I need to let users add more text fields to my JFrame so once the size of the frame has exceeded its original value a scroll pane would step in. Since I cannot add JScrollPane to JFrame in order to enable scrolling I decided to put the JPanel on the JFrame and pass the JPanel object into the JScrollPane constructor. Scrolling now works fine but only until it has reached the borders of the JPanel. The thing is the size of JPanel stays as is and is not stretching dynamically. What happens is the buttons in my code are using up all the space of the JPanel being the size of 300x300 but what I want

I need to make my JPanel resize dynamically as new components are being added to it

独自空忆成欢 提交于 2019-12-01 11:18:40
问题 I need to let users add more text fields to my JFrame so once the size of the frame has exceeded its original value a scroll pane would step in. Since I cannot add JScrollPane to JFrame in order to enable scrolling I decided to put the JPanel on the JFrame and pass the JPanel object into the JScrollPane constructor. Scrolling now works fine but only until it has reached the borders of the JPanel. The thing is the size of JPanel stays as is and is not stretching dynamically. What happens is

JScrollPane in JScrollPane

馋奶兔 提交于 2019-12-01 10:44:02
I have a JScrollPane , which has a JPanel for its content pane. To that JPanel I add smaller JPanel s, and as expected, if I add too much JPanel , a vertical scrollbar will appear. The problem is, that my small JPanel s contains a JScrollPane too for a JEditorPane . I'd like to use the mouse wheel only for the outer scrollpane, not for the smaller scrollpane. I already set wheelScrollingEnabled() to false for the small scrollpane, but if I scroll in any direction, and the mouse gets over the JEditorPane , the scrolling doesn't work anymore. Any advice? You may try to forward the wheel events

java scrollpane with flowlayout

不羁的心 提交于 2019-12-01 10:41:59
问题 For some reason, I cannot this working. It should be simple really. I've having a JFrame with a BorderLayout , which contains a JPanel (SOUTH) and a (CENTER) JPanel (itemPanel). itemPanel should be wrapped in a scrollpane. Its width = x, and all of its children shares its length, so it basically works like a table with only 1 column. For some reason, I cannot get the scrollpane to show the scrollbars (and scroll). In the JFrame: setPreferredSize(dimension); setDefaultCloseOperation(EXIT_ON

JScrollPane in JScrollPane

旧街凉风 提交于 2019-12-01 09:59:17
问题 I have a JScrollPane , which has a JPanel for its content pane. To that JPanel I add smaller JPanel s, and as expected, if I add too much JPanel , a vertical scrollbar will appear. The problem is, that my small JPanel s contains a JScrollPane too for a JEditorPane . I'd like to use the mouse wheel only for the outer scrollpane, not for the smaller scrollpane. I already set wheelScrollingEnabled() to false for the small scrollpane, but if I scroll in any direction, and the mouse gets over the

Column-oriented Layout for Component in JScrollPane

為{幸葍}努か 提交于 2019-12-01 09:41:38
问题 I'm working on my first Swing application and I'm having a layout problem concerning a dialog window I created for my users to enter values in certain fields. Because the number of fields displayed varies based on a user choice, I use a JScrollPane in my dialog, setting its viewport to a panel to which I add my field components. For every field to be displayed, I create and add three components: "field name" label Field component (usually a JTextField, but it also could be a JComboBox or a