jlist

Listbox (JList) Won't update dynamically from custom ListModel

感情迁移 提交于 2019-12-30 11:06:05
问题 I'm working on a GUI app in Clojure using Seesaw and am having trouble getting a listbox (JList in Java) to update when my custom ListModel gets updated. Here's some of my code: (deftype ActionHistoryListModel [^{:unsynchronized-mutable true} listeners ^{:unsynchronized-mutable true} listening-to] ListModel (addListDataListener [this listener] (set! listeners (conj listeners listener))) (removeListDataListener [this listener] (set! listeners (remove #(= % listener) listeners))) (getSize [this

Add ToolTipText in Jlist Item(s)

怎甘沉沦 提交于 2019-12-29 01:56:16
问题 public static void populateJList(JList list) { ArrayList<String> contents= DataAccess.getContents(); DefaultListModel listModel = new DefaultListModel(); for (String string : contents) { listModel.addElement(string); } preset.setModel(listModel); } I have this method that populates my JList, is there a way that I can add toolTipText of every item in the JList? 回答1: You can override the getToolTipText(..) method of the JList. I believe you can also use a custom renderer which invokes the

Display images inside a JList?

回眸只為那壹抹淺笑 提交于 2019-12-25 18:04:07
问题 I have to write a little photo application for my studies and I have a problem: Basically I divided a frame into two sections: the upper section should display all of the images inside a folder in some kind of overview (thumbnails). If you select a thumbnail, the lower section of the frame should display the image in full size. I'm not sure how to do the upper part right. I guess the best way to do it would be a JList with a horizontal LayoutOrientation ? I tried something like this: public

How to get multiline for a Jlist text? [closed]

不问归期 提交于 2019-12-25 17:43:40
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 6 years ago . I have a problem in get mutiline for Jlist ! Do you have any idiea? 回答1: what have you tried so far? Try implementing a custom ListCellRenderer . More information here. 来源: https://stackoverflow.com/questions

is there a way to make selections permanent on a JList

戏子无情 提交于 2019-12-25 09:13:24
问题 I am trying to device a way to make a list selected items not change, that is, the selections are final. Only newly added or non clicked items can be changed but not the ones which have already been clicked and are already in the list. Following is an example by mKorbel (see answer 8). Is there a way to make the selections permanent on this example? THNX! import java.awt.Component; import java.awt.event.InputEvent; import java.awt.event.MouseEvent; import javax.swing.*; public class Ctrl_Down

Best practice Database Access - list of contacts

自古美人都是妖i 提交于 2019-12-25 06:23:53
问题 i have been wondering for a long time, whilst creating several stupid solutions for this Problem, how the following should be done properly: DataTable: ID | givenname | lastname | address | data ... I want to show all givennames + lastnames in a listbox and uppon selection of one item, i want to retrieve the rest of the corresponding dataset and display is in some textboxes. So i basically do: 1) Query: SELECT ID, givenname, lastname FROM DataTable; 2) Create and ArrayList of "Contact Objects

JList - Highlight specific cells in red

最后都变了- 提交于 2019-12-25 05:16:20
问题 I have a JList on a form. When the form loads, the JList is populated with items from my array. The items are products and have a "quantity in stock" number next to the product details. In the code below I find the stock number and if it is less than 5 I want that line to be highlighted in red. At the moment my WHOLE Jlist is being highlighted in red if there is any quantity which is less than 5. Help!! I'm pretty new to Java so please explain as simply as possible! If someone could explain

Moving selected items between 2 JList with add/remove buttons using AbstractListModel

北慕城南 提交于 2019-12-25 01:18:44
问题 I'm brand new to programming. It seems the more I research the more I confuse myself, I have to be over thinking what needs to be done. abstract list model is what is needed to make the Jlist work properly. I need to know what is right/wrong. where do I put getselectedvalues() , if it even needs to be used? JList Left_list = new JList(); Left_list.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { } }); Left_list.setFont(new Font("Tahoma",

(Java) How can I save multiple files at the same time in Jfilechooser from JList?

做~自己de王妃 提交于 2019-12-24 19:46:22
问题 Picture Purpose I am customizing an Java App for personal use. This App can make many midi files in Java. I would like to SAVE many files at the same time from Jlist. I already could select many files in one time. (I already changed below) public interface ListSelectionModel { int MULTIPLE_INTERVAL_SELECTION > = 2; } Problems I can’t save many files at the same time from list (JList). My idea I am afraid I don’t have good idea. I am not good at Java. I researched this problem in Google and

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