View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   https://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.bcel.verifier;
20  
21  import java.awt.Dimension;
22  import java.awt.Toolkit;
23  
24  import javax.swing.UIManager;
25  
26  import org.apache.bcel.generic.Type;
27  
28  /**
29   * A graphical user interface application demonstrating JustIce.
30   */
31  public class GraphicalVerifier {
32  
33      private static final boolean packFrame = false;
34  
35      /**
36       * Main method.
37       *
38       * @param args command line arguments.
39       */
40      public static void main(final String[] args) {
41          try {
42              UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
43          } catch (final Exception e) {
44              e.printStackTrace();
45          }
46          new GraphicalVerifier();
47      }
48  
49      /** Constructs a new instance. */
50      public GraphicalVerifier() {
51          final VerifierAppFrame frame = new VerifierAppFrame();
52          // Frames �berpr�fen, die voreingestellte Gr��e haben
53          // Frames packen, die nutzbare bevorzugte Gr��eninformationen enthalten, z.B. aus ihrem Layout
54          if (packFrame) {
55              frame.pack();
56          } else {
57              frame.validate();
58          }
59          // Das Fenster zentrieren
60          final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
61          final Dimension frameSize = frame.getSize();
62          if (frameSize.height > screenSize.height) {
63              frameSize.height = screenSize.height;
64          }
65          if (frameSize.width > screenSize.width) {
66              frameSize.width = screenSize.width;
67          }
68          frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
69          frame.setVisible(true);
70          frame.getClassNamesJList().setModel(new VerifierFactoryListModel());
71          VerifierFactory.getVerifier(Type.OBJECT.getClassName()); // Fill list with java.lang.Object
72          frame.getClassNamesJList().setSelectedIndex(0); // default, will verify java.lang.Object
73      }
74  }