jscrollbar

Using a JScrollPane with a JTextArea [duplicate]

岁酱吖の 提交于 2020-01-07 09:50:10
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Java Textarea ScrollPane I have code for a scrollbar to appear in a textarea but it doesnt really work. Any suggestions? final JTextArea textArea = new JTextArea(); textArea.setEditable(false); textArea.setBounds(10, 152, 456, 255); textArea.setBorder(border); textArea.setLineWrap(true); sbrText = new JScrollPane(textArea); sbrText.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); panel_1.add

MouseListener for JScrollBar arrow buttons

泄露秘密 提交于 2020-01-05 10:19:33
问题 http://s019.radikal.ru/i626/1203/ae/8420ef7757f7.png JScrollPane.getVerticalScrollBar().addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { System.out.println("mouseClicked"); } public void mousePressed(MouseEvent e) { System.out.println("mousePressed"); } public void mouseReleased(MouseEvent e) { System.out.println("mouseReleased"); } }); It works if I click on the strip, but does not work when I click on the buttons 回答1: The buttons are defined in the JScrollBar's

JScrollBar Doesn't Do Anything

。_饼干妹妹 提交于 2020-01-05 07:08:17
问题 I'm trying to put a vertical JScrollBar on top of a JPanel. I can add the scoll bar easily enough, but when I run the program, my scroll bar doesn't have any effect. I can drag it up and down, but the contents of the JPanel don't move. I've read all what I can find about how to do this, and it seems very straightforward, but I'm obviously missing something. Please note that my JPanel layout is set to NULL. Here is the relevant code. Thanks! public JDlgResults(ArrayList<AnsweredProblem>

How to change the Thumb of the JScrollbar to a custom image

浪尽此生 提交于 2020-01-04 13:25:32
问题 Say I have an appropriately sized image inside an Image() I want to change the Thumb or Knob of the JScrollBar component to be this image. I know I need to subclass the ScrollBarUI Here is where I am at right now. public class aScrollBar extends JScrollBar { public aScrollBar(Image img) { super(); this.setUI(new ScrollBarCustomUI(img)); } public class ScrollBarCustomUI extends BasicScrollBarUI { private final Image image; public ScrollBarCustomUI(Image img) { this.image = img; } @Override

How to add scrollbar in JFrame with null layout?

北城以北 提交于 2019-12-25 01:46:44
问题 I want to add a vertical scroll-bar on my JFrame with null layout. Is it possible or not? please help! 回答1: Just set the JScrollPane as ContentPane for JFrame as it is described here: public class TabbedPaneTest { public static void main(String [] a) { final JFrame frame = new JFrame(); frame.setSize(500, 500); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JScrollPane pane = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); frame

moving / scrolling up and down on three JTable simultanously.

旧时模样 提交于 2019-12-25 01:13:55
问题 I have three different jtable on three diffenernt jscrollpane - one next to the other. I successfuly written some code that makes them all scroll together when I scroll the mouse wheel. I inherrited JScrollpane and overriden its processMouseWheelEvent methos as follows: public void processMouseWheelEvent(MouseWheelEvent e) { ... if (e.getSource() == this) { for (BTSJScrollPane other : effected) { other.processMouseWheelEvent(e); } } } I have canelled the pageup pagedown using final InputMap

swing JTable with ScrollBar - color of square between headers and track

荒凉一梦 提交于 2019-12-24 00:01:02
问题 I have a JTable with BasicScrollBarUI, I set the headers background color: table.getTableHeader().setBackground(GuiConstants.backgroundColor); and the scrolbar background color: public class ScrollBarUI extends BasicScrollBarUI { @Override protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds) { c.setBackground(GuiConstants.backgroundColor); } } I still have a square between them that its color won't change. does anybody knows how to change it also to their color? thanks

JScrollBar don't show thumb in Nimbus L&F

早过忘川 提交于 2019-12-23 16:25:43
问题 I got a problem which only happens on Nimbus L&F. If there are too many items in a JList, the thumb of JScrollBar will disappear. But in metal L&F, the thumb will be always visible, because it has a min size. I have also checked the logic in Nimbus L&F, there does have a same min size. But it not effected. Please see my code below: public static void main(String[] args) { for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { try {

Java Textarea ScrollPane

一曲冷凌霜 提交于 2019-12-20 07:16:16
问题 I have created a textarea, and i need a scrollbar applied to the textarea when necessary (when the text gets too long down and it cant be read anymore). this is the code i have written, but for some reason, the scrollbar doesnt really come up? final JTextArea textArea = new JTextArea(); textArea.setEditable(false); textArea.setBounds(10, 152, 456, 255); textArea.setBorder(border); textArea.setLineWrap(true); sbrText = new JScrollPane(textArea); sbrText.setVerticalScrollBarPolicy(JScrollPane

Remove Arrows from Swing Scrollbar in JScrollPane

南楼画角 提交于 2019-12-19 09:57:08
问题 I would like to remove the scrollbar arrow buttons from a scrollbar in a JScrollPane. How would I do this? 回答1: class NoArrowScrollBarUI extends BasicScrollBarUI { protected JButton createZeroButton() { JButton button = new JButton("zero button"); Dimension zeroDim = new Dimension(0,0); button.setPreferredSize(zeroDim); button.setMinimumSize(zeroDim); button.setMaximumSize(zeroDim); return button; } @Override protected JButton createDecreaseButton(int orientation) { return createZeroButton();