1 package rero.test; 2 3 import java.awt.*; 4 import java.awt.event.*; 5 6 import javax.swing.*; 7 import javax.swing.event.*; 8 9 import rero.gui.*; 10 import rero.gui.windows.*; 11 12 import rero.config.*; 13 import rero.ident.*; 14 15 import java.net.URI ; 16 17 import java.lang.reflect.*; 18 19 public class WindowTest 20 { 21 private static void checkEnvironment() 22 { 23 boolean invalidenv = false; 24 25 try 26 { 27 String envs = System.getProperty("java.specification.version"); 28 double ver = Double.parseDouble(envs); 29 30 if (ver == 1.4) 31 { 32 invalidenv = System.getProperty("java.vm.version").indexOf("1.4.1") > -1 || System.getProperty("java.vm.version").indexOf("1.4.0") > -1; 33 } 34 else 35 { 36 invalidenv = ver < 1.4; 37 } 38 } 39 catch (Exception ex) { invalidenv = true; } 40 41 if (invalidenv) 42 { 43 String outdated = "Outdated Java Error:\njIRC Requires a java virtual machine compatible \nwith Java 1.4.2 or greater. Download the latest \nversion of "+System.getProperty("java.vendor")+"'s Java at\n"+System.getProperty("java.vendor.url")+"\nYou are running: Java "+System.getProperty("java.version"); 44 45 System.err.println(outdated); 46 47 Frame temp = new Frame(); 48 JOptionPane.showMessageDialog(temp, outdated, "Outdated Java Error", JOptionPane.ERROR_MESSAGE); 49 System.exit(-1); 50 } 51 } 52 53 public static void main(String args[]) 54 { 55 checkEnvironment(); 57 int ARGNO = 0; 58 59 if (System.getProperty("mrj.version") != null) 63 { 64 System.setProperty("apple.laf.useScreenMenuBar", "true"); 65 System.setProperty("com.apple.macos.smallTabs", "true"); 66 System.setProperty("com.apple.mrj.application.apple.menu.about.name", "jIRCii"); 67 68 try 69 { 70 Class osxAdapter = Class.forName("apple.OSXAdapter"); 71 Class [] defArgs = new Class [0]; Method registerMethod = osxAdapter.getDeclaredMethod("registerMacOSXApplication", defArgs); 73 74 if (registerMethod != null) 75 { 76 registerMethod.invoke(osxAdapter, new Object [0]); 77 } 78 } 79 catch (Exception ex) 80 { 81 System.err.println("Exception while loading the OSXAdapter:"); 82 ex.printStackTrace(); 83 } 84 } 85 86 if ((ARGNO + 1) < args.length && args[ARGNO].equals("-settings")) 90 { 91 ClientState.setBaseDirectory(args[ARGNO + 1]); 92 93 ARGNO += 2; 94 } 95 96 try 100 { 101 if ((ARGNO + 1) < args.length && args[ARGNO].equals("-lnf")) 102 { 103 UIManager.setLookAndFeel(args[ARGNO + 1]); 104 ARGNO += 2; 105 } 106 else if (ClientState.getClientState().isOption("ui.native", ClientDefaults.ui_native) && !"com.sun.java.swing.plaf.gtk.GTKLookAndFeel".equals(UIManager.getSystemLookAndFeelClassName())) 114 { 115 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 116 } 117 else 118 { 119 UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); 120 } 121 } 122 catch (Exception e) 123 { 124 System.err.println("Could not load specified look and feel, using system default"); 125 e.printStackTrace(); 126 } 127 128 ProxySettings.initialize(); 132 133 IdentDaemon.initialize(); 137 138 if (ARGNO < args.length && (args[ARGNO].indexOf("irc://") > -1 || args[ARGNO].indexOf("ircs://") > -1)) 142 { 143 try 144 { 145 new QuickConnect(new URI (args[ARGNO])); } 147 catch (Exception urlex) { urlex.printStackTrace(); } 148 149 ARGNO++; 150 } 151 152 new WindowTest(); 156 } 157 158 protected JFrame frame; 159 160 public WindowTest() 161 { 162 frame = new JFrame("jIRCii"); 163 164 GlobalCapabilities.frame = frame; 165 166 frame.getContentPane().setLayout(new BorderLayout()); 167 168 frame.getContentPane().add(new SessionManager(frame), BorderLayout.CENTER); 169 170 frame.setIconImage(ClientState.getClientState().getIcon("jirc.icon", "jicon.jpg").getImage()); 171 172 int inset = (int)Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2; 173 174 frame.setBounds(ClientState.getClientState().getBounds("desktop.bounds", Toolkit.getDefaultToolkit().getScreenSize(), new Dimension(640, 480))); 175 176 frame.addWindowListener(new WindowAdapter() 177 { 178 public void windowClosing(WindowEvent ev) 179 { 180 SessionManager.getGlobalCapabilities().QuitClient(); 181 } 182 }); 183 184 frame.addComponentListener(new ComponentAdapter() 185 { 186 public void componentMoved(ComponentEvent ev) 187 { 188 if (ClientState.getClientState().isOption("desktop.relative", false) || 189 ClientState.getClientState().isOption("window.relative", false) || 190 ClientState.getClientState().isOption("statusbar.relative", false) 191 ) 192 { 193 frame.validate(); 194 ClientState.getClientState().fireChange("desktop"); 195 ClientState.getClientState().fireChange("window"); 196 ClientState.getClientState().fireChange("statusbar"); 197 frame.repaint(); 198 } 199 } 200 }); 201 202 frame.show(); 203 } 204 } 205 | Popular Tags |