private void onOK() { try { InputStream in = new FileInputStream(inputFile); if (outputFile == null) { outputFile = new File(inputFile.getAbsolutePath() + "_"); } OutputStream out = new FileOutputStream(outputFile); ANSIUnicodeConverter converter = new ANSIUnicodeConverter(); converter.setDirection(ANSIUnicodeConverter.ANSI2UNICODE); StringBuffer output = new StringBuffer(); final int BUFFER_SIZE = 1024 * 1024; // 1M byte[] buffer = new byte[BUFFER_SIZE]; int currentPosition = 0; while (in.available() != 0) { int currentBufferSize = BUFFER_SIZE; if (in.available() < BUFFER_SIZE) { currentBufferSize = in.available(); } in.read(buffer, currentPosition, currentBufferSize); currentBufferSize = currentBufferSize + currentBufferSize; converter.setInput(new String(buffer)); out.write(converter.convert().getBytes()); } in.close(); out.close(); } catch (Exception e) { e .printStackTrace(); // To change body of catch statement use File | Settings | File // Templates. } }
public void changeLAF(int iLAFIndex) { try { // Change LAF if (iLAFIndex >= marrLaf.length) iLAFIndex = marrLaf.length - 1; UIManager.setLookAndFeel( (LookAndFeel) Class.forName(marrLaf[iLAFIndex].getClassName()).newInstance()); // Update UI ((JMenuItem) mvtLAFItem.elementAt(iLAFIndex)).setSelected(true); SwingUtilities.updateComponentTreeUI(this); SwingUtilities.updateComponentTreeUI(mnuMain); WindowManager.updateLookAndField(); // Store config try { Hashtable prt = Global.loadHashtable(Global.FILE_CONFIG); prt.put("LAF", String.valueOf(iLAFIndex)); Global.storeHashtable(prt, Global.FILE_CONFIG); } catch (Exception e) { } } catch (Exception e) { e.printStackTrace(); MessageBox.showMessageDialog(this, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE); } }
public void actionPerformed(ActionEvent ev) { try { // stok String query = "DELETE FROM stok_produk WHERE id_produk=" + idProduk; int hasil1 = stm.executeUpdate(query); // pemasukkan query = "DELETE FROM pemasukan WHERE id_produk=" + idProduk; int hasil2 = stm.executeUpdate(query); // pengeluaran query = "DELETE FROM pengeluaran WHERE id_produk=" + idProduk; int hasil3 = stm.executeUpdate(query); // produk query = "DELETE FROM produk WHERE id_produk=" + idProduk; int hasil4 = stm.executeUpdate(query); if (hasil1 == 1 || hasil2 == 1 || hasil3 == 1 && hasil4 == 1) { setDataTabel(); JOptionPane.showMessageDialog(null, "berhasil hapus"); } else { JOptionPane.showMessageDialog(null, "gagal"); } } catch (SQLException SQLerr) { SQLerr.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } }
/** * Calculates location of caret and displays the suggestion popup at the location. * * @param listModel * @param subWord */ protected void showSuggestion(DefaultListModel<CompletionCandidate> listModel, String subWord) { // new Exception(System.currentTimeMillis() + "").printStackTrace(System.out); hideSuggestion(); if (listModel.size() == 0) { Messages.log("TextArea: No suggestions to show."); } else { int position = getCaretPosition(); Point location = new Point(); try { location.x = offsetToX(getCaretLine(), position - getLineStartOffset(getCaretLine())); location.y = lineToY(getCaretLine()) + getPainter().getFontMetrics().getHeight() + getPainter().getFontMetrics().getDescent(); // log("TA position: " + location); } catch (Exception e2) { e2.printStackTrace(); return; } suggestion = new CompletionPanel(this, position, subWord, listModel, location, editor); requestFocusInWindow(); } }
// check if sudo password is correct (so sudo can be used in all other scripts, even without // password, lasts for 5 minutes) private void doSudoCmd() { String pass = passwordField.getText(); File file = null; try { // write file in /tmp file = new File("/tmp/cmd_sudo.sh"); // ""c:/temp/run.bat"" FileOutputStream fos = new FileOutputStream(file); fos.write("echo $password | sudo -S ls\nexit $?".getBytes()); // "echo $password > pipo.txt" fos.close(); // execute HashMap vars = new HashMap(); vars.put("password", pass); List oses = new ArrayList(); oses.add( new OsConstraint( "unix", null, null, null)); // "windows",System.getProperty("os.name"),System.getProperty("os.version"),System.getProperty("os.arch"))); ArrayList plist = new ArrayList(); ParsableFile pf = new ParsableFile(file.getAbsolutePath(), null, null, oses); plist.add(pf); ScriptParser sp = new ScriptParser(plist, new VariableSubstitutor(vars)); sp.parseFiles(); ArrayList elist = new ArrayList(); ExecutableFile ef = new ExecutableFile( file.getAbsolutePath(), ExecutableFile.POSTINSTALL, ExecutableFile.ABORT, oses, false); elist.add(ef); FileExecutor fe = new FileExecutor(elist); int retval = fe.executeFiles(ExecutableFile.POSTINSTALL, this); if (retval == 0) { idata.setVariable("password", pass); isValid = true; } // else is already showing dialog // { // JOptionPane.showMessageDialog(this, "Cannot execute 'sudo' cmd, check your password", // "Error", JOptionPane.ERROR_MESSAGE); // } } catch (Exception e) { // JOptionPane.showMessageDialog(this, "Cannot execute 'sudo' cmd, check your password", // "Error", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); isValid = false; } try { if (file != null && file.exists()) file.delete(); // you don't want the file with password tobe arround, in case of error } catch (Exception e) { // ignore } }
private static void printHelp(OptionParser parser) { try { parser.printHelpOn(System.out); } catch (Exception exception) { exception.printStackTrace(); } }
public DataSourceQueryChooserDialog( Collection dataSourceQueryChoosers, Frame frame, String title, boolean modal) { super(frame, title, modal); init(dataSourceQueryChoosers); try { jbInit(); pack(); } catch (Exception ex) { ex.printStackTrace(); } addComponentListener( new ComponentAdapter() { public void componentShown(ComponentEvent e) { okCancelPanel.setOKPressed(false); } }); addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { // User may have hit OK, got a validation-error dialog, then hit the // X button. [Jon Aquino] okCancelPanel.setOKPressed(false); } }); // Set the selected item to trigger the event that sets the panel. [Jon Aquino] formatComboBox.setSelectedItem(formatComboBox.getItemAt(0)); }
public void run() { try { AudioInputStream ais = AudioSystem.getAudioInputStream(soundFile); AudioFormat format = ais.getFormat(); // System.out.println("Format: " + format); DataLine.Info info = new DataLine.Info(SourceDataLine.class, format); SourceDataLine source = (SourceDataLine) AudioSystem.getLine(info); source.open(format); source.start(); int read = 0; byte[] audioData = new byte[16384]; while (read > -1) { read = ais.read(audioData, 0, audioData.length); if (read >= 0) { source.write(audioData, 0, read); } } donePlaying = true; source.drain(); source.close(); } catch (Exception exc) { System.out.println("error: " + exc.getMessage()); exc.printStackTrace(); } }
public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (command.equals("AddPersonnel")) { AddNewPersonnel(); } if (command.equals("RemovePersonnel")) {} if (command.equals("RandomName")) { SetRandomName(); } if (command.equalsIgnoreCase("AssetAssignment")) { PersonnelAssetAssignmentDialog dlg = new PersonnelAssetAssignmentDialog(_CurrentPersonnel.getName(), _Unit); dlg.setLocationRelativeTo(this); dlg.setModal(true); dlg.setVisible(true); if (dlg.wasAssetAssigned()) { try { UnitManager.getInstance().saveUnit(_Unit); SetFields(); } catch (Exception ex) { ex.printStackTrace(); } } } }
/** * store BufferedImage to file * * @param image BufferedImage * @param outputFile output image file * @param quality quality of output image * @return true success, else fail */ public static boolean storeImage(BufferedImage image, File outputFile, float quality) { try { // reconstruct folder structure for image file output if (outputFile.getParentFile() != null && !outputFile.getParentFile().exists()) { outputFile.getParentFile().mkdirs(); } if (outputFile.exists()) { outputFile.delete(); } // get image file suffix String extName = "gif"; // get registry ImageWriter for specified image suffix Iterator writers = ImageIO.getImageWritersByFormatName(extName); ImageWriter imageWriter = (ImageWriter) writers.next(); // set image output params ImageWriteParam params = new JPEGImageWriteParam(null); params.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); params.setCompressionQuality(quality); params.setProgressiveMode(javax.imageio.ImageWriteParam.MODE_DISABLED); params.setDestinationType( new ImageTypeSpecifier( IndexColorModel.getRGBdefault(), IndexColorModel.getRGBdefault().createCompatibleSampleModel(16, 16))); // writer image to file ImageOutputStream imageOutputStream = ImageIO.createImageOutputStream(outputFile); imageWriter.setOutput(imageOutputStream); imageWriter.write(null, new IIOImage(image, null, null), params); imageOutputStream.close(); imageWriter.dispose(); return true; } catch (Exception e) { e.printStackTrace(); } return false; }
/** * Implement the interface for validating and converting to internal object. Null is a valid * successful return, so errors are indicated only by existance or not of a message in the * messageBuffer. */ public Object validateAndConvert(String value, Object originalValue, StringBuffer messageBuffer) { // handle null, which is shown as the special string "<null>" if (value.equals("<null>") || value.equals("")) return null; // Do the conversion into the object in a safe manner try { if (useJavaDefaultFormat) { // allow the user to enter just the hour or just hour and minute // and assume the un-entered values are 0 int firstColon = value.indexOf(":"); if (firstColon == -1) { // user just entered the hour, so append min & sec value = value + ":0:0"; } else { // user entered hour an min. See if they also entered secs if (value.indexOf(":", firstColon + 1) == -1) { // user did not enter seconds value = value + ":0"; } } Object obj = Time.valueOf(value); return obj; } else { // use the DateFormat to parse java.util.Date javaDate = dateFormat.parse(value); return new Time(javaDate.getTime()); } } catch (Exception e) { messageBuffer.append(e.toString() + "\n"); // ?? do we need the message also, or is it automatically part of the toString()? // messageBuffer.append(e.getMessage()); return null; } }
public Test() { try { jbInit(); } catch (Exception e) { e.printStackTrace(); } }
private VirtualMachine connect(String bndlPrefix, AttachingConnector connector, Map args) throws DebuggerException { if (bndlPrefix != null) { if (connector.transport().name().equals("dt_shmem")) { Argument a = (Argument) args.get("name"); if (a == null) println(bundle.getString(bndlPrefix + "_shmem_noargs"), ERR_OUT); else println( new MessageFormat(bundle.getString(bndlPrefix + "_shmem")) .format(new Object[] {a.value()}), ERR_OUT); } else if (connector.transport().name().equals("dt_socket")) { Argument name = (Argument) args.get("hostname"); Argument port = (Argument) args.get("port"); if ((name == null) || (port == null)) println(bundle.getString(bndlPrefix + "_socket_noargs"), ERR_OUT); else println( new MessageFormat(bundle.getString(bndlPrefix + "_socket")) .format(new Object[] {name.value(), port.value()}), ERR_OUT); } else println(bundle.getString(bndlPrefix), ERR_OUT); } // launch VM try { // S ystem.out.println ("attach to:" + ac + " : " + password); // NOI18N return connector.attach(args); } catch (Exception e) { finishDebugger(); throw new DebuggerException( new MessageFormat(bundle.getString("EXC_While_connecting_to_debuggee")) .format(new Object[] {e.toString()}), e); } }
// public void savePDF(){ // Rectangle suggestedPageSize = getITextPageSize(page1.getPageSize()); // Rectangle pageSize = rotatePageIfNecessary(suggestedPageSize); // //rotate if we need landscape // Document document = new Document(pageSize); // // PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(outputFile)); // document.open(); // Graphics2D graphics = cb.createGraphics(pageSize.getWidth(), pageSize.getHeight()); // // // call your GTRenderer here // GTRenderer draw = new StreamingRenderer(); // draw.setMapContent(mapContent); // // draw.paint(graphics, outputArea, mapContent.getLayerBounds() ); // // // cleanup // graphics.dispose(); // // //cleanup // document.close(); // writer.close(); // } public void saveImage(final MapContent map, final String file, final int imageWidth) { GTRenderer renderer = new StreamingRenderer(); renderer.setMapContent(map); Rectangle imageBounds = null; ReferencedEnvelope mapBounds = null; try { mapBounds = map.getMaxBounds(); double heightToWidth = mapBounds.getSpan(1) / mapBounds.getSpan(0); imageBounds = new Rectangle(0, 0, imageWidth, (int) Math.round(imageWidth * heightToWidth)); } catch (Exception e) { // failed to access mapContent layers throw new RuntimeException(e); } BufferedImage image = new BufferedImage(imageBounds.width, imageBounds.height, BufferedImage.TYPE_INT_RGB); Graphics2D gr = image.createGraphics(); gr.setPaint(Color.WHITE); gr.fill(imageBounds); try { renderer.paint(gr, imageBounds, mapBounds); File fileToSave = new File(file); ImageIO.write(image, "jpeg", fileToSave); } catch (Exception e) { e.printStackTrace(); } }
public void actionPerformed(ActionEvent evt) { // 删除原来的JTable(JTable使用scrollPane来包装) if (scrollPane != null) { jf.remove(scrollPane); } try ( // 根据用户输入的SQL执行查询 ResultSet rs = stmt.executeQuery(sqlField.getText())) { // 取出ResultSet的MetaData ResultSetMetaData rsmd = rs.getMetaData(); Vector<String> columnNames = new Vector<>(); Vector<Vector<String>> data = new Vector<>(); // 把ResultSet的所有列名添加到Vector里 for (int i = 0; i < rsmd.getColumnCount(); i++) { columnNames.add(rsmd.getColumnName(i + 1)); } // 把ResultSet的所有记录添加到Vector里 while (rs.next()) { Vector<String> v = new Vector<>(); for (int i = 0; i < rsmd.getColumnCount(); i++) { v.add(rs.getString(i + 1)); } data.add(v); } // 创建新的JTable JTable table = new JTable(data, columnNames); scrollPane = new JScrollPane(table); // 添加新的Table jf.add(scrollPane); // 更新主窗口 jf.validate(); } catch (Exception e) { e.printStackTrace(); } }
// 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; } }
/** Creates new form SIPHeadersParametersFrame */ public StackPanel(ConfigurationFrame configurationFrame, ProxyLauncher proxyLauncher) { super(); this.parent = configurationFrame; this.proxyLauncher = proxyLauncher; listeningPointsList = new ListeningPointsList(proxyLauncher); initComponents(); // Init the components input: try { Configuration configuration = proxyLauncher.getConfiguration(); if (configuration == null) return; if (configuration.stackName != null) proxyStackNameTextField.setText(configuration.stackName); if (configuration.stackIPAddress != null) proxyIPAddressTextField.setText(configuration.stackIPAddress); if (configuration.outboundProxy != null) outboundProxyTextField.setText(configuration.outboundProxy); if (configuration.routerPath != null) routerClassTextField.setText(configuration.routerPath); if (configuration == null) listeningPointsList.displayList(new Hashtable()); else listeningPointsList.displayList(configuration.listeningPoints); } catch (Exception e) { e.printStackTrace(); } }
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()); } }
/** i_square,resultの有効期間は、この関数の終了までです。 */ protected void onUpdateHandler(NyARSquare i_square, NyARDoubleMatrix44 result) { try { NyARGLUtil.toCameraViewRH(result, 1.0, this.gltransmat); } catch (Exception e) { e.printStackTrace(); } }
private Hashtable<String, String> getJarManifestAttributes(String path) { Hashtable<String, String> h = new Hashtable<String, String>(); JarInputStream jis = null; try { cp.appendln(Color.black, "Looking for " + path); InputStream is = getClass().getResourceAsStream(path); if (is == null) { if (!path.endsWith("/MIRC.jar")) { cp.appendln(Color.red, "...could not find it."); } else { cp.appendln( Color.black, "...could not find it. [OK, this is a " + programName + " installation]"); } return null; } jis = new JarInputStream(is); Manifest manifest = jis.getManifest(); h = getManifestAttributes(manifest); } catch (Exception ex) { ex.printStackTrace(); } if (jis != null) { try { jis.close(); } catch (Exception ignore) { } } return h; }
public void run() { try { if (myPreviousThread != null) myPreviousThread.join(); Thread.sleep(delay); log("> run MouseMoveThread " + x + ", " + y); while (!hasFocus()) { Thread.sleep(1000); } int x1 = lastMouseX; int x2 = x; int y1 = lastMouseY; int y2 = y; // shrink range by 1 px on both ends // manually move this 1px to trip DND code if (x1 != x2) { int dx = x - lastMouseX; if (dx > 0) { x1 += 1; x2 -= 1; } else { x1 -= 1; x2 += 1; } } if (y1 != y2) { int dy = y - lastMouseY; if (dy > 0) { y1 += 1; y2 -= 1; } else { y1 -= 1; y2 += 1; } } robot.setAutoDelay(Math.max(duration / 100, 1)); robot.mouseMove(x1, y1); int d = 100; for (int t = 0; t <= d; t++) { x1 = (int) easeInOutQuad( (double) t, (double) lastMouseX, (double) x2 - lastMouseX, (double) d); y1 = (int) easeInOutQuad( (double) t, (double) lastMouseY, (double) y2 - lastMouseY, (double) d); robot.mouseMove(x1, y1); } robot.mouseMove(x, y); lastMouseX = x; lastMouseY = y; robot.waitForIdle(); robot.setAutoDelay(1); } catch (Exception e) { log("Bad parameters passed to mouseMove"); e.printStackTrace(); } log("< run MouseMoveThread"); }
public void setQuery(String q) { cache = new Vector(); try { ResultSet rs = statement.executeQuery(q); ResultSetMetaData meta = rs.getMetaData(); colCount = meta.getColumnCount(); headers = new String[colCount]; for (int h = 1; h <= colCount; h++) { headers[h - 1] = meta.getColumnName(h); } while (rs.next()) { String[] record = new String[colCount]; for (int i = 0; i < colCount; i++) { record[i] = rs.getString(i + 1); } cache.addElement(record); } // while sonu fireTableChanged(null); } // try sonu catch (Exception e) { cache = new Vector(); e.printStackTrace(); } } // setQuery sonu
public void mouseClicked(MouseEvent e) { int x = e.getX(); int y = e.getY(); int currentTabIndex = -1; int tabCount = tabPane.getTabCount(); for (int i = 0; i < tabCount; i++) { if (rects[i].contains(x, y)) { currentTabIndex = i; break; } // if contains } // for i if (currentTabIndex >= 0) { Rectangle tabRect = rects[currentTabIndex]; x = x - tabRect.x; y = y - tabRect.y; if ((x >= 5) && (x <= 15) && (y >= 5) && (y <= 15)) { try { tabbedPane.remove(currentTabIndex); } catch (Exception ex) { ex.printStackTrace(); } } // if } // if currentTabIndex >= 0 System.gc(); } // mouseClicked
private void updateTabBar(Vector vtThread) { pnlThread.removeAll(); for (int iThreadIndex = 0; iThreadIndex < vtThread.size(); iThreadIndex++) { try { Vector vtThreadInfo = (Vector) vtThread.elementAt(iThreadIndex); PanelThreadMonitor mntTemp = new PanelThreadMonitor(channel); String strThreadID = (String) vtThreadInfo.elementAt(0); String strThreadName = (String) vtThreadInfo.elementAt(1); int iThreadStatus = Integer.parseInt((String) vtThreadInfo.elementAt(2)); mntTemp.setThreadID(strThreadID); mntTemp.setThreadName(strThreadName); mntTemp.setThreadStatus(iThreadStatus); showResult(mntTemp.txtMonitor, (String) vtThreadInfo.elementAt(3)); mntTemp.addPropertyChangeListener(this); pnlThread.add(strThreadName, mntTemp); mntTemp.updateStatus(); } catch (Exception e) { e.printStackTrace(); MessageBox.showMessageDialog(this, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE); } } Skin.applySkin(this); }
protected void buildPanel(String strPath) { BufferedReader reader = WFileUtil.openReadFile(strPath); String strLine; if (reader == null) return; try { while ((strLine = reader.readLine()) != null) { if (strLine.startsWith("#") || strLine.startsWith("%") || strLine.startsWith("@")) continue; StringTokenizer sTokLine = new StringTokenizer(strLine, ":"); // first token is the label e.g. Password Length if (sTokLine.hasMoreTokens()) { createLabel(sTokLine.nextToken(), this); } // second token is the value String strValue = sTokLine.hasMoreTokens() ? sTokLine.nextToken() : ""; if (strValue.equalsIgnoreCase("yes") || strValue.equalsIgnoreCase("no")) createChkBox(strValue, this); else createTxf(strValue, this); } } catch (Exception e) { Messages.writeStackTrace(e); // e.printStackTrace(); Messages.postDebug(e.toString()); } }
public UserDataTabPanel() { try { jbInit(); } catch (Exception ex) { ex.printStackTrace(); } }
public JournalFilterFrame() { try { jbInit(); // set domain in combo box... ClientApplet applet = ((ApplicationClientFacade) MDIFrame.getInstance().getClientFacade()).getMainClass(); ButtonCompanyAuthorizations bca = applet.getAuthorizations().getCompanyBa(); ArrayList companiesList = bca.getCompaniesList("ACC05"); Domain domain = new Domain("DOMAIN_ACC05"); for (int i = 0; i < companiesList.size(); i++) { if (applet .getAuthorizations() .getCompanyBa() .isInsertEnabled("ACC05", companiesList.get(i).toString())) domain.addDomainPair(companiesList.get(i), companiesList.get(i).toString()); } controlCompaniesCombo.setDomain(domain); controlCompaniesCombo.getComboBox().setSelectedIndex(0); setSize(400, 200); MDIFrame.getInstance().add(this); } catch (Exception e) { e.printStackTrace(); } }
public void actionPerformed(ActionEvent ae) { String cname = nameF.getText().trim(); int state = conditions[stateC.getSelectedIndex()]; try { if (isSpecialCase(cname)) { handleSpecialCase(cname, state); } else { JComponent comp = (JComponent) Class.forName(cname).newInstance(); ComponentUI cui = UIManager.getUI(comp); cui.installUI(comp); results.setText("Map entries for " + cname + ":\n\n"); if (inputB.isSelected()) { loadInputMap(comp.getInputMap(state), ""); results.append("\n"); } if (actionB.isSelected()) { loadActionMap(comp.getActionMap(), ""); results.append("\n"); } if (bindingB.isSelected()) { loadBindingMap(comp, state); } } } catch (ClassCastException cce) { results.setText(cname + " is not a subclass of JComponent."); } catch (ClassNotFoundException cnfe) { results.setText(cname + " was not found."); } catch (InstantiationException ie) { results.setText(cname + " could not be instantiated."); } catch (Exception e) { results.setText("Exception found:\n" + e); e.printStackTrace(); } }
/** * The method to invoke the application. * * @param arg a list of DICOM files which may contain chest x-ray images */ public static void main(String arg[]) { try { new ChestImageViewer(arg); } catch (Exception e) { e.printStackTrace(System.err); } }
public RasterShieldFrame() { try { init(); } catch (Exception e) { e.printStackTrace(); } }