Show a Java Swing GUI with a list
Code: "gui_ShowDemo.py"
Programming language: Python
DMelt Version 1. Last modified: 07/11/2017. License: Free
http://jwork.org/dmelt/code/cache/gui_ShowDemo_4925.py
To run this script using the DMelt IDE, copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.




from java.awt import *
from java.awt.event import *
from javax.swing import *
 
class ExtendedListSelector(MouseListener, MouseMotionListener):
    '''
    Helper class for extended list selections.
    Click + drag to select range of entries.
    Ctrl + click + drag for non-contiguous ranges.
    '''
    def __init__(self, list):
        self.list = list
        # self.selstartindex = -1
        print "OK" 
   
    def mouseClicked(self, evt):
        print "OK"    
        # pass
    def mouseEntered(self, evt):      
          print "OK"  
         # pass
    def mouseExited(self, evt):
          print "OK"  
        # pass
    def mousePressed(self, evt):
        a=JFrame("test");
        a.setVisible(1)
        print "OK" 
        # self.selstartindex = self.list.locationToIndex(evt.point)
       # print "OOO"
    def mouseReleased(self, evt):
        print "OK"
        self.selstartindex = -1
        # pass
    def mouseDragged(self, evt):
        print "OK"
        # pass
        # i = self.list.locationToIndex(evt.point)
        # self.list.addSelectionInterval(self.selstartindex, i)
    def mouseMoved(self, evt):
         print "OK"
        # pass

def  test(self, list):
        self.list = list
        # self.selstartindex = -1
        print "OK" 
    
class ListTest(JFrame):
    def __init__(self):
        rows = \
            ['apple', 'battle', 'cattle', 'dawdle', 'easel', 'fizzle']

       # list = JList(rows,mouseListener=test)
        list = JList(rows)
        list.selectionMode = \
            ListSelectionModel.SINGLE_INTERVAL_SELECTION
        
         
       #  listselector = ExtendedListSelector(list)
       #  list.addMouseListener(listselector)
       # list.addMouseMotionListener(listselector)
        s = JScrollPane(list)
        self.contentPane.add(s)
        
        self.size = 200, 300
        
 
if __name__ == '__main__':
    lt = ListTest()
    lt.visible = 1



lt=ListTest()
lt.setVisible(1)