jlist

Java AWT Threads

喜夏-厌秋 提交于 2019-11-26 22:05:03
问题 I'm having an issue with Threads using netbeans Swing GUI. This is my first time really trying to develop a GUI for a backup program using Java's File System Notifier. I have two files SyncUI.java and Sync.java . Pretty much what I want to happen is you enter a directory path in the jTextField1 text field which creates a sync thread that creates a new sync object and then calls processEvents on that object. When a file in that directory is changed I want to add text about the change to the

Swing JList with multiline text and dynamic height

馋奶兔 提交于 2019-11-26 21:47:08
问题 I already read/tried these posts but that didn't help: Display multiple lines within a Jlist cell How to get multiline for a Jlist text? Problem displaying components of JList What I need is a ListCellRenderer which returns a panel with an icon on the left and a text of dynamic length on the right (like in any forum: on the left a user avatar, on the right the post text). The texts are NOT known to me, so I can't set a fixed cell height. Further, the text length differs from list cell to list

Drag and Drop custom object from JList into JLabel

隐身守侯 提交于 2019-11-26 19:06:59
I have a JList containing an ArrayList of custom objects and I'm trying to create a drag and drop into fields. I'm having trouble understanding how to package and receive the object in Transferable. This is about as far as I've gotten: import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; import java.util.*; public class FlightProjectInterface extends JFrame{ //create GUI Objects private JFrame primaryFrame; private JPanel createFlightPanel; private JPanel aircraftLayout; private JList personsJList, personsOnFlightJList; private JTextField pilotLabel,

JList with categories

时间秒杀一切 提交于 2019-11-26 18:30:31
问题 I have been googling hard trying to find a JList implementation with categories. I guess I could implement one myself, but the cell renderer, model and everything is a bit of a pain. Therefore I turn to you! My question is this: If I have a list of items, assigned to categories, I could display them in a JTree. But since I know the depth is never more than 2, I feel the JTree is overkill. Do you know if there is an easy way in Swing (or in some external library) to make a JList like this:

Disable items in JList

江枫思渺然 提交于 2019-11-26 14:29:27
问题 I'm using a JList as part of a wizard to display all the steps to be performed (it also allows clicking on a step to go to it). Some steps will not always be needed, based on what's done in previous steps. It's these inapplicable steps I'd like to disable in the list. How can I go about disabling (preventing the selection of) certain items in the list? Is there a better way than subclassing JList and overriding every selection-related method? 回答1: you have to implements

How can I set the priority mouse listener

淺唱寂寞╮ 提交于 2019-11-26 11:37:14
问题 I have a panel with lists and buttons. The lists set MouseAdapter with mouseClick() . I added to the panel MouseAdapter with mousePressed() and mouseReleased() and MouseMotionAdapter with mouseDragged . Drag and drop only works if you click on the panel. How to make the drag work even if I clicked on the list? Simple examlpe: public class DragTest extends JFrame{ private boolean drag; private Point btnCoord; private Point startPoint; public DragTest(){ setDefaultCloseOperation(WindowConstants

Add JLabel with image to JList to show all the images

不打扰是莪最后的温柔 提交于 2019-11-26 06:49:04
问题 Here is my code. It does not show images in the frame and instead shows some text. would anybody please suggest me that what change I should make in the code so that it allows me to show the images in a frame? import java.awt.Component; import java.awt.Image; import java.awt.Toolkit; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; import javax.swing.DefaultListModel; import javax.swing.Icon; import javax.swing.ImageIcon;