KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > core > CLIOptions2


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.core;
21
22 import org.netbeans.CLIHandler;
23
24 /**
25  * Shows the main window, so it is fronted when second instance of
26  * NetBeans tries to start.
27  *
28  * @author Jaroslav Tulach
29  */

30 public class CLIOptions2 extends CLIHandler implements Runnable JavaDoc {
31     /** number of invocations */
32     private int cnt;
33
34     /**
35      * Create a default handler.
36      */

37     public CLIOptions2 () {
38         super(WHEN_INIT);
39     }
40
41     protected int cli(Args arguments) {
42         return cli(arguments.getArguments());
43     }
44
45     final int cli(String JavaDoc[] args) {
46         if (cnt++ == 0) return 0;
47         
48         /*
49         for (int i = 0; i < args.length; i++) {
50             if ("--nofront".equals (args[i])) {
51                 return 0;
52             }
53         }
54          */

55         javax.swing.SwingUtilities.invokeLater (this);
56         
57         return 0;
58     }
59     
60     public void run () {
61         java.awt.Frame JavaDoc f = org.openide.windows.WindowManager.getDefault ().getMainWindow ();
62
63         // makes sure the frame is visible
64
f.setVisible(true);
65         // uniconifies the frame if it is inconified
66
if ((f.getExtendedState () & java.awt.Frame.ICONIFIED) != 0) {
67             f.setExtendedState (~java.awt.Frame.ICONIFIED & f.getExtendedState ());
68         }
69         // moves it to front and requests focus
70
f.toFront ();
71         
72     }
73     
74     
75     protected void usage(java.io.PrintWriter JavaDoc w) {
76         //w.println(NonGui.getString("TEXT_help"));
77
}
78     
79 }
80
Popular Tags