Run the user interface.
()
| 145 | |
| 146 | /** Run the user interface. */ |
| 147 | protected static void runGui() throws GateException { |
| 148 | |
| 149 | Thread.currentThread().setPriority(Thread.MIN_PRIORITY); |
| 150 | |
| 151 | // initialise the library and load user CREOLE directories |
| 152 | try{ |
| 153 | Gate.runInSandbox(false); |
| 154 | Gate.init(); |
| 155 | }catch(Throwable t){ |
| 156 | log.error("Problem while initialising GATE", t); |
| 157 | int selection = JOptionPane.showOptionDialog( |
| 158 | null, |
| 159 | "Error during initialisation:\n" + t.toString() + |
| 160 | "\nDo you still want to start GATE?", |
| 161 | "GATE", JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, |
| 162 | null, new String[]{"Cancel", "Start anyway"}, |
| 163 | "Cancel"); |
| 164 | if(selection != 1){ |
| 165 | System.exit(1); |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | //create the main frame, show it |
| 170 | SwingUtilities.invokeLater(new Runnable(){ |
| 171 | @Override |
| 172 | public void run(){ |
| 173 | GraphicsConfiguration gc = GraphicsEnvironment. |
| 174 | getLocalGraphicsEnvironment().getDefaultScreenDevice(). |
| 175 | getDefaultConfiguration(); |
| 176 | |
| 177 | //this needs to run before any GUI component is constructed. |
| 178 | applyUserPreferences(); |
| 179 | |
| 180 | //all the defaults tables have been updated; build the GUI |
| 181 | frame = MainFrame.getInstance(gc); |
| 182 | if(DEBUG) Out.prln("constructing GUI"); |
| 183 | |
| 184 | // run the GUI |
| 185 | frame.setTitleChangable(true); |
| 186 | frame.setTitle(name + " " + Gate.VERSION_STRING + " build " + Gate.BUILD); |
| 187 | |
| 188 | // Set title from Java properties |
| 189 | String title = |
| 190 | System.getProperty(GateConstants.TITLE_JAVA_PROPERTY_NAME); |
| 191 | if(title != null) { |
| 192 | frame.setTitle(title); |
| 193 | } // if |
| 194 | frame.setTitleChangable(false); |
| 195 | |
| 196 | // Set icon from Java properties |
| 197 | // iconName could be absolute or "gate:/img/..." |
| 198 | String iconName = |
| 199 | System.getProperty(GateConstants.APP_ICON_JAVA_PROPERTY_NAME); |
| 200 | if(iconName != null) { |
| 201 | try { |
| 202 | frame.setIconImage(Toolkit.getDefaultToolkit().getImage( |
| 203 | new URL(iconName))); |
| 204 | } catch(MalformedURLException mue){ |
no test coverage detected