Double JList for Selection Panel with editable fields


I'm not entirely sure how to describe this, but the widget should allow users to set up how they want a table to look. There is a list of available columns, and they have to choose which are visible, and of those that are visible they set how wide the column is, and a number indicating sort order.

Sooooo....

I have been tasked to create two JList boxes, one for NOT visible columns and one for visible columsn. In between would be the "<>" buttons you often see that allow you to move the items back and forth from one list to another.

In the "visible" JList, each item should ALSO have editable fields for entering the width & sort order. The not-visible JList should not show those fields.

My questions are:
1. What do you call that thing when there are two JLists & the "<>" buttons in between That might make my search easier...

2. Can I do this with JLists...or do I need to try to implement this with two tiny tables (And just make it look like JLists)

Any suggestions on where to start\t See silly image I made in Paint below:

THANK YOU!!!
Posted On: Tuesday 23rd of October 2012 10:41:49 PM Total Views:  84
View Complete with Replies

RELATED TOPICS OF Swing / AWT / SWT PROGRAMMING LANGUAGE




how to make mouse clicked event in jlist

Hi My GUI page contains JList and table. Based on the selection in jlist, each time table has to be modified, i.e., if i select first value in jlist and I am adding one or more rows in the table. And then if i click second value in jlist means, a new table have to appear and have to add some new values. Likewise the table should be.. Can anyone suggest me, how to do like this.. I need to complete this within today.. But i dont know how to do.. help please!!
VIEWS ON THIS POST

92

Posted on:

Saturday 22nd September 2012
View Replies!

load a folder and dispaly the pictures en jlist

hello my friend i m newbie en java. i wanna to display all the picture content in folder in jlist it is posible\t what can do i dont have no idea.
VIEWS ON THIS POST

92

Posted on:

Wednesday 26th September 2012
View Replies!

Prevent Duplicate value from jlist to jlist by way of a jbutton

Here is what I have so far. Now I just get the "No duplicates please!" message whenever I add anything to lbSelection. I need to recognize that there is a duplicate and prevent the value from being entered into the list! Any help you can provide would be greatly appreciated!
VIEWS ON THIS POST

155

Posted on:

Monday 1st October 2012
View Replies!

disable selection on double click in textpane

For my application i want to disable the textpane from selecting a word when double click is performed on the word. Is there a way to do this
VIEWS ON THIS POST

122

Posted on:

Tuesday 2nd October 2012
View Replies!

getting result in textfield using jlist

hai i'm trying to use a jtextfiled with a jlist.....here i'm getting the values from a database to the jlist and whenever i type the name i want, i'm getting the result in the jlist...but i can't use the arrowkeys to select these values to jtextfield...i'm able to do it with mouse so i have to get the values in the jlist to the textfield using the arrowkeys..or enter key using the arrowkeys to traverse through the jlist i hope you can help me....if my query is not clear please reply...please do help.. nijin--
VIEWS ON THIS POST

122

Posted on:

Wednesday 17th October 2012
View Replies!

System Tray - double click icon to set visible

I have this code working just fine, one option I want is to use a double-click on the icon in the system tray to set the application visible again. I am thinking of using a mouse listener but not sure where I would put it or would I use a window listener
VIEWS ON THIS POST

100

Posted on:

Wednesday 17th October 2012
View Replies!

How to make all my graphics selectable and doubleclick with event?

Do i have to turn the images into buttons with images But i don't think i want that. If it's selected, I would like to but a border around the image to show it is selected. Then if it's double-click, i want to put some action code on the selected item. Does anyone know of a good link example of what I am trying to do
VIEWS ON THIS POST

85

Posted on:

Wednesday 17th October 2012
View Replies!

header color and the cursor double headed arrow in JTable is not visible

I am using NetBeans 6.7.1 In this desktop app after the user imports a file, the data is displayed in the JTable. Before the file is imported the JTable is setVisible(false) Once the user selects a file to open the code is below tableScrollPane.setVisible(true); jTable1.setVisible(true); DataFileTableModel model = new DataFileTableModel(dataList); jTable1.setModel(model); jTable1.getTableHeader().setBackground(Color.blue); jTable1.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); //HERE is the code to assign the width of the column equal to the length of the header text
VIEWS ON THIS POST

