jlist

Displaying large amount of data with JList?

蓝咒 提交于 2020-01-21 22:09:33
问题 I have a JList, wich must display more than 3000 items. I wish to have "visible" around 100 items in the list, and when you scroll and getting close to the end (or begining) of the "visible" items the next portion (around 50) must be loaded in the list. Is there any simple way of doing this? 回答1: no there are no simple way for that, you have to implements Pagination(s) easiest job when is managed by Databases engine, most of then support paginations directly in the Model, but I never seen

Displaying large amount of data with JList?

北战南征 提交于 2020-01-21 22:09:10
问题 I have a JList, wich must display more than 3000 items. I wish to have "visible" around 100 items in the list, and when you scroll and getting close to the end (or begining) of the "visible" items the next portion (around 50) must be loaded in the list. Is there any simple way of doing this? 回答1: no there are no simple way for that, you have to implements Pagination(s) easiest job when is managed by Databases engine, most of then support paginations directly in the Model, but I never seen

Custom ListCellRenderer will not change background color

*爱你&永不变心* 提交于 2020-01-21 05:17:08
问题 I have this class: @SuppressWarnings("serial") private class DataCellRenderer extends JLabel implements ListCellRenderer { public DataCellRenderer() { setHorizontalAlignment(SwingConstants.RIGHT); } @Override public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { if(isSelected) setBackground(Color.red); setText(" " + value.toString()); return this; } } The problem is that my Background will not turn red when I select a

Components in JList are Hidden by White Square Thing Until Clicked

痞子三分冷 提交于 2020-01-16 16:50:24
问题 In a project I've been working on, I noticed that all the JList items in my JScrollPane are hidden until the JScrollPane/JList has been clicked. The weird part is it's not completely covered. There's this white box with a transparent border that spreads out over the whole thing, covering all but a few pixels on all edges. Pictures: As you can see, there is this white block in the middle - notice the pink "border": Now, once I click that white box, it goes away: I know the magenta looks

Populate JList with threads

纵饮孤独 提交于 2020-01-16 01:12:12
问题 I want JList to be populated with multiple threads. I tried this way but jlist is empty. It would be good if jlist was updated on the fly There are two threads, the other one loads in anouther direction new Thread(new Runnable() { @Override public void run() { for(i=0; i<cells.size()/2; i++){ System.out.println("thread"); try{ HtmlPage p = client.getPage("https://tbilisi.embassytools.com/en/slotsReserve?slot="+cells.get(i).getAttribute("data-slotid")); pages.add(p); if(!p.getUrl().toString()

Displaying an ImageIcon in a JList that uses a different Object to load the JList data

夙愿已清 提交于 2020-01-15 12:16:06
问题 I have a JList that is being populated through an ArrayList of strings somewhere else, i want to for the same list now display an ImageIcon saved in my directory somewhere. For now i want to display the same icon for any item added to the list (or any items currently in the list). My list should look like this : ICON STUDENT NAME ... ICON STUDENT NAME The problem (The image icon shows the correct height and it is being captured but does not show in the list at run-time Here is my action

Java Swing: JList with ListCellRenderer selected item different height

房东的猫 提交于 2020-01-10 00:00:31
问题 I'm making a custom ListCellRenderer. I know that you can have different dimensions for each individual cell. But now I want to have a different dimension for the selected cell. Somehow, the JList is caching the dimension for each individual cell the first time it has to calculate bounds for each cell. This is my code: public class Test { static class Oh extends JPanel { public Oh() { setPreferredSize(new Dimension(100, 20)); } protected void paintComponent(Graphics g) { super.paintComponent

Java JList and list problems

旧时模样 提交于 2020-01-07 06:07:58
问题 I added list items to JList numbersList.add("first example"); numbersList.add("second example"); numbersList.add("third example"); and when I add new text or number to field it would would be added into list and showed at JList. Here my code, I just want to make that when I push button new element appear at JList fullList from list numberList which has been added from textfield numberTxtFld . p.s i have removed some unnecessary code. package average; import java.awt.Color; import java.awt

Java JList and list problems

蹲街弑〆低调 提交于 2020-01-07 06:06:48
问题 I added list items to JList numbersList.add("first example"); numbersList.add("second example"); numbersList.add("third example"); and when I add new text or number to field it would would be added into list and showed at JList. Here my code, I just want to make that when I push button new element appear at JList fullList from list numberList which has been added from textfield numberTxtFld . p.s i have removed some unnecessary code. package average; import java.awt.Color; import java.awt

Multi-colored lists

一笑奈何 提交于 2020-01-06 03:12:12
问题 I have to create 5 Jlists in succession to make their backgrounds look in different colors. My existing code creates these 5 lists without the colors (the default JList). I understand that I can only customize the inside/border of a jlist and not the margin/padding around it? Or Am I wrong and is there a way to it? Btw, The space above the list is a Jlabel (not shown in the pic above) and the layout managers in use are GroupLayout and GridBagLayout. UPDATE AT, as per your suggestion, here is