Hey Stack Overflow folks,
I have been trying to get code working where i can double click on an item in a JList and it creates a new JList on a different place on the Frame from scratch of all the object names of items that belong to that category (this is useless info i guess). But the problem is when i double click on the items in the list, it runs through the code to add a component to the JFrame but it just never shows up, is this because i am using a mouse event to build it after run time or something?
My Gui Class is:
public class MediaGUI extends JFrame
and the adding code happens here
_mediaList.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent event) {
if (event.getClickCount() == 2) {
CreateObjectPane(_mediaList.getSelectedValue().toString(););
}
}
});
and here is the building code, this method belongs to MediaGUI, so this. is referring to a JFrame
private void CreateObjectPane(String category)
{
/*=======================================================================
* Create ther list on Objects that belong to each category
* Also a scroll bar for the list
*=======================================================================*/
String objects[] = _mediaHandler.GetObjects(category);
_mediaList = new JList(objects);
_mediaList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
_mediaList.setLayoutOrientation(_mediaList.VERTICAL);
_mediaList.setVisibleRowCount(-1);
_mediaScrollPane = new JScrollPane(_mediaList);
_mediaScrollPane.setPreferredSize(new Dimension(100,100));
_mediaScrollPane.setAlignmentX(CENTER_ALIGNMENT);
_mediaPanel = new JPanel();
_mediaPanel.setLayout(new BoxLayout(_mediaPanel, BoxLayout.PAGE_AXIS));
_mediaLabel = new JLabel("Media Objects");
_mediaLabel.setLabelFor(_mediaList);
_mediaPanel.add(_mediaLabel);
_mediaPanel.add(Box.createRigidArea(new Dimension(0, 15)));
_mediaPanel.add(_mediaScrollPane);
_mediaPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
this.add(_mediaPanel, BorderLayout.CENTER);
}
Any help you could offer would be great, if any more explanation is needed i am happy to require it