jscrollpane

Dynamically create jCheckBox and add to a jScrollPane

心已入冬 提交于 2019-12-07 02:34:11
问题 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 block scrolling parent

不问归期 提交于 2019-12-07 01:53:54
问题 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. 回答1: 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: $('

Smart JScrollPane autoscrolling

家住魔仙堡 提交于 2019-12-07 00:58:50
问题 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

Writing at the bottom of JTextArea

℡╲_俬逩灬. 提交于 2019-12-06 15:56:15
I have a JScrollPane and a JTextArea (editable) with 10 rows. I want the first user input to appear at the bottom of the JTextArea and the most recent input should push the previous input upward. To achieve this I use textArea.setMargin(new Insets(x,0,0,0)); and everything works as it should - except that my second input will toggle the JScrollPane . How can I start at the bottom of the JTextArea and only enable scrolling when the entire original viewport is filled? Basically, you could add the JTextText onto a JPanel with another JPanel which acts a filler, causing the JTextArea to occupy the

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

北城以北 提交于 2019-12-06 14:43:48
问题 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

Trying to get a JTable + JScrollPane to scroll

。_饼干妹妹 提交于 2019-12-06 12:18:30
I have done the Google search and tried implementing a number of different solutions concerning the JTable and JScrollPane. The following is a self contained example of the problem I am having. I want to be able to have a horizontal scroll bar with these tables. Your assistance would be deeply appreciated: package org.examples; import java.awt.EventQueue; import java.awt.Frame; import java.awt.Rectangle; import java.util.ArrayList; import java.util.List; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.JViewport; import javax.swing

Set size of JTable in JScrollPane and in JPanel with the size of the JFrame

廉价感情. 提交于 2019-12-06 11:21:41
I want the table with the same width as the frame and also when I resize the frame the table need to be resized too. I think setSize() of JTable doesn't work correctly. Can you help me? import java.awt.Color; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.SwingUtilities; public class Main extends JFrame { public Main() { setSize(400, 600); String[] columnNames = {"A", "B", "C"}; Object[][] data = { {"Moni", "adsad", 2}, {"Jhon", "ewrewr", 4}, {"Max", "zxczxc", 6} }; JTable table = new JTable(data, columnNames)

JScrollPane setViewPosition After “Zoom”

主宰稳场 提交于 2019-12-06 10:50:37
The code that I have here is using a MouseAdapter to listen for the user to "draw" a box around the area of an image that they would like to zoom in on and calculate the ratio of the box to the image. It then resizes the image to the calculated ratio. This part works. The issue that I am having is making the JScrollPane view appear as if it is still at the same top left position after the image has been resized. I have tried several methods that seem to have gotten close to the result I want but not exactly. This is the Listener that finds the scale ratio and sets the position: import java.awt

Java JTextArea Line Numbers

非 Y 不嫁゛ 提交于 2019-12-06 07:34:22
I'm trying to add line numbers to a JTextArea and am having some difficulties. The line numbers appear, but they do not scroll properly. I have a linked-list of a custom class that stores a line of data (log message) and a line number associated with it as well as visibility on whether it should be shown in the text area or not. So what I did was create two JTextAreas... one to store the logs, and the other to store the line numbers. The layout works and the line numbers populate correctly with the logs. The problem is when I try to scroll up or down. The logs adjust properly as you scroll,

JScrollPane scroll at last added line

浪子不回头ぞ 提交于 2019-12-06 06:42:05
I have JTextArea text and JScrollPane pane=new JScrollPane(text), I put pane.setAutoScrolls(true). How to get that when I append some text to my component text that pane scrolls at the end ( last line ) ? mKorbel follows link from this thread ScrollPane scroll to bottom problem Best (and up-to-date, as far as I can tell) explanation of how caret is moved, by Rob Camick: http://tips4java.wordpress.com/2008/10/22/text-area-scrolling/ Is it possible, that you are not on the EDT? If the append does not happen on the EDT, the position of the JTextArea does not update. Short, runnable example to