from java.awt import *
from java.awt import *
from java.awt.event import *
from javax.swing import *


class Scribble(JScrollPane):
    """ A simple GUI example """

    def __init__ (self):  # constructor
        JScrollPane.__init__(self)
        # self.size = 200, 300

        rows = \
            ['apple', 'battle', 'cattle', 'dawdle', 'easel', 'fizzle']
        list=JList(rows)
        
        self.getViewport().add(list)
        
        list.selectionMode = \
            ListSelectionModel.SINGLE_INTERVAL_SELECTION
       
        list.mousePressed = self.doPress
       # self.__last = 0, 0

    def doPress (self, event):
            print "test";
            print "test";
            a=JFrame("test");
            a.setVisible(1)
            i = self.locationToIndex(event.point)

if __name__ == "__main__":
    def doClose (event):
        frame.dispose()



def doClose (event):
        frame.visible = 0

# test
from java.awt import Frame
frame = JFrame("Scribble", windowClosing=doClose)
frame.contentPane.add( Scribble() )

topPanel = JPanel();
lowerPanel = JPanel();
jB2 = JButton("Exit", actionPerformed=doClose)
lowerPanel.add(jB2)
topPanel.setLayout(BorderLayout())
topPanel.add(Scribble(),BorderLayout.CENTER);


frame.add( topPanel,  BorderLayout.CENTER );
frame.add( lowerPanel, BorderLayout.SOUTH );

bounds = view.getBounds()
ww = bounds.width
hh=  bounds.height
xx = bounds.x
yy = bounds.y
frame.setLocation(xx+(int)(0.1*ww), yy+(int)(0.1*hh))
# frame.pack()
frame.setSize( (int)(0.2*ww),(int)(0.4*hh) );
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE)
frame.setVisible(1)



# frame.size = 200, 300
# frame.pack();
# frame.size = 200, 300
# frame.visible = 1





# jHepWork @S.Chekanov