All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edu.stanford.smi.protege.widget.UglySlotWidget Maven / Gradle / Ivy

Go to download

Core code for the Protege ontology editor. Serves as the basis for the Protege-Frames and Protege-OWL editors.

There is a newer version: 3.5.1
Show newest version
package edu.stanford.smi.protege.widget;

import java.awt.*;

import javax.swing.*;

import edu.stanford.smi.protege.util.*;

/**
 * Slot widget that is displayed when another slot widget fails to load (either the constructor or the initialize method
 * throw an exception.  This is a fairly common occurance when slot widgets are being developed.  Placing a "dead" 
 * widget on the form instead causes problems whose source is unclear.  When this widget appears it is perfectly clear
 * that something has gone wrong and users know where to look.
 *
 * @author    Ray Fergerson 
 */
public class UglySlotWidget extends AbstractSlotWidget {
    private static final long serialVersionUID = -1320896168960476357L;
    private String widgetClassName;

    public UglySlotWidget() {
        
    }
    
    public UglySlotWidget(String widgetClassName) {
        this.widgetClassName = widgetClassName;
    }
    
    public String getLabel() {
        return "Ugly Slot Widget (tm)";
    }

    public void initialize() {
        JComponent c1 = ComponentFactory.createLabel("The Ugly Widget\u2122", SwingConstants.CENTER);
        String text = "Slot: " + getSlot().getName();
        if (widgetClassName != null) {
            text += "
Class: " + widgetClassName; } text += ""; JComponent c2 = ComponentFactory.createLabel(text, SwingConstants.CENTER); JPanel panel = new JPanel(new BorderLayout()); panel.setOpaque(true); panel.setBackground(Color.red); panel.setForeground(Color.black); panel.setBorder(BorderFactory.createMatteBorder(5, 5, 5, 5, Color.green)); panel.add(c1, BorderLayout.CENTER); panel.add(c2, BorderLayout.SOUTH); add(panel); setPreferredColumns(2); setPreferredRows(2); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy