jscrollpane

Swing: Scroll to bottom of JScrollPane, conditional on current viewport location

扶醉桌前 提交于 2019-11-29 18:51:18
问题 I am attempting to mimic the functionality of Adium and most other chat clients I've seen, wherein the scrollbars advance to the bottom when new messages come in, but only if you're already there. In other words, if you've scrolled a few lines up and are reading, when a new message comes in it won't jump your position to the bottom of the screen; that would be annoying. But if you're scrolled to the bottom, the program rightly assumes that you want to see the most recent messages at all times

How to make JScrollPane (In BorderLayout, containing JPanel) smoothly autoscroll

故事扮演 提交于 2019-11-29 17:41:33
I'm trying to have a JPanel of varying size (potentially much wider than the standard screen) inside of a JScrollPanel. Currently it works out great, and I have configured the scrollbars to work fine manually, however I would like the JPanel to "scroll" constantly to the left, so that over time the whole thing is displayed. All of the answers I found are specific to JTextArea and use Carets, or use rectToVisible. Neither of these will work because I'm trying to scroll internally to a single JPanel. I've included what I believe to be all of the relevant code below. center is the JPanel (of

How to make JTextPane scroll horizontally

只愿长相守 提交于 2019-11-29 17:38:29
I have a JTextPane , when there are too many lines, a vertical scroll bar appears, but when a line is too long, instead of appearing a horizontal scroll bar, the line breaks into two lines, how to make the horizontal bar appear instead of breaking into two lines, my jTextPane is added like this: JScrollPane jScrollPane1 = new JScrollPane(); jScrollPane1.setViewportView(jTextPane1); As presented here by our very own Rob Camick, you could try using something like... JTextPane tp = new JTextPane() { @Override public boolean getScrollableTracksViewportWidth() { return getUI().getPreferredSize(this

How to create a Piano using JScrollPane and JLayeredPane

佐手、 提交于 2019-11-29 17:10:44
I need to create a virtual piano containing four octaves using JLayeredPane inside a JScrollPane such that one octave is shown initially, and can be scrolled horizontally to see the other octaves. My code displays only one octave and does not show the scrollbar and the other octaves. What is the problem with the following code? class PianoLayout extends JScrollPane { public PianoLayout() { initComponents(); } private void initComponents() { JLayeredPane layer = new JLayeredPane(); //ScrollableLayeredPane layer = new ScrollableLayeredPane(); layer.setSize(1120,150); JButton[] keys = new JButton

I can't get my JTable to show anything

落花浮王杯 提交于 2019-11-29 16:48:23
I cant get my gui to show the Jtable, why i dont know and i dont get any error and when i print something to the screen i get 9 colum. so i get data. but what i'm doing wrong i have no idea about that. My GUIOdreHandler looks like this public GUIOrdreHandler(){ KaldSQL ks = new KaldSQL(); ResultSet rs; } public static DefaultTableModel buildTableModel(ResultSet rs) throws SQLException { java.sql.ResultSetMetaData metaData = rs.getMetaData(); // names of columns Vector<String> columnNames = new Vector<String>(); int columnCount = metaData.getColumnCount(); for (int column = 1; column <=

Why is my table not visible when it's in a JScrollPane?

南笙酒味 提交于 2019-11-29 16:05:16
I've been trying for hours, different things and searching everywhere for a solution, but I can not get my table in addScoreCardUpper() to show up. I get an horizontal scrollbar, but no content, just 2 pixels worth of border. import java.awt.BorderLayout; import java.awt.event.*; import javax.swing.*; import javax.swing.table.*; public class YahtzeeGUI extends JFrame{ /** * */ private static final long serialVersionUID = 3255683022699487295L; private JFrame frame; private JPanel panel; private JPanel dicePanel; private JScrollPane scrollPane; private JButton btnRoll; private JButton[] btnDice

Simple way of creating an animated JScrollPane in Java?

爷,独闯天下 提交于 2019-11-29 15:46:34
I currently have a JScrollPane that holds what is basically a list of items. This JScrollPane is to be displayed on an information screen. What I'm looking for is some way of making it automatically scroll to the bottom of the list at a given interval, then back to the top. I recognise this is probably not achievable using a JScrollPane, so any suggestions for alternatives would also be great! Normally I would use the TimingFramework or you could use something like Trident or the Unviversal Tween Engine as a bases for any animation. The main reason is, apart from doing most of the work for you

JTable horizontal scrollbar based on width of one column

南笙酒味 提交于 2019-11-29 15:36:50
I am running into a problem that has been discussed on here before: getting a JScrollPane containing a JTable to display the horizontal scrollbar as I desire. HERE is a post I tried following, but for some reason it does not seem to work with my situation (I think it is because I've set one of my columns to have a fixed width. Here is a SSCCE: import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.table.DefaultTableModel; @SuppressWarnings("serial") public class TableScrollTest extends JFrame { public TableScrollTest() { DefaultTableModel model

How does one make a component in the .CENTER of a Borderlayout occupy all center space and resize with the app?

倾然丶 夕夏残阳落幕 提交于 2019-11-29 15:09:46
My app/JFrame, using Borderlayout, has a toolbar at the top or north, a statusbar at the bottom or south and a JPanel.JTabbedPane.JScrollPane.JTable in the center. The JPanel is always a fixed size which is roughly adjustable using the various set*Size() methods applied in various combinations to the various components. But it's always a fixed size and always has east and west gaps. The north and south components stay fixed height and resize horizontally as one would expect. Surely this is not a new or unique design. Is this normal behaviour? Is there some trick I've missed? This is

Java JTable Column headers not showing

情到浓时终转凉″ 提交于 2019-11-29 14:39:29
Hi guys was hoping you could help me out here, my code (Logic-wise) is all good the only problem is that the column headers do not show up in the 2 tables (table and tableS, one for teacher and one for student details) how do i make them show? import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.io.*; import java.util.*; public class Display { ArrayList<Student> stud1 = new ArrayList<Student>(); ArrayList<SubjectTeacher> sTeach1 = new ArrayList<SubjectTeacher>(); //For Display Teachers private JTable table; private JFrame f; private int i; //For DisplayStudents private