    001/*
    002 * Licensed to the Apache Software Foundation (ASF) under one or more
    003 * contributor license agreements.  See the NOTICE file distributed with
    004 * this work for additional information regarding copyright ownership.
    005 * The ASF licenses this file to You under the Apache License, Version 2.0
    006 * (the "License"); you may not use this file except in compliance with
    007 * the License.  You may obtain a copy of the License at
    008 *
    009 *      http://www.apache.org/licenses/LICENSE-2.0
    010 *
    011 *  Unless required by applicable law or agreed to in writing, software
    012 *  distributed under the License is distributed on an "AS IS" BASIS,
    013 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    014 *  See the License for the specific language governing permissions and
    015 *  limitations under the License.
    016 */
    017package org.apache.bcel.verifier;
    018
    019import java.awt.Dimension;
    020import java.awt.Toolkit;
    021
    022import javax.swing.UIManager;
    023
    024import org.apache.bcel.generic.Type;
    025
    026/**
    027 * A graphical user interface application demonstrating JustIce.
    028 */
    029public class GraphicalVerifier {
    030
    031    private static final boolean packFrame = false;
    032
    033    /** Main method. */
    034    public static void main(final String[] args) {
    035        try {
    036            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    037        } catch (final Exception e) {
    038            e.printStackTrace();
    039        }
    040        new GraphicalVerifier();
    041    }
    042
    043    /** Constructor. */
    044    public GraphicalVerifier() {
    045        final VerifierAppFrame frame = new VerifierAppFrame();
    046        // Frames �berpr�fen, die voreingestellte Gr��e haben
    047        // Frames packen, die nutzbare bevorzugte Gr��eninformationen enthalten, z.B. aus ihrem Layout
    048        if (packFrame) {
    049            frame.pack();
    050        } else {
    051            frame.validate();
    052        }
    053        // Das Fenster zentrieren
    054        final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    055        final Dimension frameSize = frame.getSize();
    056        if (frameSize.height > screenSize.height) {
    057            frameSize.height = screenSize.height;
    058        }
    059        if (frameSize.width > screenSize.width) {
    060            frameSize.width = screenSize.width;
    061        }
    062        frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
    063        frame.setVisible(true);
    064        frame.getClassNamesJList().setModel(new VerifierFactoryListModel());
    065        VerifierFactory.getVerifier(Type.OBJECT.getClassName()); // Fill list with java.lang.Object
    066        frame.getClassNamesJList().setSelectedIndex(0); // default, will verify java.lang.Object
    067    }
    068}