def createGui( self ):
     
     jp = swing.JPanel( java.awt.BorderLayout() )
     self.jtp = jtp = swing.JEditorPane( "text/html", "" , editable = 0 )
     self.jsp = jsp = swing.JScrollPane( jtp )
     jb = self.jsp.getBorder()
     self.tb = tb = swing.border.TitledBorder( jb )
     self.tb2 = tb2 = swing.border.TitledBorder( tb, "", tb.CENTER, tb.BOTTOM )
     self.jsp.setBorder( self.tb2 )
     jp.add( jsp )
     jp2 = swing.JPanel()
     
     self.label = swing.JLabel()    
     self._question = question = swing.JButton( "Question" )
     question.actionPerformed = self.question
     self._answer = answer = swing.JButton( "Answer" )
     answer.actionPerformed = self.answer
     self._back = back = swing.JButton( "Back" )
     back.actionPerformed = self.back
     self._next = next = swing.JButton( "Next" )
     next.actionPerformed = self.next
     for z in ( question, answer, back, next ):
         jp2.add( z )
         
     jp.add( jp2, java.awt.BorderLayout.SOUTH )
     return jp
Beispiel #2
0
 def __init__( self, urlString="" ):
     swing.JFrame.__init__( self, title = "HTML Browser", size = ( 800, 600 ) )
     self.contentPane.layout = java.awt.BorderLayout()
     self.contentPane.add( self.buildTopPane( urlString ), java.awt.BorderLayout.NORTH )
     self.htmlPane = swing.JEditorPane( "text/html", "" , editable = 0, hyperlinkUpdate = self.followHyperlink,
                     size = (400, 400 ) )
     self.contentPane.add( swing.JScrollPane( self.htmlPane ), java.awt.BorderLayout.CENTER )
     self.status = swing.JLabel( " ", preferredSize=(500,20) )
     self.contentPane.add( self.status, java.awt.BorderLayout.SOUTH )
     print self.htmlPane.getContentType()
     print self.htmlPane.getDocument()
    def __init__(self):

        self.cached_pages = {}
        self.seen_elements = []
        self.entered = []
        dbf = jparse.DocumentBuilderFactory.newInstance()
        dbf.setValidating(0)
        dbf.setIgnoringComments(1)
        self.documentBuilder = dbf.newDocumentBuilder()
        self.documentBuilder.setEntityResolver(DoNothingEntityResolver())
        self.htmlPane = swing.JEditorPane("text/html",
                                          "",
                                          editable=0,
                                          hyperlinkUpdate=self.followHyperlink)
        self.jsp = swing.JScrollPane(self.htmlPane)
        self.html_dir = g.os_path_join(g.app.loadDir, "..", "doc", "html",
                                       "leo_TOC.html")
        self.fakeDoc = html.HTMLDocument()
        ifile = io.File(self.html_dir)
        self.homeUrl = url = ifile.getCanonicalFile().toURL()
        self.setPage(url)
Beispiel #4
0
 def __init__(self, urlString=DEFAULT_HELP_LINK):
     self.urlList = [urlString]
     self.curUrl = 0
     self.endURL = 0
     #        swing.JFrame.__init__(self, title="JESHelp Browser", size=(800, 600))
     swing.JPanel.__init__(self)
     self.setLayout(java.awt.BorderLayout())
     self.add(self.buildTopPane(urlString), java.awt.BorderLayout.NORTH)
     # don't init this with a URL
     self.htmlPane = swing.JEditorPane(
         'text/html',
         'Welcome to JES',  # urlString,
         editable=0,
         hyperlinkUpdate=self.followHyperlink,
         size=(lang.Short.MAX_VALUE, lang.Short.MAX_VALUE))
     self.add(
         swing.JScrollPane(self.htmlPane,
                           size=(lang.Short.MAX_VALUE,
                                 lang.Short.MAX_VALUE)),
         java.awt.BorderLayout.CENTER)
     self.status = swing.JLabel(" ", preferredSize=(200, 20))
     self.add(self.status, java.awt.BorderLayout.SOUTH)
     self.back.enabled = 0
     self.forward.enabled = 0
