jscrollpane

JScrollPane vertical scrollbar too wide

房东的猫 提交于 2019-12-10 23:56:07
问题 I'm using Netbeans GUI Builder to create a GUI app (so all the code generated is by Netbeans). Everything looks fine in the Preview Design, but when I run the app, the JScrollPane displays badly... ...as you can see, only half of the scrollbar is visible. I have tried manually setting the JScrollBar for the JScrollPane, using my own method: jScrollPane1.setVerticalScrollBar(getScrollBarForScrollPane()); But that gives this result... Maybe there is some property on the JScrollBar or

jQuery jScrollpane's scrollToElement

我与影子孤独终老i 提交于 2019-12-10 23:38:07
问题 I'm looking to use jScrollPane's "scrollToElement" API function here: http://dextersgospel.com/index-test.html Instructions on it's usage can be found here: http://jscrollpane.kelvinluck.com/api.html#scrollTo The issue I'm having is with the "stickToTop" argument. When clicking the arrows, I want it to bring the targeted div to the top of the viewport (not just barely visible as it's currently doing). The "stickToTop" argument is supposed to be handling this, but I can't get it to work. I've

How do I save my JScrollPane position after I do a JFrame.pack()?

梦想与她 提交于 2019-12-10 21:46:43
问题 I have the following code: JFrame frame = new JFrame(); JScrollPane scrollPane = new JScrollPane(new panel(with stuff in it)); frame.getContentPane().add(scrollPane); So the user scrolls a bit and then clicks a link on my panel and then I do a pack(), so I try the following code: int val = scrollPane.getVerticalScrollBar().getValue(); frame.pack(); scrollPane.getVerticalScrollBar().setValue(val); But this code still returns my scrollBar back to the beginning instead of keeping the position it

Add a JScrollPane to a JLabel

半城伤御伤魂 提交于 2019-12-10 21:01:12
问题 I can't seem to find out how I can add a JScrollPane to a JLabel . The JLabel that I'm using is populated with a long formatted HTML string. Please help. area = new JLabel(); JScrollPane scroller = new JScrollPane(area, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); panel.add(scroller); 回答1: Really not good idea to hold or display long Html formatted text in the JLabel, since is possible, better would be use JEditorPanes / JTextPanes, these JComponets support

How to scroll two or more JTables with a single Scrollbar?

…衆ロ難τιáo~ 提交于 2019-12-10 20:29:42
问题 How can I use one scroll from one JScrollPane to move another or more than one JScrollPane ? In example: I have three JTable s in separate JScrollPane s. I want to bind the scrollpanes to each other. If I'll use one - the another will scroll the same way. Some kind of Listener s which i can't find? Any sugestions? Best regards. 回答1: An approach that preserves the JTables ' headers would be to use the same BoundedRangeModel for each JScrollPane 's vertical scrollbar and add each ScrollPane to

Adding JScrollPane in JTextArea using GridBagLayout

久未见 提交于 2019-12-10 18:38:15
问题 I'm having an issue adding JScrollPane in JTextArea using GridBagLayout. Basically the program runs fine when the scrollbar isn't needed but the layout gets messed up and the content gets cut off when it is. The relevent code is as follows import java.io.*; import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.util.*; public class testGUI extends JFrame { public static String name; static JTextField textfield = new JTextField(30); static JTextArea textarea = new

Layout for displaying panels dynamically with scroll bar

风格不统一 提交于 2019-12-10 18:32:58
问题 In java, I have been trying to create a panel that can accept other panels with a scroll bar. I tried using gridlayout, and this works fine, except for the fact that if I only add a few panels, it grows those panels to fit the size of the parent panel. I tried using flowlayout, but this makes the panels flow horizontally as there is a scroll bar. How do I make it so I can add panels to the parent panel starting at the top and make them always the same size(or their preferred size). Also, when

synchronize scrolling of N number of jtables in java swing

孤人 提交于 2019-12-10 18:17:56
问题 I have a requirement of having N number of tables arranged in a grid pane side by side provided height of the scrollpanes of all the jtables remains same. Now i want to synchronize scroll of all the jtables means if i scroll the first jtable then rest of the jtables should scroll automatically by the same amount. Anyone has any idea about this ? 回答1: Try sharing the model of the scrollbar. Something like: JScrollPane scrollPane1 = new JScrollPane(...); JScrollPane scrollPane2 = new

FlowLayout not flowing with JScrollPane around it

浪尽此生 提交于 2019-12-10 17:56:40
问题 I have a bunch of buttons on a JPanel using a FlowLayout. It looks really nice. When the buttons reach the right side of the panel they start out on a new row creating a nice 2-dimensional grid. Here is the code: Container cp = getContentPane(); JPanel panel = new JPanel(); panel.setLayout(new FlowLayout()); for (int i = 0; i < 20; i++) panel.add(new JButton("Button " + i)); cp.add(panel); However, the minute I put the panel in a scroll pane with only vertical scrolling: Container cp =

JScrollPane- Only Vertical Scroll?

﹥>﹥吖頭↗ 提交于 2019-12-10 17:47:03
问题 I have the following line of code: JSplitPane VPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,(new class1()),new JScrollPane(new class2())); I'd like class2 to ONLY have vertical scrolling please? Since my layout falls to bits otherwise. I am using GridBagLayout and it's too late to change the layout now. Is there a method to fix this? 回答1: +1 to trashgods comment. It doesn't seem to work- I'm just getting errors =[ To illustrate this: JScrollPane js=...; //Create a variable reference to the