defaultlistmodel

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()

display list using DefaultListModel and JList

a 夏天 提交于 2019-12-24 09:37:26
问题 I am trying to display a list of items using DefaultListModel and JList but my window is empty. What is the error? see code: public class ViewInventoryInterface extends JFrame { private Inventory theInventory; // reference to back end private InventoryUPCIterator iter; private DefaultListModel dlm; private JList list; private JScrollPane scroll; public ViewInventoryInterface(Inventory theInventory) { this.theInventory = theInventory; iter = theInventory.inventoryUPCIterator(); //returns an

Display a property of Objects in Jlist

梦想的初衷 提交于 2019-12-22 05:31:50
问题 I have a Ingredient class public class Ingredient { String NameP; List ListS; String Desc; List ListT; ... multiple instances of this class are stored in a Objects list. I have also a javax.swing.JList ListIng; With it's model set to ListIngModel = new DefaultListModel(); The idea is to use the Jlist to display the field "NameP" of all objects, select one of them to be further inspected and then grab the selected object: Ingredient Selected = ListIngModel.get(ListIng.getSelectedIndex()) I can

HashMap into DefaultListModel

不想你离开。 提交于 2019-12-20 05:47:23
问题 Here's the code that I have: HashMap<String, String> inst1 = new HashMap(instructorIO.getInstructors()); instListModel = new DefaultListModel<String>(inst1.values()); I get errors: DepartmentProject.java:69: error: constructor DefaultListModel in class DefaultListModel<E> cannot be applied to given types; required: no arguments found: Collection<String> reason: actual and formal argument lists differ in length where E is a type-variable: E extends Object declared in class DefaultListModel Can

JList not updating when adding element to DefaultListModel

不羁的心 提交于 2019-12-20 05:18:13
问题 I'm trying to create a simple program to manage Employees. When trying to add a new employee I can't seem to get the employee to be displayed on the Jlist. The main frame... public class EmployeeFrame extends JFrame implements ActionListener { // The buttons to display private JButton addButton; private JButton editButton; private JButton deleteButton; private JButton saveButton; // The underlying list of employees, and the GUI object to display them private DefaultListModel<Employee>

Java JList problems

会有一股神秘感。 提交于 2019-12-13 07:43:28
问题 Ok what am trying to do is allow the user to make a list for themselves, what ever they type in in the TextField the output of that will be shown in the Jlist but my problem here is that if i type in another word to the TextField the output of that is either appending or replacing the other word that was already there it suppose to go beneath the other word and save there can anyone help me please?? public lala(){ b2 = new JButton("ADD"); b2.addActionListener(new ActionListener(){ public void

DefaultListModel modify jList view

大城市里の小女人 提交于 2019-12-13 04:29:12
问题 If I have the following scenario DefaultListModel model = new DefaultListModel(); model.addElement(file1.getName); model.addElement(file2.getName); ... //Add to list myJList.setModel(model); Now the list would obviously display the file name which is what I want. However if I were to process the files I would then need the actual path. So how would I achieve this outcome where the JList displays only the name but at the same time the model has stored the full path ? Alternately I could of

How do I turn a Java Deque<T> into a DefaultListModel?

微笑、不失礼 提交于 2019-12-12 16:27:28
问题 I wrote a class (let's call it Model.java) that contains a Deque<T> , with methods for enqueuing and dequeuing items. Now I'm trying to tie this to a GUI JList. I'm baffled by how to somehow use my "model" data -- the Deque -- as a DefaultListModel that JList wants. I'm still struggling to really get OO concepts, as they apply to GUI programming. DefaultListModel documentation states: This class loosely implements the java.util.Vector API, in that it implements the 1.1.x version of java.util

Way to save jList data into a txt file?

前提是你 提交于 2019-12-12 05:00:32
问题 I am looking for a way to save the users input from a jlist into a txt file. It's for a homework project. I have the program set up to take user input from a textfield, then it goes into the jlist once they hit the add button. The jlist has a defaultlistmodel on it, and I'm wondering if there is a way to create a save button and allow it to save the complete jlist into a .txt file. Also, here is my code: import java.awt.BorderLayout; import java.awt.EventQueue; import javax.swing.JFrame;

How to change description image in JList java

痴心易碎 提交于 2019-12-11 09:46:27
问题 Below is my code that displays images in a JList . I want to edit the description by each of the images shown in the JList . I don't know how to do it & need help. Thanks... import java.util.*; import javax.imageio.ImageIO; import javax.swing.*; import javax.swing.border.Border; import java.awt.*; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; import java.awt.datatransfer.UnsupportedFlavorException; import java.awt.image.BufferedImage; import java.io.File;