Beispiel #5
0
    def __init__(self):
        #########################################################
        #
        # set up the overall frame (the window itself)
        #
        self.window = swing.JFrame("Swing Sampler!")
        self.window.windowClosing = self.goodbye
        self.window.contentPane.layout = awt.BorderLayout()

        #########################################################
        #
        # under this will be a tabbed pane; each tab is named
        # and contains a panel with other stuff in it.
        #
        tabbedPane = swing.JTabbedPane()
        self.window.contentPane.add("Center", tabbedPane)

        #########################################################
        #
        # The first tabbed panel will be named "Some Basic
        # Widgets", and is referenced by variable 'firstTab'
        #
        firstTab = swing.JPanel()
        firstTab.layout = awt.BorderLayout()
        tabbedPane.addTab("Some Basic Widgets", firstTab)

        #
        # slap in some labels, a list, a text field, etc... Some
        # of these are contained in their own panels for
        # layout purposes.
        #
        tmpPanel = swing.JPanel()
        tmpPanel.layout = awt.GridLayout(3, 1)
        tmpPanel.border = swing.BorderFactory.createTitledBorder(
            "Labels are simple")
        tmpPanel.add(swing.JLabel("I am a label. I am quite boring."))
        tmpPanel.add(
            swing.JLabel(
                "<HTML><FONT COLOR='blue'>HTML <B>labels</B></FONT> are <I>somewhat</I> <U>less boring</U>.</HTML>"
            ))
        tmpPanel.add(
            swing.JLabel("Labels can also be aligned", swing.JLabel.RIGHT))
        firstTab.add(tmpPanel, "North")

        #
        # Notice that the variable "tmpPanel" gets reused here.
        # This next line creates a new panel, but we reuse the
        # "tmpPanel" name to refer to it.  The panel that
        # tmpPanel used to refer to still exists, but we no
        # longer have a way to name it (but that's ok, since
        # we don't need to refer to it any more).

        #
        tmpPanel = swing.JPanel()
        tmpPanel.layout = awt.BorderLayout()
        tmpPanel.border = swing.BorderFactory.createTitledBorder(
            "Tasty tasty lists")

        #
        # Note that here we stash a reference to the list in
        # "self.list".  This puts it in the scope of the object,
        # rather than this function.  This is because we'll be
        # referring to it later from outside this function, so
        # it needs to be "bumped up a level."
        #

        listData = [
            "January", "February", "March", "April", "May", "June", "July",
            "August", "September", "October", "November", "December"
        ]
        self.list = swing.JList(listData)
        tmpPanel.add("Center", swing.JScrollPane(self.list))
        button = swing.JButton("What's Selected?")
        button.actionPerformed = self.whatsSelectedCallback
        tmpPanel.add("East", button)
        firstTab.add("Center", tmpPanel)

        tmpPanel = swing.JPanel()
        tmpPanel.layout = awt.BorderLayout()

        #
        # The text field also goes in self, since the callback
        # that displays the contents will need to get at it.
        #
        # Also note that because the callback is a function inside
        # the SwingSampler object, you refer to it through self.
        # (The callback could potentially be outside the object,
        # as a top-level function. In that case you wouldn't
        # use the 'self' selector; any variables that it uses
        # would have to be in the global scope.
        #
        self.field = swing.JTextField()
        tmpPanel.add(self.field)
        tmpPanel.add(
            swing.JButton("Click Me", actionPerformed=self.clickMeCallback),
            "East")
        firstTab.add(tmpPanel, "South")

        #########################################################
        #
        # The second tabbed panel is next...  This shows
        # how to build a basic web browser in about 20 lines.
        #
        secondTab = swing.JPanel()
        secondTab.layout = awt.BorderLayout()
        tabbedPane.addTab("HTML Fanciness", secondTab)

        tmpPanel = swing.JPanel()
        tmpPanel.add(swing.JLabel("Go to:"))
        self.urlField = swing.JTextField(40, actionPerformed=self.goToCallback)
        tmpPanel.add(self.urlField)
        tmpPanel.add(swing.JButton("Go!", actionPerformed=self.goToCallback))
        secondTab.add(tmpPanel, "North")

        self.htmlPane = swing.JEditorPane("http://www.google.com",
                                          editable=0,
                                          hyperlinkUpdate=self.followHyperlink,
                                          preferredSize=(400, 400))
        secondTab.add(swing.JScrollPane(self.htmlPane), "Center")

        self.statusLine = swing.JLabel("(status line)")
        secondTab.add(self.statusLine, "South")

        #########################################################
        #
        # The third tabbed panel is next...
        #
        thirdTab = swing.JPanel()
        tabbedPane.addTab("Other Widgets", thirdTab)

        imageLabel = swing.JLabel(
            swing.ImageIcon(
                net.URL("http://www.gatech.edu/images/logo-gatech.gif")))
        imageLabel.toolTipText = "Labels can have images! Every widget can have a tooltip!"
        thirdTab.add(imageLabel)

        tmpPanel = swing.JPanel()
        tmpPanel.layout = awt.GridLayout(3, 2)
        tmpPanel.border = swing.BorderFactory.createTitledBorder(
            "Travel Checklist")
        tmpPanel.add(
            swing.JCheckBox("Umbrella", actionPerformed=self.checkCallback))
        tmpPanel.add(
            swing.JCheckBox("Rain coat", actionPerformed=self.checkCallback))
        tmpPanel.add(
            swing.JCheckBox("Passport", actionPerformed=self.checkCallback))
        tmpPanel.add(
            swing.JCheckBox("Airline tickets",
                            actionPerformed=self.checkCallback))
        tmpPanel.add(
            swing.JCheckBox("iPod", actionPerformed=self.checkCallback))
        tmpPanel.add(
            swing.JCheckBox("Laptop", actionPerformed=self.checkCallback))
        thirdTab.add(tmpPanel)

        tmpPanel = swing.JPanel()
        tmpPanel.layout = awt.GridLayout(4, 1)
        tmpPanel.border = swing.BorderFactory.createTitledBorder("My Pets")
        #
        # A ButtonGroup is used to indicate which radio buttons
        # go together.
        #
        buttonGroup = swing.ButtonGroup()

        radioButton = swing.JRadioButton("Dog",
                                         actionPerformed=self.radioCallback)
        buttonGroup.add(radioButton)
        tmpPanel.add(radioButton)

        radioButton = swing.JRadioButton("Cat",
                                         actionPerformed=self.radioCallback)
        buttonGroup.add(radioButton)
        tmpPanel.add(radioButton)

        radioButton = swing.JRadioButton("Pig",
                                         actionPerformed=self.radioCallback)
        buttonGroup.add(radioButton)
        tmpPanel.add(radioButton)

        radioButton = swing.JRadioButton("Capybara",
                                         actionPerformed=self.radioCallback)
        buttonGroup.add(radioButton)
        tmpPanel.add(radioButton)

        thirdTab.add(tmpPanel)

        self.window.pack()
        self.window.show()
Beispiel #6
0
 def showHelp(self, e):
     pane = swing.JEditorPane(editable = False)
     pane.setContentType('text/html')
     pane.setPage(MANUAL_JYMET)
     helptab = swing.JScrollPane(pane)
     BaseTabs.TabCloser("Manual").put(helptab, self.tabs)