108

Posted on:

Wednesday 17th October 2012
View Replies!

multiple selection in a JList

I've got a JList, where I set theList.setSelectionMode( ListSelectionModel.MULTIPLE_INTERVAL_SELECTION );
VIEWS ON THIS POST

61

Posted on:

Thursday 18th October 2012
View Replies!

JList Deselection

, I am trying to find out how to handle the event of any item being deselected from a JList component. I can deselect a selected item from JList by holding down the Ctrl key and clicking on the selected item. But I couldn't find the event that gets fired. Can anybody help\t Shirish [ October 08, 2004: Message edited by: Shirish Limaye ]
VIEWS ON THIS POST

46

Posted on:

Thursday 18th October 2012
View Replies!

chess game ;array_bug ;selection_of_pieces_in_chess_game

hey ...i am making a project of "CHESS GAME"..... in which to identify any pieces of chess board ,i had used described mechanism....(see code of array) ... but it actually not working...it takes garbage value...it is working only for the "Rook"... i can't understand this behavior...so please help me 2 find out d bugs.. you can also give some more efficient mechanism for identify the piece on chess board... if you know any thing which can help me to make chess game then please post it...hurry up!! thank you... mundvawala array code(jst for idea); jPieces = new String[8][8]; jPieces[0][0] = "bRook"; jPieces[0][1] = "bKnight"; jPieces[0][2] = "bBishop"; jPieces[0][3] = "bQueen"; jPieces[0][4] = "bKing"; jPieces[0][5] = "bBishop"; jPieces[0][6] = "bKnight"; jPieces[0][7] = "bRook"; jPieces[1][0] = "bPawn"; jPieces[1][1] = "bPawn"; jPieces[1][2] = "bPawn"; jPieces[1][3] = "bPawn"; jPieces[1][4] = "bPawn"; jPieces[1][5] = "bPawn"; jPieces[1][6] = "bPawn"; jPieces[1][7] = "bPawn"; jPieces[6][0] = "wPawn"; jPieces[6][1] = "wPawn"; jPieces[6][2] = "wPawn"; jPieces[6][3] = "wPawn"; jPieces[6][4] = "wPawn"; jPieces[6][5] = "wPawn"; jPieces[6][6] = "wPawn"; jPieces[6][7] = "wPawn"; jPieces[7][0] = "wRook"; jPieces[7][1] = "wKnight"; jPieces[7][2] = "wBishop"; jPieces[7][3] = "wQueen"; jPieces[7][4] = "wKing"; jPieces[7][5] = "wBishop"; jPieces[7][6] = "wKnight"; jPieces[7][7] = "wRook"; for(int x=0;x
VIEWS ON THIS POST

70

Posted on:

Monday 22nd October 2012
View Replies!

Can't do multiple selections

On the API of JList there is a link to "How To Use Lists" in the java tutorial, and on that page there are pictures of the different kind of selection modes, single selection, single interval selection, multiple interval selection. In single selection, two is selected, in single interval selection, two,three,four are selected, and in multiple interval selection, one,two,four are selected. I assume those are examples of the possible selections of JList. However, I tried out the online ListSelectionDemo on the page there and I was unable to select more than one item after changing to the single interval selection and the multiple interval selection. Also, in the program I wrote, I can't select more than one item at a time on my JList even after changing to multiple interval selection. Am I selecting wrong or something Is there something wrong with this computer http://java.sun.com/docs/books/tutorial/uiswing/examples/events/index.html#ListSelectionDemo (ListSelectionDemo)
VIEWS ON THIS POST

46

Posted on:

Monday 22nd October 2012
View Replies!

Opening JInternalFrame on JMenu selection

