@Override public void actionPerformed(ActionEvent AE) { if (AE.getSource() == CheckAll) { boolean Selection = CheckAll.isSelected(); if (Selection) CheckAll.setText("Uncheck all"); else CheckAll.setText("Check all"); for (int i = 0; i < NumberOfCourses; i++) My[i].CourseCheckBox.setSelected(Selection); } if (AE.getSource() == DocButton) if (TempControll.ConnectionManagerObject.createConnection()) { new File(System.getProperty("user.home") + "/TermResultCalculator/StudentDocs/").mkdirs(); if (gatherDataForDocument()) { if (TempControll.StudentPdfObject.createPDF( this.Roll, this.Session, this.Selected, this.Taken, this.Completed, this.GPA)) JOptionPane.showMessageDialog( RPS, "Report created successfully at " + System.getProperty("user.home") + "/TermResultCalculator/StudentDocs/", "Success", JOptionPane.INFORMATION_MESSAGE); else JOptionPane.showMessageDialog( RPS, "Error while creating report.", "Error", JOptionPane.ERROR_MESSAGE); } else JOptionPane.showMessageDialog( RPS, "At least one course has to be selected.", "Error : No Selection", JOptionPane.ERROR_MESSAGE); } }
/** * Make sure we have a theme set. Try to read a default value from the 'theme' property or use the * fallback. */ public static void initialize() { if (ShadeConfig.theme.isSet()) return; MyTheme theme = null; if (System.getProperty("theme") == null) theme = FALLBACK; else { try { theme = valueOf(System.getProperty("theme").trim().toUpperCase(java.util.Locale.ENGLISH)); } catch (IllegalArgumentException ignored) { /* No theme by the name given in the property 'theme'. */ } if (theme == null) { Color customColor = null; try { customColor = Color.decode(System.getProperty("theme").trim()); } catch (NumberFormatException e) { if (System.getProperty("theme").trim().length() > 0) Logger.get(MyTheme.class) .err(e, "err.invalidDefaultTheme", System.getProperty("theme").trim()); } if (customColor != null) { MyTheme.CUSTOM.getLookAndFeel().setBase(customColor); theme = CUSTOM; } else theme = FALLBACK; } } ShadeConfig.theme.set(theme.getLookAndFeel()); }
/* (non-Javadoc) * @see org.jdesktop.swingworker.SwingWorker#doInBackground() */ @Override protected Void doInBackground() throws Exception { if (errorInfo != null) { Throwable t = errorInfo.getErrorException(); String osMessage = "An error occurred on " + System.getProperty("os.name") + " version " + System.getProperty("os.version"); StringBuffer message = new StringBuffer(); message.append("System Info : ").append(osMessage).append(NEW_LINE_CHAR); message.append("Message : ").append(t.toString()).append(NEW_LINE_CHAR); message.append("Level : ").append(errorInfo.getErrorLevel()).append(NEW_LINE_CHAR); message.append("Stack Trace : ").append(NEW_LINE_CHAR); message.append(stackTraceToString(t)); // copy error message to system clipboard StringSelection stringSelection = new StringSelection(message.toString()); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(stringSelection, null); // open errorReportingURL OpenBrowserAction openBrowserAction = new OpenBrowserAction(errorReportingURL); openBrowserAction.actionPerformed(null); } return null; }
private MouseOrTabletOperation( String name, String description, WorldPainterView view, int delay, boolean oneshot, String statisticsKey, String iconName) { super( name, description, (iconName != null) ? iconName : name.toLowerCase().replaceAll("\\s", "")); setView(view); this.delay = delay; this.oneShot = oneshot; this.statisticsKey = statisticsKey; statisticsKeyUndo = statisticsKey + ".undo"; legacy = (SystemUtils.isMac() && System.getProperty("os.version").startsWith("10.4.")) || "true" .equalsIgnoreCase( System.getProperty("org.pepsoft.worldpainter.disableTabletSupport")); if (legacy) { logger.warn("Tablet support disabled for operation " + name); } }
public static void main(String[] s) { System.out.println("STAGE 1"); System.setProperty("sun.awt.enableExtraMouseButtons", "true"); boolean propValue = Boolean.parseBoolean(System.getProperty("sun.awt.enableExtraMouseButtons")); if (!propValue) { throw new RuntimeException( "TEST FAILED(1) : System property sun.awt.enableExtraMouseButtons = " + propValue); } if (!Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled()) { throw new RuntimeException( "TEST FAILED(1) : Toolkit.areExtraMouseButtonsEnabled() returns false"); } System.out.println("STAGE 2"); System.setProperty("sun.awt.enableExtraMouseButtons", "false"); propValue = Boolean.parseBoolean(System.getProperty("sun.awt.enableExtraMouseButtons")); if (propValue) { throw new RuntimeException( "TEST FAILED(2) : System property sun.awt.enableExtraMouseButtons = " + propValue); } if (!Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled()) { throw new RuntimeException( "TEST FAILED(2) : Toolkit.areExtraMouseButtonsEnabled() returns false"); } System.out.println("Test passed."); }
/** * Returns JPicEdt's install directory w/o trailing "/", provided the command line looks like : * * <p><code>java -classpath other-class-paths:jpicedt-install-dir/lib/jpicedt.jar jpicedt.JPicEdt * </code> (where <code>/</code> may be replaced by the actual respective separator for files on * the underlying platform). * * <p>For Windows platform, the install directory is tried to be detected 1st with the MSWindows * file-separator (<code>\</code>), and if this does not work, a subsequent trial is made with * <code>/</code>. * * <p>That is, the old way (java -jar jpicedt.jar) won't work. However, classpath can contain * relative pathname (then user.dir get prepended). * * <p>Code snippet was adapted from jEdit/JEdit.java (http://www.jedit.org). * * @return the value of the "user.dir" Java property if "lib/jpicedt.jar" wasn't found in the * command line. */ public static String getJPicEdtHome() { String classpath = System.getProperty("java.class.path"); // e.g. // "/usr/lib/java/jre/lib/rt.jar:/home/me/jpicedt/1.3.2/lib/jpicedt.jar" // File.separator = "/" on Unix, "\\" on Windows,... String fileSeparator = File.separator; int index; // File.pathSeparator = ":" on Unix/MacOS-X platforms, ";" on Windows // search ":" backward starting from // "/usr/lib/java/jre/lib/rt.jar:/home/me/jpicedt/1.3.2/^lib/jpicedt.jar" String homeDir = null; int trials = 2; do { index = classpath.toLowerCase().indexOf("lib" + fileSeparator + "jpicedt.jar"); int start = classpath.lastIndexOf(File.pathSeparator, index); if (start == -1) start = 0; // File.pathSeparator not found => lib/jpicedt.jar probably at beginning of classpath else start += File.pathSeparator.length(); // e.g. ":^/home..." if (index >= start) { homeDir = classpath.substring(start, index); if (homeDir.endsWith(fileSeparator)) homeDir = homeDir.substring(0, homeDir.length() - 1); } switch (trials) { case 2: if (File.pathSeparator.equals(";") && homeDir == null) { // MS-Windows case, this must work both with / and \ trials = 1; fileSeparator = "/"; } else trials = 0; break; case 1: if (homeDir != null && !fileSeparator.equals(File.separator)) { homeDir.replace(fileSeparator, File.separator); } trials = 0; break; default: trials = 0; break; } } while (trials != 0); if (homeDir != null) { if (homeDir.equals("")) homeDir = System.getProperty("user.dir"); else if (!new File(homeDir).isAbsolute()) homeDir = System.getProperty("user.dir") + File.separator + homeDir; } else { homeDir = System.getProperty("user.dir"); if (homeDir.endsWith( "lib")) // this is the case if jpicedt run as "java -jar jpicedt.jar" from inside lib/ dir homeDir = homeDir.substring(0, homeDir.lastIndexOf("lib")); } // System.out.println("JPicEdt's home = " + homeDir); return homeDir; }
// Creates a new thread, runs the program in that thread, and reports any errors as needed. private void run(String clazz) { try { // Makes sure the JVM resets if it's already running. if (JVMrunning) kill(); // Some String constants for java path and OS-specific separators. String separator = System.getProperty("file.separator"); String path = System.getProperty("java.home") + separator + "bin" + separator + "java"; // Tries to run compiled code. ProcessBuilder builder = new ProcessBuilder(path, clazz); // Should be good now! Everything past this is on you. Don't mess it up. println( "Build succeeded on " + java.util.Calendar.getInstance().getTime().toString(), progErr); println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", progErr); JVM = builder.start(); // Note that as of right now, there is no support for input. Only output. Reader errorReader = new InputStreamReader(JVM.getErrorStream()); Reader outReader = new InputStreamReader(JVM.getInputStream()); // Writer inReader = new OutputStreamWriter(JVM.getOutputStream()); redirectErr = redirectIOStream(errorReader, err); redirectOut = redirectIOStream(outReader, out); // redirectIn = redirectIOStream(null, inReader); } catch (Exception e) { // This catches any other errors we might get. println("Some error thrown", progErr); logError(e.toString()); displayLog(); return; } }
static { // SoyLatte doesn't properly support document modal dialogs yet. isDocumentModalitySupported = !System.getProperty("os.name").equals("Darwin") && System.getProperty("java.version").compareTo("1.6") >= 0; isNativeSheetSupported = QuaquaManager.isOSX() && System.getProperty("java.version").compareTo("1.6") >= 0; }
public String getInfo() { return version() + System.getProperty("os.name") + " " + System.getProperty("os.version") + "; " + IJ.freeMemory(); }
private String generateExceptionReport() { StringBuilder builder = new StringBuilder("Spoutcraft Launcher Error Report:\n"); builder.append("( Please submit this report to http://spout.in/issues )\n"); builder.append(" Launcher Build: ").append(Settings.getLauncherBuild()).append("\n"); builder .append("----------------------------------------------------------------------") .append("\n"); builder.append("Stack Trace:").append("\n"); builder.append(" Exception: ").append(cause.getClass().getSimpleName()).append("\n"); builder.append(" Message: ").append(cause.getMessage()).append("\n"); logTrace(builder, cause); builder .append("----------------------------------------------------------------------") .append("\n"); builder.append("System Information:\n"); builder.append(" Operating System: ").append(System.getProperty("os.name")).append("\n"); builder .append(" Operating System Version: ") .append(System.getProperty("os.version")) .append("\n"); builder .append(" Operating System Architecture: ") .append(System.getProperty("os.arch")) .append("\n"); builder .append(" Java version: ") .append(System.getProperty("java.version")) .append(" ") .append(System.getProperty("sun.arch.data.model", "32")) .append(" bit") .append("\n"); builder .append(" Total Memory: ") .append(Runtime.getRuntime().totalMemory() / 1024L / 1024L) .append(" MB\n"); builder .append(" Max Memory: ") .append(Runtime.getRuntime().maxMemory() / 1024L / 1024L) .append(" MB\n"); builder .append(" Memory Free: ") .append(Runtime.getRuntime().freeMemory() / 1024L / 1024L) .append(" MB\n"); builder .append(" CPU Cores: ") .append(Runtime.getRuntime().availableProcessors()) .append("\n"); return builder.toString(); }
/** * This method initializes jTextArea * * @return javax.swing.JTextArea */ private JTextArea getJTextArea() { if (installDirTextArea == null) { String path; path = System.getProperty("user.home"); installDirTextArea = new JTextArea(); installDirTextArea.setEditable(false); installDirTextArea.setText(System.getProperty("user.home")); installDirTextArea.setBounds(new Rectangle(13, 49, 206, 21)); } return installDirTextArea; }
private void updateLinuxServiceInstaller() { try { File dir = new File(directory, "CTP"); if (suppressFirstPathElement) dir = dir.getParentFile(); Properties props = new Properties(); String ctpHome = dir.getAbsolutePath(); cp.appendln(Color.black, "...CTP_HOME: " + ctpHome); ctpHome = ctpHome.replaceAll("\\\\", "\\\\\\\\"); props.put("CTP_HOME", ctpHome); File javaHome = new File(System.getProperty("java.home")); String javaBin = (new File(javaHome, "bin")).getAbsolutePath(); cp.appendln(Color.black, "...JAVA_BIN: " + javaBin); javaBin = javaBin.replaceAll("\\\\", "\\\\\\\\"); props.put("JAVA_BIN", javaBin); File linux = new File(dir, "linux"); File install = new File(linux, "ctpService-ubuntu.sh"); cp.appendln(Color.black, "Linux service installer:"); cp.appendln(Color.black, "...file: " + install.getAbsolutePath()); String bat = getFileText(install); bat = replace(bat, props); // do the substitutions bat = bat.replace("\r", ""); setFileText(install, bat); // If this is an ISN installation, put the script in the correct place. String osName = System.getProperty("os.name").toLowerCase(); if (programName.equals("ISN") && !osName.contains("windows")) { install = new File(linux, "ctpService-red.sh"); cp.appendln(Color.black, "ISN service installer:"); cp.appendln(Color.black, "...file: " + install.getAbsolutePath()); bat = getFileText(install); bat = replace(bat, props); // do the substitutions bat = bat.replace("\r", ""); File initDir = new File("/etc/init.d"); File initFile = new File(initDir, "ctpService"); if (initDir.exists()) { setOwnership(initDir, "edge", "edge"); setFileText(initFile, bat); initFile.setReadable(true, false); // everybody can read //Java 1.6 initFile.setWritable(true); // only the owner can write //Java 1.6 initFile.setExecutable(true, false); // everybody can execute //Java 1.6 } } } catch (Exception ex) { ex.printStackTrace(); System.err.println("Unable to update the Linux service ctpService.sh file"); } }
public String getSelectedPath(String item) { String path = "", fileSep = System.getProperty("file.separator"); /* try { path = converter.getDefaultTemplateFilePath().getParent() + fileSep; } catch (FileNotFoundException e) { final String caption = ResourceHandler.getMessage("notemplate_dialog.caption"); final String info = ResourceHandler.getMessage("notemplate_dialog.info0") + PluginConverter.getDefaultTemplateFileName() + ResourceHandler.getMessage("notemplate_dialog.info1"); JOptionPane.showMessageDialog(this, info, caption, JOptionPane.ERROR_MESSAGE); System.exit(0); } */ if (item.equals(DEFAULT_STR)) return path + DEFAULT_PATH; else if (item.equals(EXTEND_STR)) return path + EXTEND_PATH; else if (item.equals(IE_STR)) return path + IE_PATH; else if (item.equals(NS_STR)) return path + NS_PATH; else return item; }
/** Construct a FileTree */ public FilePanel(JPanel panel, final IDEWindow ideWindow) { pane = panel; setLayout(new BorderLayout()); // Make a tree list with all the nodes, and make it a JTree JTree tree = new JTree(addNodes(null, new File(System.getProperty("user.dir")))); // Add a listener tree.addTreeSelectionListener( new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.getPath().getLastPathComponent(); File file = null; if (node.isLeaf()) { file = new File(node.getParent() + "/" + node); ToolbarFunctions.open(file, ideWindow); } } }); setSize(panel.getPreferredSize()); // Lastly, put the JTree into a JScrollPane. JScrollPane scrollpane = new JScrollPane(); scrollpane.getViewport().add(tree); add(BorderLayout.CENTER, scrollpane); }
/** * Returns the language set on the client computer as a full string. If there are any errors, it * will return the default ISO 639 2-digit language code. * * @return The client's language. */ public static String getLanguage() { try { return locale.getDisplayLanguage(); } catch (Exception ignored) { return System.getProperty("user.language"); } }
public APCircleWindow() { super("AP Circles"); setDefaultCloseOperation(EXIT_ON_CLOSE); String startDirectoryName = System.getProperty("user.dir"); startDirectory = new File(startDirectoryName); // this for convenience, as the program normally starts in graph/display // startDirectory = startDirectory.getParentFile(); gw = this; generalXML = new GeneralXML(graph); gp = new APCirclePanel(this); getContentPane().add(gp); graph = gp.getGraph(); initView(); initExperiment(); initUtility(); initLayout(); initMenu(); setSize(width, height); Dimension frameDim = Toolkit.getDefaultToolkit().getScreenSize(); int posX = (frameDim.width - getSize().width) / 2; int posY = (frameDim.height - getSize().height) / 2; setLocation(posX, posY); setVisible(true); gp.requestFocus(); }
private static File findFileForFont(Font font, final boolean matchStyle) { final String normalizedFamilyName = font.getFamily().toLowerCase(Locale.getDefault()).replace(" ", ""); final int fontStyle = font.getStyle(); File[] files = new File(System.getProperty("user.home"), "Library/Fonts") .listFiles( new FilenameFilter() { @Override public boolean accept(File file, String name) { String normalizedName = name.toLowerCase(Locale.getDefault()); return normalizedName.startsWith(normalizedFamilyName) && (normalizedName.endsWith(".otf") || normalizedName.endsWith(".ttf")) && (!matchStyle || fontStyle == ComplementaryFontsRegistry.getFontStyle(name)); } }); if (files == null || files.length == 0) return null; // to make sure results are predictable we return first file in alphabetical order return Collections.min( Arrays.asList(files), new Comparator<File>() { @Override public int compare(File file1, File file2) { return file1.getName().compareTo(file2.getName()); } }); }
/** * The following code is a trick! By default Swing uses lightweight and "medium" weight popups to * show JPopupMenu. The code below force the creation of real heavyweight menus - this increases * speed of popups and allows to get rid of some drawing artifacts. */ private static void fixPopupWeight() { int popupWeight = OurPopupFactory.WEIGHT_MEDIUM; String property = System.getProperty("idea.popup.weight"); if (property != null) property = property.toLowerCase(Locale.ENGLISH).trim(); if (SystemInfo.isMacOSLeopard) { // force heavy weight popups under Leopard, otherwise they don't have shadow or any kind of // border. popupWeight = OurPopupFactory.WEIGHT_HEAVY; } else if (property == null) { // use defaults if popup weight isn't specified if (SystemInfo.isWindows) { popupWeight = OurPopupFactory.WEIGHT_HEAVY; } } else { if ("light".equals(property)) { popupWeight = OurPopupFactory.WEIGHT_LIGHT; } else if ("medium".equals(property)) { popupWeight = OurPopupFactory.WEIGHT_MEDIUM; } else if ("heavy".equals(property)) { popupWeight = OurPopupFactory.WEIGHT_HEAVY; } else { LOG.error("Illegal value of property \"idea.popup.weight\": " + property); } } PopupFactory factory = PopupFactory.getSharedInstance(); if (!(factory instanceof OurPopupFactory)) { factory = new OurPopupFactory(factory); PopupFactory.setSharedInstance(factory); } PopupUtil.setPopupType(factory, popupWeight); }
/** * Class constructor alloowing specification of the heading text. * * @param properties the Properties object containing the initial values of the extensions list * and the path to be displayed. This object is updated tin response to root changes, * extension changes, and file selections. If any property is missing, a suitable one is * supplied by default. * @param heading the text to appear in the heading of the JPanel. * @param background the background color or null if the default is to be used. */ public SourcePanel(ApplicationProperties properties, String heading, Color background) { super(); this.properties = properties; if (background == null) this.background = Color.getHSBColor(0.58f, 0.17f, 0.95f); else this.background = background; // Make the file filter filter = new GeneralFileFilter(); String extensions = properties.getProperty("extensions"); if (extensions != null) filter.setExtensions(extensions); else { filter.addExtension(".dcm"); properties.setProperty("extensions", filter.getExtensionString()); } // Get the starting directory path from the properties. // If it is missing, start in the directory containing the program. String currentDirectoryPath = properties.getProperty("directory"); if (currentDirectoryPath == null) currentDirectoryPath = System.getProperty("user.dir"); // Create the UI components this.setLayout(new BorderLayout()); directoryPane = new DirectoryPane(filter, currentDirectoryPath); directoryPane.addFileListener(this); headerPanel = new HeaderPanel(heading); footerPanel = new FooterPanel(); this.add(headerPanel, BorderLayout.NORTH); this.add(directoryPane, BorderLayout.CENTER); this.add(footerPanel, BorderLayout.SOUTH); }
public void loadROM() { FileDialog fileDialog = new FileDialog(this); fileDialog.setMode(FileDialog.LOAD); fileDialog.setTitle("Select a ROM to load"); // should open last folder used, and if that doesn't exist, the folder it's running in final String path = PrefsSingleton.get().get("filePath", System.getProperty("user.dir", "")); final File startDirectory = new File(path); if (startDirectory.isDirectory()) { fileDialog.setDirectory(path); } // and if the last path used doesn't exist don't set the directory at all // and hopefully the jFileChooser will open somewhere usable // on Windows it does - on Mac probably not. fileDialog.setFilenameFilter(new NESFileFilter()); boolean wasInFullScreen = false; if (inFullScreen) { wasInFullScreen = true; // load dialog won't show if we are in full screen, so this fixes for now. toggleFullScreen(); } fileDialog.setVisible(true); if (fileDialog.getFile() != null) { PrefsSingleton.get().put("filePath", fileDialog.getDirectory()); loadROM(fileDialog.getDirectory() + fileDialog.getFile()); } if (wasInFullScreen) { toggleFullScreen(); } }
private byte[] loadClassData(String className) throws IOException { Playground.println("Loading class " + className + ".class", warning); File f = new File(System.getProperty("user.dir") + "/" + className + ".class"); byte[] b = new byte[(int) f.length()]; new FileInputStream(f).read(b); return b; }
/** * Returns the country from which the client is from based on the default Locale. If it encounters * any errors in retrieving the locale, it will reply with the ISO 3166 2-digit code. * * @return The language's country. */ public static String getCountry() { try { return locale.getDisplayCountry(); } catch (Exception ignored) { return System.getProperty("user.country"); } }
public String getPath() { String cadena = ((Ps2RealityFileChooser) panelChooser).getMediaPath(); if (cadena == null) { cadena = System.getProperty("user.dir"); } return cadena; }
// creaza un nou disk si un nou sistem de fisiere pe acesta public void newDisk(String diskName) { try { File newDisk = new File(System.getProperty("user.dir").toString() + "/" + diskName); if (newDisk.exists()) { System.out.println("Unable to create " + newDisk.getAbsolutePath()); } else { newDisk.mkdirs(); System.out.println("New disk created:" + diskName); addDiskRefernce(diskName); currentDiskPath = System.getProperty("user.dir").toString() + "\\" + diskName; currentPath = currentDiskPath; } } finally { takePath(); } }
/** Return the platform standard tmp dir, or null if none is standardly defined. */ public static File getOSTmpDir() { // Note : default tmp dir can be obtained through : // System.getProperty("java.io.tmp") String tmp = System.getProperty("java.io.tmp"); if (tmp == null) return null; else return new File(tmp); }
void enableLionFS() { try { String version = System.getProperty("os.version"); String[] tokens = version.split("\\."); int major = Integer.parseInt(tokens[0]), minor = 0; if (tokens.length > 1) minor = Integer.parseInt(tokens[1]); if (major < 10 || (major == 10 && minor < 7)) throw new Exception("Operating system version is " + version); Class fsuClass = Class.forName("com.apple.eawt.FullScreenUtilities"); Class argClasses[] = new Class[] {Window.class, Boolean.TYPE}; Method setWindowCanFullScreen = fsuClass.getMethod("setWindowCanFullScreen", argClasses); setWindowCanFullScreen.invoke(fsuClass, this, true); Class fsListenerClass = Class.forName("com.apple.eawt.FullScreenListener"); InvocationHandler fsHandler = new MyInvocationHandler(cc); Object proxy = Proxy.newProxyInstance( fsListenerClass.getClassLoader(), new Class[] {fsListenerClass}, fsHandler); argClasses = new Class[] {Window.class, fsListenerClass}; Method addFullScreenListenerTo = fsuClass.getMethod("addFullScreenListenerTo", argClasses); addFullScreenListenerTo.invoke(fsuClass, this, proxy); canDoLionFS = true; } catch (Exception e) { vlog.debug("Could not enable OS X 10.7+ full-screen mode:"); vlog.debug(" " + e.toString()); } }
public void loadMacros() { File f = new File(System.getProperty("user.dir")); String[] files = f.list(); for (int i = 0; i < files.length; i++) { try { if (files[i].startsWith("macro_") && files[i].endsWith(".class") && files[i].indexOf('$') == -1) { System.out.println(files[i]); Class clazz = Class.forName(files[i].substring(0, files[i].length() - ".class".length())); Macro macro = (Macro) clazz .getConstructor(new Class[] {mudclient_Debug.class}) .newInstance(new Object[] {inner}); String[] commands = macro.getCommands(); for (int j = 0; j < commands.length; j++) { System.out.println("command registered:" + commands[j]); mudclient_Debug.macros.put(commands[j], macro); } } } catch (Exception e) { e.printStackTrace(); } } }
/** * @return the clipboard content as a String (DataFlavor.stringFlavor) Code snippet adapted from * jEdit (Registers.java), http://www.jedit.org. Returns null if clipboard is empty. */ public static String getClipboardStringContent(Clipboard clipboard) { // Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); try { String selection = (String) (clipboard.getContents(null).getTransferData(DataFlavor.stringFlavor)); if (selection == null) return null; boolean trailingEOL = (selection.endsWith("\n") || selection.endsWith(System.getProperty("line.separator"))); // Some Java versions return the clipboard contents using the native line separator, // so have to convert it here , see jEdit's "registers.java" BufferedReader in = new BufferedReader(new StringReader(selection)); StringBuffer buf = new StringBuffer(); String line; while ((line = in.readLine()) != null) { buf.append(line); buf.append('\n'); } // remove trailing \n if (!trailingEOL) buf.setLength(buf.length() - 1); return buf.toString(); } catch (Exception e) { e.printStackTrace(); return null; } }
public void initGame() { String cfgname = null; if (isApplet()) { cfgname = getParameter("configfile"); } else { JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new File(System.getProperty("user.dir"))); chooser.setDialogTitle("Choose a config file"); int returnVal = chooser.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { cfgname = chooser.getSelectedFile().getAbsolutePath(); } else { System.exit(0); } // XXX read this as resource! // cfgname = "mygeneratedgame.appconfig"; } gamecfg = new AppConfig("Game parameters", this, cfgname); gamecfg.loadFromFile(); gamecfg.defineFields("gp_", "", "", ""); gamecfg.saveToObject(); initMotionPars(); // unpause and copy settingswhen config window is closed gamecfg.setListener( new ActionListener() { public void actionPerformed(ActionEvent e) { start(); requestGameFocus(); initMotionPars(); } }); defineMedia("simplegeneratedgame.tbl"); setFrameRate(35, 1); }
/** * Method performed when button clicked. * * @param event event that triggers action, here clicking of the button. */ public void actionPerformed(ActionEvent event) { if (choiceBox.getSelectedItem().equals(CUSTOM)) { JFileChooser chooser = new JFileChooser(System.getProperty("user.home")); int returnVal = chooser.showOpenDialog(settingsPanel); if (returnVal == JFileChooser.APPROVE_OPTION) { specifiedOntology = CUSTOM; openFile = chooser.getSelectedFile(); choiceBox.setEditable(true); choiceBox.setSelectedItem(openFile.toString()); choiceBox.setEditable(false); def = false; if (((String) choiceBox.getSelectedItem()).endsWith(".obo")) { settingsPanel.getNamespacePanel().choiceBox.setEnabled(true); } else { settingsPanel.getNamespacePanel().choiceBox.setEnabled(false); } } if (returnVal == JFileChooser.CANCEL_OPTION) { choiceBox.setSelectedItem(NONE); specifiedOntology = NONE; def = true; settingsPanel.getNamespacePanel().choiceBox.setEnabled(false); } } else if (choiceBox.getSelectedItem().equals(NONE)) { specifiedOntology = NONE; def = true; settingsPanel.getNamespacePanel().choiceBox.setEnabled(false); } else { specifiedOntology = (String) choiceBox.getSelectedItem(); def = true; settingsPanel.getNamespacePanel().choiceBox.setEnabled(false); } }