user interface - Adding Java GUI component on Mouse Event -


O stack overflow people,

I'm trying to work in code where I double-click An item in a JList and it creates a new JList at a different place on the frame with the scratches of all the object names of items related to that class (it is useless) The information I think is) But the problem is that when I double click on the items in the list, then this code will be sent to JFrame Tuck runs to add, but yet never displayed, it is because I want to make it after the mouse is using the event to go off on time or something?

My GUI class is:

  Extends the media class JFrame of the public class  

Add more code here

  _medialist.addMouseListener (new mouse adapter) {public zero mouse lime (mouse Event event)} {if (event.getClickCount () == 2) {CreateObjectPane (_mediaList.getSelectedValue () wire () ;);}}});  

And here is the building code, this method is of media, so it is. A JFrame

  Private Zero is referring to the CreateObjectPane (string category) {/ * ================ == ================================================ == === * List the items related to each category * for a list * A scroll bar * ========================== ================================================== ======= / String Object [] = _MediaHandler.GetObjects (Category); _ Media list = new jellist (objects); _mediaList.setSelectionMode (ListSelectionModel.SINGLE_INTERVAL_SELECTION); _mediaList.setLayoutOrientation (_mediaList.VERTICAL); _mediaList.setVisibleRowCount (-1); _mediacrollPane = new JScrollPane (_MediaList); _mediacrollPane.setPreferredSize (new dimension (100,100)); _media ScrollPane.setAlignmentX (CENTER_ALIGNMENT); _ Mediapanel = new zpn (); _mediapanel.setLayout (new boxlight (_MediaPanel, BoxLayout.PAGE_AXIS)); _mediaLabel = New JLabel ("Media Objects"); _mediaLabel.setLabelFor (_mediaList); _mediaPanel.add (_mediaLabel); _ MediaPanel.ed (box. Countrywide Area (new dimension (0, 15)); _mediaPanel.add (_mediaScrollPane); _ MediaPanel.setborder (bordercutter cut attribute (10, 10, 10, 10)); This.add (_MediaPanel, BorderLayout.CENTER); }  

If any further clarification is necessary then whatever you can offer, it will be great.

:

  Note: If a container is displayed, then the container should be valid to display the new component if more than one If the components are being added, after adding all the components, you can only improve once efficiency is valid.  

Some other tips:

  • Rename the CreateObjectPane to create an objectpay
  • Is the layout manager you are using? Try experimenting with it, since most of the time new ingredients are used, where you expect it to be.

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -