jlist

JList does not populates after search button clicked

此生再无相见时 提交于 2019-12-12 01:25:28
问题 I've written a recursive search method in java GUI application to find a file in a drive. UI is responsive, Search happened successfully but JList does not populate,whereas console prints file names successfully, after 3 clicks on search button files are added in JList but with repeated names of each file //nullpointerexception java.util.concurrent.ExecutionException: java.lang.NullPointerException at java.util.concurrent.FutureTask.report(FutureTask.java:122) at java.util.concurrent

SortedListModel and JList Numerical Sort

我与影子孤独终老i 提交于 2019-12-12 01:20:47
问题 I have two JLists to move items back and forth between. I add items with a number value in front so example. 1. A 2. B 3. C ... 10. j The problem is that the list currently sorts as 1. 10. 2. 3., the 10. comes right after the one and isn't the last item as it should be by numerical sort. Can someone shed some light on this or help me fix this please? Thank you! import java.awt.*; import java.awt.List; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.*;

java jlist - AbstractListModel - fireContentsChanged does not work properly

自古美人都是妖i 提交于 2019-12-12 00:49:26
问题 I have a simple ListModel , that is filterable and is used in a JList ... It uses the following code... public class FilteredListModel extends AbstractListModel { private List<LineData> data = null; private final ArrayList<Integer> indices = new ArrayList<Integer>(); public FilteredListModel() { } public void setData(List<LineData> data) { this.data = data; doFilter(); } public void doFilter() { int oldSize = indices.size(); indices.clear(); if (data != null) { int count = data.size(); for

Converting string array to list: double brackets

喜你入骨 提交于 2019-12-12 00:34:23
问题 I use this part of the code to get the select items from a jlist into a string list. I get the following result: [[String1, String2, String3,...]] How can I avoid the double []? Thanks static List<String> strlist = new ArrayList<String>(); public class tog { List<String> strlisttemp = new ArrayList<String>(); final JList list = new JList(strlisttemp.toArray()); list.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); final ListSelectionListener listSelectionListener = new

Chat program freezes JFrame

旧城冷巷雨未停 提交于 2019-12-11 20:33:59
问题 I'm writing a simply chat client and am moving it over to a nice GUI. The constructor for the server side (client side is android) contains a list that's in the JFrame, and the first part of the server runs, but then the entire frame locks up. Does anyone see the issue? Sorry for the relatively disorganized, not cleanly commented code... Server: import java.awt.List; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import

method getSelectionIndex() in ListSelectionListener

寵の児 提交于 2019-12-11 18:23:21
问题 For example, I have a JList named across_list that containing a list of items and now I add a ListSelectionListener to that JList Considering these lines of code: class AcrossListHandler implements ListSelectionListener { @Override public void valueChanged(ListSelectionEvent e) { JList lsm = (JList) e.getSource(); int selected_index = lsm.getMaxSelectionIndex(); if (selected_index >= 0){ System.out.println(selected_index); } } } } I have a question that: Why the line "System.out.println()"

How to get selected elements of panels in JList (overlay selected elements)

笑着哭i 提交于 2019-12-11 16:59:12
问题 I have a JList of ChartPanel s. When I'm trying to select elements I can't visually see what elements of the list actually are selected. On a program level listeners are working properly. How to get visually selected my chart panels of the list? Or how to overlay these elements with opacity color? Desired result: Here is the code based on this example: import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; import java.awt.Dimension; import java.awt.EventQueue; import

Updating JList Components

妖精的绣舞 提交于 2019-12-11 13:17:18
问题 I have a JProgressBar on a JPanel as a JList components.The JList components are supposed to update the JProgressBar in every two seconds.But the problem is, I don't know how to pass the value of progress into the JProgressBar. here is my code import java.awt.*; import java.awt.event.*; import javax.swing.*; class download { download(){} } class myPanelListCellRenderer extends DefaultListCellRenderer{ private static final long serialVersionUID = 1L; private JPanel downloadPanel,labelStack;

JList update freezes display but not JFrame setTitle

情到浓时终转凉″ 提交于 2019-12-11 10:17:48
问题 If I update a JList with a long number of html formatted items then the controls stop responding and indicators won't update. This makes sense, the event thread is busy. The title can still be set though. Why is this? Here's some (long) code demonstrating this: import java.awt.*; import java.awt.event.*; import java.lang.reflect.InvocationTargetException; import java.util.Timer; import java.util.TimerTask; import javax.swing.*; public class JListTest extends JFrame { class TestListModel

JList with toggable group headers

戏子无情 提交于 2019-12-11 10:06:45
问题 Is it possible to do something like the following image in Java? I understand that I would need to be using a multi columned list, with a custom cell renderer, in order to show the images of each list element. But my question is regards to Grouping the list elements, and using group headers... As you can see from the image above this comes from windows explorer and is exactly the type of grouped list view that I would be looking to do with a JList in Java. 回答1: I don't think I would use a