jlist

JList content that changes depending on the selected JComboBox made ​​in

左心房为你撑大大i 提交于 2019-12-11 10:02:22
问题 I would like to create a GUI in Java that is composed of a JComboBox and JList. The alternatives are selected from the JComboBox {A, B, C}. Depending on the choice made ​​(A, B, or C) are shown in JList different lists. example: if I select A in the JComboBox, JList will show the following strings: A1, A2, A3, A4 if I select B in the JComboBox, JList will show the following strings: B1, B2, B3, B4 if I select C in the JComboBox, JList will show the following strings: C1, C2, C3, C4 How can I

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;

How can I create dynamic JLists?

本秂侑毒 提交于 2019-12-11 08:56:01
问题 I have multiple Jlist components. When an item in the first list is selected, the next list should dynamically display a new set of possible selections. For example, the first list might have three items which are "A" ,"B" ,"C". When I click "A", the next list should show 1, 2, 3, 4, 5, etc. When I click "B" the next list should show 7, 8, 9, etc. I need these lists to work on this logic. The aim is to implement a GUI like this: 回答1: In outline, Add a ListSelectionListener to the first JList.

Using JList with a model?

两盒软妹~` 提交于 2019-12-11 08:08:09
问题 I'm making an application that lets you add files and then compress them but how to get the files from my hard drive or any hard drive for that matter into my application? I can get the file through a filereader but how to put it into my GUI? I read that defaultListModel is the way to go but am unsure. public class LockNCompressWindow { public static void main(String[] args) { LockFrame w = new LockFrame(); w.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); w.setSize(500,500); w.setResizable

Custom Classes and JLists

大城市里の小女人 提交于 2019-12-11 08:04:46
问题 I'm working in NetBeans on a Java Project. I need to display every State (e.g. "Oklahoma") in an ArrayList<State> in a JList . I can't figure out how to do this... especially not in NetBeans. I think it involves creating a DefaultListModel with each State as a String . I've tried this a million different ways to no avail. Is it possible to just load the ArrayList<State> (perhaps if the State class has a toString() method)? This would be especially helpful, because I could directly modify the

Delete checkboxes in swings

南楼画角 提交于 2019-12-11 06:02:57
问题 i am doing one project related to swings in this i am facing one problem like some 5 check boxes are there in this if i delete two non immediate check boxes (or) single check box i am able to delete but if i delete two immediate check boxes i am not able to delete i.e i have check boxes like 1,2,3,4,5 if i delete 1 and 3 , 1 and 4 , or 3 and 5 etc... (or) 1,2,3 etc.. if i delete using this combination i am able to delete but if i delete 1 and 2 or 2 and 3 or 4 and 5 like immediate check boxes

How to make JScrollPane fit to my jTable?

徘徊边缘 提交于 2019-12-11 05:41:28
问题 I have a problem with JScrollPane when it is used with JTable. How can I make it such that the the scrollPane doesn't have a blank space below the JTable as can be seen in the picture Also,I am currently using a JTabPane that contains 2 JPanels, one for the JScrollPane and one for the JList at the bottom. Is this the right way to do things? 回答1: The method setPreferredScrollableViewportSize(), mentioned here, may be useful in this context. 来源: https://stackoverflow.com/questions/10809263/how

Java - Is there a way to insert a background image in a JList?

江枫思渺然 提交于 2019-12-11 05:32:41
问题 JLists don't offer a method for this, and that's very sad. Do you know how to do it? 回答1: Fixed Position List (ie the image is fixed, but you can scroll the list)... import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; import javax.swing.JFrame; import javax.swing.JList;

How to get the number of columns and rows that are visible in my JList?

泪湿孤枕 提交于 2019-12-11 05:15:42
问题 I have a JList that is inside of a JscrollPane and I am trying to do some pagination on the data, in which as the user scrolls it loads the appropriate amount of data onto the screen. The problem is I need to figure out how much data I need to buffer out of my file and the only way to do that is to figure out how much data needs to be displayed on the screen. Does anyone have an idea of how to get the number or rows and columns that can be displayed out of my JList ? Also is doing pagination

Problem displaying components of JList

霸气de小男生 提交于 2019-12-11 02:39:31
问题 I am trying to dsiplay the twitter timeline in a Jlist component. I have already fixed the size of my frame and the cell height and cell width of the JList too with the following code. jlist.setFixedCellHeight(50); jlist.setFixedCellWidth(70); I find that the height and width of each cell are fine but if the content of the tweet inside the cell exceeds the width it is not displaying the further part of the tweet. For example: Assume that 70 width exactly fits the tweet "I am good" Suppose if