jscrollpane

Add labels inside JscrollPane inside loop

我只是一个虾纸丫 提交于 2019-12-12 07:04:26
问题 I have a loop that generates some Titles and Description which are String values and I made Labels to contains theses two strings, I want to add these to a JScrollPane , but for some reason my code isn't working, I'm not getting any error now, no item is being added to the scroll pane, here's my code: package testa; import java.awt.Color; import java.awt.FlowLayout; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; public class

How to set scroll to the top - JPanel that has multiple JTextareas inside Jscrollpane

主宰稳场 提交于 2019-12-12 05:52:33
问题 I have a JPanel in a JScrollPane. The JPanel contains multiple JTextAreas vertically. I like to keep the scroll of the scrollpane to the top whenever the page is refreshed. Currently, the scroll always starts from the bottom. this is my current code and it doesn't work.. panel.invalidate(); panel.revalidate(); panel.repaint(); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { ((JPanel) panel).setLocation(new Point(0, 0)); } }); I've also tried adding this code below to

JTextArea in JScrollPane, view coordinate translation

孤街浪徒 提交于 2019-12-12 05:49:53
问题 I'm trying to translate between view and viewport coordinates. But the JViewport/JScrollpane doesn't seem to work as documented. JViewport.toViewCoordinates() thinks the view is always at the top left of the component, even though that's clearly not the case. String text = "blahblahblah\nblahblah\nblah"; JFrame frame = new JFrame("title"); JTextArea textArea = new JTextArea(text, 1, 30); // shows only one line frame.add(new JScrollPane(textArea)); frame.pack(); frame.setVisible(true);

JList with changing Height

时间秒杀一切 提交于 2019-12-12 04:57:54
问题 I got a JList, which i want to change height of depended on how many items within the JList. As seen in the picture, theres alot of components inside a JPanel, which all are alligned at the Y axis. (the JScrollPanel belongs to the JPanel, NOT the JList) I would like the JList to match its height with the amount of items. A normal JList just stops showing items if it gets too big (unless you apply a JScrollPane).. What i simply want to, is that the JList will get the right size (without hiding

Issue with addMouseMotionListener getting wrong coordinates

筅森魡賤 提交于 2019-12-12 04:46:09
问题 I borrowed the class below to make a selection area tool for a project. But it has a issue when I try to make a selection when the content is not aligned at top-left, it get my mouse coordinates related to the ScrollPane, but draws over the image - See this SS for better understanding: sscce : import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.Point; import java.awt.Rectangle; import java.awt.Robot; import java.awt

Can't see components in JScrollPane

泪湿孤枕 提交于 2019-12-12 03:59:13
问题 I'm using a JScrollPane to hold a JTextArea for a large area of text. I add the TextArea directly to the JFrame, it works fine. But I add it to the scrollpane and add the scrollpane, I don't see the textarea. Here's my SSCCE: public class foo extends JFrame{ //gui elements JTextArea chatMonitor = new JTextArea(); JScrollPane textPane = new JScrollPane(); ChatFrame(final String nickname, final String login, final String server, final String channel){ setSize(500,500); chatMonitor.setEditable

Java - Open JScrollPane with JScrollBar set to the right

╄→гoц情女王★ 提交于 2019-12-12 02:48:17
问题 I'm looking to try and load up a JScrollPane with the horizontal JScrollBar set all the way to the right, i.e. like in this image: http://i.imgur.com/VeKYPa6.png However, no matter what I do, I end up with this image: http://i.imgur.com/c9KzRqZ.png This is the relevant snippet of my code JComponent graph = new TrendsForSuccLarge(wccScores, wccScoresTimes, graphStrings, maxScore, bgColour, iPadWidth); JScrollPane graphScrollPane = new JScrollPane(graph, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED

Disappearing components in JScrollPane

耗尽温柔 提交于 2019-12-12 02:45:59
问题 I'm trying to add scroll view in my Swing-UI project. So I've got a JPanel(container) with some JPanels(cards) inside, and I want to put a container in JScrollPane: MealListPanel mlp = new MealListPanel(meals); JScrollPane scrollPane = new JScrollPane(); scrollPane.setBounds(10,50,1000,400); scrollPane.setLayout(new ScrollPaneLayout()); scrollPane.add(mlp); this.add(scrollPane); After that everything is ok, but when I try to scroll, a container disappears: Before scroll: To What am I doing

Absolute Layout Panel within JScrollPane

拜拜、爱过 提交于 2019-12-12 02:27:57
问题 I'am using panel with absolute layout (don't ask why) and I need to add elements on it programmatically. I done that part, but now I want to surround panel with JScrollPane so that when user add more items, scroll bar does its job. But surrounding panel with scroll bar doesn't work. What can I do here. JFrame frame = new JFrame(); frame.setSize(582, 451); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().setLayout(null);

jScrollPane strange behavior in Internet Explorer

孤人 提交于 2019-12-12 01:36:43
问题 I'm trying to use jScrollPane with fallowing page: http://demo.2klika.net/home.php#!pages/prodavaonice.html Well, this works as expected in all major browsers except in Internet Explorer (I tried with IE7 and IE8). On first load (same goes for every page reload), IE will show list of locations, and when you click somewhere in that list, it will jump down to the last item in list. After that it will work normally (you can click on title, eg. Mesnica 1, Mesnica 2, etc..., and script will center