GraphicalVerifier.java

  1. /*
  2.  * Licensed to the Apache Software Foundation (ASF) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * The ASF licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *      http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  *  Unless required by applicable law or agreed to in writing, software
  12.  *  distributed under the License is distributed on an "AS IS" BASIS,
  13.  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  *  See the License for the specific language governing permissions and
  15.  *  limitations under the License.
  16.  */
  17. package org.apache.bcel.verifier;

  18. import java.awt.Dimension;
  19. import java.awt.Toolkit;

  20. import javax.swing.UIManager;

  21. import org.apache.bcel.generic.Type;

  22. /**
  23.  * A graphical user interface application demonstrating JustIce.
  24.  */
  25. public class GraphicalVerifier {

  26.     private static final boolean packFrame = false;

  27.     /** Main method. */
  28.     public static void main(final String[] args) {
  29.         try {
  30.             UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
  31.         } catch (final Exception e) {
  32.             e.printStackTrace();
  33.         }
  34.         new GraphicalVerifier();
  35.     }

  36.     /** Constructs a new instance. */
  37.     public GraphicalVerifier() {
  38.         final VerifierAppFrame frame = new VerifierAppFrame();
  39.         // Frames �berpr�fen, die voreingestellte Gr��e haben
  40.         // Frames packen, die nutzbare bevorzugte Gr��eninformationen enthalten, z.B. aus ihrem Layout
  41.         if (packFrame) {
  42.             frame.pack();
  43.         } else {
  44.             frame.validate();
  45.         }
  46.         // Das Fenster zentrieren
  47.         final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
  48.         final Dimension frameSize = frame.getSize();
  49.         if (frameSize.height > screenSize.height) {
  50.             frameSize.height = screenSize.height;
  51.         }
  52.         if (frameSize.width > screenSize.width) {
  53.             frameSize.width = screenSize.width;
  54.         }
  55.         frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
  56.         frame.setVisible(true);
  57.         frame.getClassNamesJList().setModel(new VerifierFactoryListModel());
  58.         VerifierFactory.getVerifier(Type.OBJECT.getClassName()); // Fill list with java.lang.Object
  59.         frame.getClassNamesJList().setSelectedIndex(0); // default, will verify java.lang.Object
  60.     }
  61. }