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      /** Main method. */
36      public static void main(final String[] args) {
37          try {
38              UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
39          } catch (final Exception e) {
40              e.printStackTrace();
41          }
42          new GraphicalVerifier();
43      }
44  
45      /** Constructs a new instance. */
46      public GraphicalVerifier() {
47          final VerifierAppFrame frame = new VerifierAppFrame();
48          // Frames �berpr�fen, die voreingestellte Gr��e haben
49          // Frames packen, die nutzbare bevorzugte Gr��eninformationen enthalten, z.B. aus ihrem Layout
50          if (packFrame) {
51              frame.pack();
52          } else {
53              frame.validate();
54          }
55          // Das Fenster zentrieren
56          final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
57          final Dimension frameSize = frame.getSize();
58          if (frameSize.height > screenSize.height) {
59              frameSize.height = screenSize.height;
60          }
61          if (frameSize.width > screenSize.width) {
62              frameSize.width = screenSize.width;
63          }
64          frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
65          frame.setVisible(true);
66          frame.getClassNamesJList().setModel(new VerifierFactoryListModel());
67          VerifierFactory.getVerifier(Type.OBJECT.getClassName()); // Fill list with java.lang.Object
68          frame.getClassNamesJList().setSelectedIndex(0); // default, will verify java.lang.Object
69      }
70  }