jlist

How to load a serialized file back to an arrayList

这一生的挚爱 提交于 2019-12-12 14:15:44
问题 ive looked at a few problems on this matter already but couldnt resolve my issue. As you can see below, i save all the objects in my Patient ArrayList ( pList - which is private at the top of the class) into the "Patient.ser" file through serialization. As far as i can tell this is working with no problems. " patSizeAtSave " is a private variable which i am using to mark as a bound to work with when loading the file(see below) the " patModel " is the DefaultListModel i use for the JLists in

JList: previous selected item

丶灬走出姿态 提交于 2019-12-12 13:13:49
问题 I have a JList and register a selection handler (ListSelectionListener). Now I need to now the previous selected item/index. Up to now, I save the last selected item on my own. Is there a better way to do so? In other words: Is there are methode/best practice which I miss all the years?! 回答1: One of my list is single-selection-only. like kleopatra says. The event data does not help here. That is not what Kleopatra said. The event data does help. You just can't assume that the first index

Update Jlist when new Jframe closing

元气小坏坏 提交于 2019-12-12 05:49:16
问题 I've tried to find some kind of information about my problem with no success, maybe Stackowerflow is to big or I'm using the wrong keywords. Anyway, my problem is that I'm kind a new to Java migrating from the sharp world. I've an project in develop a simple servicedesk software. I've made a JFrame as Startscreen with some buttons and a JList that will display the cases. One of the buttons on the start frame is to create a new case. That button will open a new Jframe where the user can enter

Moving selected data between two JList

巧了我就是萌 提交于 2019-12-12 05:30:12
问题 I am trying to develop a Java code that will move selected data between two JList, As getModel() method will not return the DefaultListModel and explicit casting is also not allowed to List.getModel() method, is it any other possible way to move selected data from one to other JList and vice versa.? Here is the Exact view of what i am trying...("Add All" and "Remove all" buttons are working well, i am using Arralist for that, but i am finding solution for selected data, includig ordering

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;

JList with changing Height

时间秒杀一切 提交于 2019-12-12 04:57:54
问题 I got a JList, which i want to change height of depended on how many items within the JList. As seen in the picture, theres alot of components inside a JPanel, which all are alligned at the Y axis. (the JScrollPanel belongs to the JPanel, NOT the JList) I would like the JList to match its height with the amount of items. A normal JList just stops showing items if it gets too big (unless you apply a JScrollPane).. What i simply want to, is that the JList will get the right size (without hiding

Search an arraylist by the contents of a JTextField - arraylist.contains(jtextfield)

五迷三道 提交于 2019-12-12 03:17:10
问题 Currently, I'm trying to write a system, which is focused around inputting data into lists and arraylists, and implementing search and sort functionality. Currently on my system, I have: A class to store data An arraylist class which gets data from an object within the data storage class. And finally, a swing GUI class, which contains a JList which displays the Arraylist. What i'm trying to do is search through the arraylist with a JButton actionlistener, and then output the results on the

How to add Items to JList from another window

假装没事ソ 提交于 2019-12-12 02:22:32
问题 I have 2 windows. one got an empty JList and the other one got a button. So I want to add the value to the list whenever I press the button. Here is my code but not completed: Window 1 final DefaultListModel<String> favouriteNames = new DefaultListModel<String>(); JList namesList = new JList(favouriteNames); Window 2 public class button extends JFrame { private JList namesList; private DefaultListModel<String> favouriteNames; this.namesList = namesList; JButton addThis = new JButton("Add");

mouseListener has my JList acting strange

倖福魔咒の 提交于 2019-12-12 01:58:01
问题 I have JList that is loaded with Object has its ListCellRenderer and mouseListener, here is the code: MyListCellRenderer: public class MyListCellRenderer extends DefaultListCellRenderer { @Override public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { Component cell = null; if (value instanceof Domain) { Domain domain = (Domain)value; int status = domain.getStatus(); String naziv = domain.getNaziv(); cell = super

How to prevent selection of SeparatorList.Separator in a JList?

荒凉一梦 提交于 2019-12-12 01:51:41
问题 I have created a JList using GrazedLists, specifically an EventList which I then pass into a SeparatorList with a custom Comparator that sorts my EventList elements. I am using a DefaultEventListModel as the JList model, passing in my SeparatorList. And I am using a custom CellRenderer to decorate the SeparatorList.Separator cells. All is displaying nicely, I see a nicely formatted list grouped as I like, similar to optgroups in HTML SELECT elements. Now I would like to prevent selection of