jscrollpane

JScrollPane does not appear when using it on a JPanel

旧城冷巷雨未停 提交于 2019-12-05 11:15:22
I have been trying for hours to find a way to solve the issue, but I had no luck with that. Here is a sample code: import java.awt.BorderLayout; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.SwingUtilities; public class Example extends JFrame { private static final long serialVersionUID = 1L; public Example() { JPanel contentPane = (JPanel) getContentPane(); contentPane.setLayout(new BorderLayout()); JPanel panTop = new JPanel(new BorderLayout()); //JPanel panBottom = new JPanel

How to auto scroll to bottom in Java Swing

社会主义新天地 提交于 2019-12-05 10:54:31
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(true) ? camickr When you add/remove components for a panel you should invoke revalidate() on the panel to

JEditorPane inside JScrollPane not resizing as needed

杀马特。学长 韩版系。学妹 提交于 2019-12-05 10:26:30
I am implementing a Comment box facility in my application which user can resize using mouse. This comment box contains a scrollpane which instead contains a JEditorPane in which user can insert comment. I have added the editor pane inside a scroll pane for the following reason: auto scolling of jeditorpane When the user resizes the comment box, I am setting the desired size for JScrollPane and the JEditorPane . When the user is increasing the size of the comment box, the size of these components are increasing as desired but when the size of the comment box is decreased, the size of the

Get shown component in JScrollPane

南楼画角 提交于 2019-12-05 10:13:57
I have a JScrollPane containing a JPanel. I fill this JPanel with many buttons. Is there any possibility to get the currently shown buttons? I know I can access the children of a JPanel via jpanel.getComponents() but those are all components in this pane; I want only the ones that are currently on screen. I assume that this container is already visible on the screen, then I suggest 1) to extract JViewPort from JScrollPane , 2) addChangeListener to JViewPort 3) each visible JComponent(s) returns Rectangle 4) and Rectangle#intersects returns Boolean value if is JComponent(s) visible or not in

Dynamically adding JTable to JScrollPane

非 Y 不嫁゛ 提交于 2019-12-05 09:45:16
I have a table that I want to populate when the user prompts me to do so. Problem is, I can't anticipate how many rows the table will end up having. In the constructor for my panel where the table will be displayed I have // add empty scrollPane to JPanel which will later hold table scrollPane = new JScrollPane(); add(scrollPane); This class contains a method that will be called when I want to finally display the table public void displayTable(String[] columnNames, String[][] dataValues) { table = new JTable(dataValues, columnNames); table.setPreferredScrollableViewportSize(new Dimension(300,

jscrollpane block scrolling parent

馋奶兔 提交于 2019-12-05 08:39:13
Can i make jscrollpne such that parent pane doesnot scroll even when child scroll has reached its bottom. Now when child scrolling reaches bottom scrolling of parent occurs. I want parent to scroll only when mouse is out of child scrollpane. The behaviour you describe is by design. This is how the native browser scrollbars behave on an element which has overflow: auto. I wouldn't recommend changing it. However, if you wish to then Borgenk's answer is correct, you can use this code: $('.scroll-pane') .jScrollPane() .bind( 'mousewheel', function(e) { e.preventDefault(); } ); See an example here

Dynamically create jCheckBox and add to a jScrollPane

爱⌒轻易说出口 提交于 2019-12-05 08:06:47
EDIT: Using the solutions presented below, I have changed the code to have a JPanel inside a JScrollPane. Using a JButton i add JCheckBoxes to the JPanel inside the JScrollPane. This was one problem solved, as the a JScrollPanecan only take one JComponent. The rest of the issues were solved setting a gridlayout to the JPanel inside JScrollPane. I have kept my original question here for the sake of posterity: ORIGINAL QUESTION: I'm trying to dynamically create JCheckBox and add them to a JScrollPane, but alas i am achieving little success. I have reduced this to a single proof-of-concept

Smart JScrollPane autoscrolling

▼魔方 西西 提交于 2019-12-05 07:07:26
I am attempting to implmement smart autoscrolling on a JScrollPane containing a JTextPane. The JTextPane is used for logging my app in color. However I'm running into a wall trying to do smart autoscrolling. By smart autoscrolling I don't mean blindly autoscrolling every time something changes, I mean checking to see if your scrolled all the way down, then autoscroll. However no matter what I do it either always autoscrolls or doesn't at all As a test script, here's the setup (the JFrame has been left out) final JTextPane textPane = new JTextPane(); textPane.setEditable(false); final

How to disable scrolling from mouse wheel in a JScrollPane header?

时光怂恿深爱的人放手 提交于 2019-12-04 19:56:09
I am currently working on a SWING frame with a JScrollPane (including a JComponent), with a row header and a column header (which are also JComponents). When the mouse is over the JComponent or one of these 2 headers, mouse wheel provokes scrolling. What I want to do is to disable this scrolling when the mouse is over the column header , but I can't find a direct way nor in JScrollPane instance, nor in JComponent. For information, I had a look at these sources : Sun's Howto on JScrollPane JScrollPane javadoc JComponent javadoc Thank you in advance if you have a way to do that. I think you need

Jscroll is not working in chrome and safari

血红的双手。 提交于 2019-12-04 19:42:00
I tried teh jScroll plugin by Kelvin Luck. First of all its a wonderful script. Its working fine with text, ie text as contents, in all browesers. But when we insert images in that the scroll is not working in Safari and Chrome... please help me. Am a beginner in javascrpt...:) Retheesh Another way of doing it is to initialise the plugin once the entire page is loaded $(window).load(function(){ $('.scroll-pane').jScrollPane(); }) Ok, this way late, but I just spent most of the day figuring this out. It's actually quite simple and also sort of explained in the jScrollpane Demo pages... Since I