View Javadoc
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  
19  import java.awt.Dimension;
20  import java.awt.Toolkit;
21  
22  import javax.swing.UIManager;
23  
24  import org.apache.bcel.generic.Type;
25  
26  /**
27   * A graphical user interface application demonstrating JustIce.
28   */
29  public class GraphicalVerifier {
30  
31      private static final boolean packFrame = false;
32  
33      /** Main method. */
34      public static void main(final String[] args) {
35          try {
36              UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
37          } catch (final Exception e) {
38              e.printStackTrace();
39          }
40          new GraphicalVerifier();
41      }
42  
43      /** Constructs a new instance. */
44      public GraphicalVerifier() {
45          final VerifierAppFrame frame = new VerifierAppFrame();
46          // Frames �berpr�fen, die voreingestellte Gr��e haben
47          // Frames packen, die nutzbare bevorzugte Gr��eninformationen enthalten, z.B. aus ihrem Layout
48          if (packFrame) {
49              frame.pack();
50          } else {
51              frame.validate();
52          }
53          // Das Fenster zentrieren
54          final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
55          final Dimension frameSize = frame.getSize();
56          if (frameSize.height > screenSize.height) {
57              frameSize.height = screenSize.height;
58          }
59          if (frameSize.width > screenSize.width) {
60              frameSize.width = screenSize.width;
61          }
62          frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
63          frame.setVisible(true);
64          frame.getClassNamesJList().setModel(new VerifierFactoryListModel());
65          VerifierFactory.getVerifier(Type.OBJECT.getClassName()); // Fill list with java.lang.Object
66          frame.getClassNamesJList().setSelectedIndex(0); // default, will verify java.lang.Object
67      }
68  }