Okay I'm stuck at a little problem. I'm creating a desktop application which uses JDesktopPane and JInternalFrame. Now the main window which contains these internal frames has a menu bar. Some of the menu's don't have any options in them. Instead I have to open a JInternalFrame when the menu is clicked (I know it sounds a little weird but I can't help it). I did it using menuListener on the JMenu. The problem is that the JInternalFrame doesn't gets focus as the empty menu has the focus. I tried to get focus in the internal frame using requestFocus, grabFocus, and setSelected but none worked (I called these methods after the internal frame was visible as I read that they don't work before the frame is visible). As an alternative I tried to add JMenuItem to JMenuBar, it took the full width which I controlled using setMaximumSize. The internal frame is getting focus but the problem in this case is that the shortcut key that I set for this menu item (using setMnemonic) doesn't work. Does anyone know how to either get the internal frame to focus when using JMenu or get the shortcut to work if I put JMenuItem to JMenuBar...
VIEWS ON THIS POST

33

Posted on:

Monday 22nd October 2012
View Replies!

TableViewer Refresh not preserving selection

I have a doubt about the refresh method of the TableViewer. The API says that if I use refresh and set reveal as true, it will preserve the selection, however that doesn't seem to be the case, cause everytime I do it, it loses the selected row. What I do is that I have an inputProvider that rebuilds the data array every 30 seconds, and when that happens I trigger the refresh to properly update, add, and remove rows. Another thing I noticed is that everytime I do that, the tableViewer rows have a different ID everytime, seems like it's incrementing. If I do it this way, would I eventually have a problem if the id becomes too big, or when it reaches a limit will start back at 0
VIEWS ON THIS POST

31

Posted on:

Monday 22nd October 2012
View Replies!

Row selection return value

Please let me know why the below code returns -1 and throws arrayindexoutofbound exception. This line of code is written in action listener for jcombobox. int iRow = Dlg.jtblValuesTable.getSelectedRow() ;
VIEWS ON THIS POST

35

Posted on:

Monday 22nd October 2012
View Replies!

selection JFileTree

I am working with a JTree. I have a button in the toolbar, which when clicked, gets the path of a node selection in the JTree. If the button is pressed but nothing is selected in the JTree, this throws an exception. code: String src = this.tree.getLastSelectedPathComponent().toString(); I need to be able to detect whether there are no nodes selected.
VIEWS ON THIS POST

38

Posted on:

Monday 22nd October 2012
View Replies!

focus selection of components

I need to develop a frame that will have some components that can be selected. Say some component, that the user will select and do some operation. Something like a table row, that can be selected. I need components that can be selected like this.
VIEWS ON THIS POST

41

Posted on:

Monday 22nd October 2012
View Replies!

question on Table selection

this scenario should work right however i keep on getting "null" as output and how can i provoke a reaction not through rightclick as "SWT.MenuDetect" does but through a regular leftclick Element selectedElement = new Element(); . . . table.addListener(SWT.MenuDetect , new Listener() { public void handleEvent(Event e) { TableItem[] selection = table.getSelection(); selectedElement= (Element)selection[0].getData(); System.out.println("Menu selection detected"); System.out.println(selectedElement); } });
VIEWS ON THIS POST

59

Posted on:

Monday 22nd October 2012
View Replies!

Displaying certain items on a panel based on radio button selection.

Hi , I have to design a GUI where in user should enter information like name, ID number, university, company etc. I have to provide radio button selection to choose between two sets of information. For example, let radioButton1(student) be the default where in the panel should display name, ID number and University. If radioButton2(employee) is selected, the panel should now display name, ID number and company(i.e should not display University field). It would have been easier if I could just disable the unwanted components based on selection but am not sure how to display only selected items. I have pasted my code which renders the panel properly initially and disables the unwanted items. Please tell me how I could change the code to display only selcted items.
VIEWS ON THIS POST

64

Posted on:

Monday 22nd October 2012
View Replies!

JList and selection problem

need help in finding solution this problem:want a my programe to be able to add food item and remove whenever i click on any of the button created,also give me an option of whether am sure of delecting and item. I used a sample code from sun tutorials of JList(ListDemo.java) but couldn't my problem and also was alot of that am find difficult debuge.somebody tell what to do.thanks the code is thus: //FoodItem.java /**@author:kingsley Efekodo *@created:31/8/2006 Time:12:02pm */ import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.border.*; public class FoodItem extends JPanel implements ListSelectionListener { //String proteinFood[]=new String[]{"chicken","turkey","beef","fish","egg whites"}; private JList foodlist; private DefaultListModel listmodel; private static final String addString="Add Food Item"; private static final String subString="Remove Food Item"; private JButton subButton; private JTextField foodName; public FoodItem() { super(new BorderLayout()); listmodel=new DefaultListModel(); listmodel.addElement("chicken"); listmodel.addElement("fish"); listmodel.addElement("turkey"); listmodel.addElement("beef"); listmodel.addElement("egg whites"); //create the list and put it in a scroll pane foodlist=new JList(listmodel); foodlist.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); foodlist.setSelectedIndex(0); foodlist.addListSelectionListener(this); foodlist.setVisibleRowCount(5); JScrollPane listScrollPane = new JScrollPane(foodlist); JButton addButton = new JButton(addstring); AddListener addListener = new AddListener(addButton); addButton.setActionCommand(addstring); addButton.addActionListener(addListener); addButton.setEnabled(false); subButton = new JButton(substring); subButton.setActionCommand(substring); subButton.addActionListener(new SubListener()); foodName = new JTextField(10); foodName.addActionListener(addListener); foodName.getDocument().addDocumentListener(addListener); String name = listModel.getElementAt( list.getSelectedIndex()).toString(); //Create a panel that uses BoxLayout. JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS)); buttonPane.add(subButton); buttonPane.add(Box.createHorizontalStrut(5)); buttonPane.add(new JSeparator(SwingConstants.VERTICAL)); buttonPane.add(Box.createHorizontalStrut(5)); buttonPane.add(foodName); buttonPane.add(addButton); buttonPane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); add(listScrollPane, BorderLayout.CENTER); add(buttonPane, BorderLayout.PAGE_END); } class SubListener implements ActionListener { public void actionPerformed(ActionEvent e) { //This method can be called only if //there's a valid selection //so go ahead and remove whatever's selected. int index = list.getSelectedIndex(); listModel.remove(index); int size = listModel.getSize(); if (size == 0) { //Nobody's left, disable firing. subButton.setEnabled(false); } else { //Select an index. if (index == listModel.getSize()) { //removed item in last position index--; } list.setSelectedIndex(index); list.ensureIndexIsVisible(index); } } } //This listener is shared by the text field and the hire button. class AddListener implements ActionListener, DocumentListener { private boolean alreadyEnabled = false; private JButton button; public AddListener(JButton button) { this.button = button; } //Required by ActionListener. public void actionPerformed(ActionEvent e) { String name = foodName.getText(); //User didn't type in a unique name... if (name.equals("") || alreadyInList(name)) { Toolkit.getDefaultToolkit().beep(); foodName.requestFocusInWindow(); foodName.select(); return; } int index = list.getSelectedIndex(); //get selected index if (index == -1) { //no selection, so insert at beginning index = 0; } else { //add after the selected item index++; } listModel.insertElementAt(employeeName.getText(), index); //If we just wanted to add to the end, we'd do this: //listModel.addElement(foodName.getText()); //Reset the text field. foodName.requestFocusInWindow(); foodName.setText(""); //Select the new item and make it visible. list.setSelectedIndex(index); list.ensureIndexIsVisible(index); } //This method tests for string equality. You could certainly //get more sophisticated about the algorithm. For example, //you might want to ignore white space and capitalization. protected boolean alreadyInList(String name) { return listModel.contains(name); } //Required by DocumentListener. public void insertUpdate(DocumentEvent e) { enableButton(); } //Required by DocumentListener. public void removeUpdate(DocumentEvent e) { handleEmptyTextField(e); } //Required by DocumentListener. public void changedUpdate(DocumentEvent e) { if (!handleEmptyTextField(e)) { enableButton(); } } private void enableButton() { if (!alreadyEnabled) { button.setEnabled(true); } } private boolean handleEmptyTextField(DocumentEvent e) { if (e.getDocument().getLength()
VIEWS ON THIS POST

42

Posted on:

Monday 22nd October 2012
View Replies!