logo of the SSW institute
Institut für Systemsoftware
Johannes Kepler Universität Linz
Fachbereich Informatik
logo of the Cristian Doppler Research Association
Christian Doppler Labor
Monitoring and Evolution of Very-Large-Scale Software Systems

Home

General
Staff
Contact
Partners
Alumni

Research
Areas
Projects
Papers
Books
Reports
Awards

Teaching
Lectures
Exams
B.Projects
M.Theses
PhD Theses
Go Abroad

Misc
Library
Seminars
Gallery
Links
Search

Webmaster


logo of the Johannes Kepler University (JKU)
back

WordApp Example - Part 3

  • Change the code of the TextTopComponent class such that a custom lookup based on an InstanceContent object (i.e. a set of objects) is the lookup of the window.
    private InstanceContent content;
    
    private TextTopComponent() {
    
        ...
    
        content = new InstanceContent();
        associateLookup(new AbstractLookup(content));
    }
    

  • Change the code of the filter button such that the old value is added to the InstanceContent object when the button is clicked.
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        String s = text.getText();
        TextFilter filter = Lookup.getDefault().lookup(TextFilter.class);
        if (filter != null) {
            content.add(s);
            s = filter.process(s);
        }
        text.setText(s);
    }  
    

  • Create a new module called "History" with code name base "at.ssw.history". Create a new window component with prefix "History" in the "at.ssw.history" package and add a text area to the window. Change the variable name of the text area to "text".

  • Add code to the HistoryTopComponent class such that it listens to the lookup of class String of the current active window. It displays all retrieved String objects in the text area.
    private Lookup.Result result;
    
    private HistoryTopComponent() {
    
        ...
    
        result = org.openide.util.Utilities.actionsGlobalContext().lookupResult(String.class);
        result.addLookupListener(new LookupListener() {
            public void resultChanged(LookupEvent e) {
                text.setText(result.allInstances().toString());
            }
        });
    }
    

  • Then you can start the application and experiment with it. The result should look similar to the one shown in the screen shot below.
    screen13

  • PROPOSAL: Change the type of the lookup result from String to Object and see what happens when you select different windows.
feedback
back