Search Mailing List Archives

Limit search to: Subject & Body Subject Author
Sort by: Reverse Sort
Limit to: All This Week Last Week This Month Last Month
Select Date Range     through    

[protege-owl] Any one got working examples of protégé-owl api programmer's guide

Seung-Hwan Kang sk33mail at
Wed May 21 19:32:38 PDT 2008

There are two examples from  The second example is not working? I have been trying to fix the source codes but I have not been successful yet.

Anyone has a working version of 'Protégé User Interface Programming' example. It seems like lots of Java classes and methods are depreciated.

public static void main(String[] args) throws Exception {

        String uri = "";
        OWLModel owlModel = ProtegeOWL.createJenaOWLModelFromURI(uri);
        OWLNamedClass destinationClass = owlModel.getOWLNamedClass("Destination");

        ListPanel listPanel = new ListPanel(destinationClass);
        JFrame frame = new JFrame("Simple List Example");
        Container cont = frame.getContentPane();
        cont.setLayout(new BorderLayout());
        cont.add(BorderLayout.CENTER, listPanel);

        frame.setBounds(100, 100, 300, 300);


    private static class ListPanel extends JPanel implements Disposable {
        private OWLNamedClass destinationClass;
        private JList list;
        private DefaultListModel listModel;

        private ModelListener modelListener = new ModelAdapter() {
            public void individualCreated(RDFResource resource) {
                if (resource.hasRDFType(destinationClass, true)) {

        private OWLModel owlModel;

        ListPanel(OWLNamedClass activityClass) {
            this.destinationClass = activityClass;
            this.owlModel = activityClass.getOWLModel();


            listModel = new DefaultListModel();
            for (Iterator it = activityClass.getInstances(true).iterator(); it.hasNext();) {
                OWLIndividual individual = (OWLIndividual);
            list = new JList(listModel);

            // Make sure list entries show up nicely with icons
            list.setCellRenderer(new ResourceRenderer());

            // Wrap the list together with a button bar
            OWLLabeledComponent lc = new OWLLabeledComponent("Destinations", new JScrollPane(list));
            lc.addHeaderButton(new AbstractAction("Add Destination...", 
                    OWLIcons.getAddIcon(OWLIcons.RDF_INDIVIDUAL)) {
                public void actionPerformed(ActionEvent e) {

            // Add everything into the JPanel
            setLayout(new BorderLayout());
            add(BorderLayout.CENTER, lc);

        private void addDestination() {

// pickOWLNamedClass is depreciated. 
// Deprecated. use ProtegeUI.getSelectionDialogFactory()...
// but it does NOT work too.??
            OWLNamedClass newType = OWLUI.pickOWLNamedClass(owlModel,
                    Collections.singleton(destinationClass), "Select type of new Destination");
            if (newType != null) {
                String name = JOptionPane.showInputDialog(
                        "Enter name of new " + newType.getBrowserText());
                if (name != null) {

        public void dispose() {

        private void handleDestinationAdded(RDFResource destination) {
            list.setSelectedValue(destination, true);

      Get the name you always wanted with the new y7mail email address.

More information about the protege-owl mailing list