List of usage examples for javax.swing ImageIcon getImage
@Transient
public Image getImage()
Image
. From source file:org.mili.core.graphics.GraphicsUtil.java
/** * Scales an image.//from w w w . j av a2 s .co m * * @param i image. * @param scaleX scale to x >= 0. * @param scaleY scale to y >= 0. * @return scaled image. */ public static Image scaleImage(Image i, int scaleX, int scaleY) { Validate.notNull(i, "image cannot be null!"); Validate.isTrue(scaleX >= 0, "scaleX cannot be < 0!"); Validate.isTrue(scaleY >= 0, "scaleY cannot be < 0!"); if (scaleX == 0 && scaleY == 0) { return i; } double f = getRelationFactor(scaleX, scaleY, i); int x = (int) (i.getWidth(null) * f); int y = (int) (i.getHeight(null) * f); i = i.getScaledInstance(x, y, Image.SCALE_SMOOTH); ImageIcon ii = new ImageIcon(i); i = ii.getImage(); if (i instanceof ToolkitImage) { ToolkitImage ti = (ToolkitImage) i; i = ti.getBufferedImage(); } return i; }
From source file:org.mskcc.pathdb.action.web_api.NeighborhoodMapRetriever.java
/** * Writes no neighbors found image to response. * * @param icon imageIcon/*from w ww .j a va 2s. c o m*/ * @param response HttpServletResponse * @throws IOException */ private void writeMapToResponse(ImageIcon icon, HttpServletResponse response) throws IOException { log.info("NeighborhoodMapRetriever.writeMapToResponse"); // create buffered image final BufferedImage image = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_RGB); final Graphics2D g2d = image.createGraphics(); g2d.drawImage(icon.getImage(), 0, 0, WIDTH, HEIGHT, null); g2d.dispose(); // write out the image bytes response.setContentType("image/png"); CONTENT_TYPE_SET = true; ImageIO.write(image, "png", response.getOutputStream()); }
From source file:org.opendatakit.appengine.updater.UpdaterWindow.java
/** * Launch the application.// www . j a v a 2 s .c om */ public static void main(String[] args) { translations = ResourceBundle.getBundle(TranslatedStrings.class.getCanonicalName(), Locale.getDefault()); Options options = addOptions(); // get location of this jar String reflectedJarPath = UpdaterWindow.class.getProtectionDomain().getCodeSource().getLocation().getFile(); // remove %20 substitutions. reflectedJarPath = reflectedJarPath.replace("%20", " "); File myJar = new File(reflectedJarPath, Preferences.JAR_NAME); System.out.println("CodeSource Location: " + myJar.getAbsolutePath()); File cleanJarPath = null; if (myJar.exists()) { try { cleanJarPath = myJar.getCanonicalFile(); } catch (Throwable t) { t.printStackTrace(); } } if (cleanJarPath == null) { // try finding this within our working directory String dir = System.getProperty("user.dir"); if (dir != null) { File myWD = new File(dir); if (myWD.exists()) { myJar = new File(myWD, Preferences.JAR_NAME); System.out.println("user.dir path: " + myJar.getAbsolutePath()); if (myJar.exists()) { try { cleanJarPath = myJar.getCanonicalFile(); } catch (Throwable t) { t.printStackTrace(); } } } } } if (cleanJarPath != null) { myJarDir = cleanJarPath.getParentFile(); System.out.println(fmt(TranslatedStrings.DIR_RUNNABLE_JAR, myJarDir.getAbsolutePath())); } else { myJarDir = null; } CommandLineParser parser = new DefaultParser(); final CommandLine cmdArgs; try { cmdArgs = parser.parse(options, args); } catch (ParseException e1) { System.out.println(fmt(TranslatedStrings.LAUNCH_FAILED, e1.getMessage())); showHelp(options); System.exit(1); return; } if (cmdArgs.hasOption(ArgumentNameConstants.HELP)) { showHelp(options); System.exit(0); return; } if (cmdArgs.hasOption(ArgumentNameConstants.VERSION)) { showVersion(); System.exit(0); return; } if (myJarDir == null && !cmdArgs.hasOption(ArgumentNameConstants.INSTALL_ROOT)) { System.out.println(fmt(TranslatedStrings.INSTALL_ROOT_REQUIRED, Preferences.JAR_NAME, ArgumentNameConstants.INSTALL_ROOT)); showHelp(options); System.exit(1); return; } // required for all operations if (cmdArgs.hasOption(ArgumentNameConstants.NO_UI) && !cmdArgs.hasOption(ArgumentNameConstants.EMAIL)) { System.out.println(fmt(TranslatedStrings.ARG_IS_REQUIRED, ArgumentNameConstants.EMAIL)); showHelp(options); System.exit(1); return; } // update appEngine with the local configuration if (cmdArgs.hasOption(ArgumentNameConstants.UPLOAD)) { if (cmdArgs.hasOption(ArgumentNameConstants.CLEAR)) { System.out.println(fmt(TranslatedStrings.CONFLICTING_ARGS_CMD, ArgumentNameConstants.UPLOAD, ArgumentNameConstants.CLEAR)); } if (cmdArgs.hasOption(ArgumentNameConstants.ROLLBACK)) { System.out.println(fmt(TranslatedStrings.CONFLICTING_ARGS_CMD, ArgumentNameConstants.UPLOAD, ArgumentNameConstants.ROLLBACK)); } if (!cmdArgs.hasOption(ArgumentNameConstants.EMAIL)) { System.out.println(fmt(TranslatedStrings.ARG_IS_REQUIRED_CMD, ArgumentNameConstants.EMAIL)); } showHelp(options); System.exit(1); return; } // rollback any stuck outstanding configuration transaction on appEngine infrastructure if (cmdArgs.hasOption(ArgumentNameConstants.ROLLBACK)) { if (cmdArgs.hasOption(ArgumentNameConstants.CLEAR)) { System.out.println(fmt(TranslatedStrings.CONFLICTING_ARGS_CMD, ArgumentNameConstants.ROLLBACK, ArgumentNameConstants.CLEAR)); } if (cmdArgs.hasOption(ArgumentNameConstants.UPLOAD)) { System.out.println(fmt(TranslatedStrings.CONFLICTING_ARGS_CMD, ArgumentNameConstants.ROLLBACK, ArgumentNameConstants.UPLOAD)); } if (!cmdArgs.hasOption(ArgumentNameConstants.EMAIL)) { System.out.println(fmt(TranslatedStrings.ARG_IS_REQUIRED_CMD, ArgumentNameConstants.EMAIL)); } showHelp(options); System.exit(1); return; } if (cmdArgs.hasOption(ArgumentNameConstants.CLEAR)) { if (cmdArgs.hasOption(ArgumentNameConstants.ROLLBACK)) { System.out.println(fmt(TranslatedStrings.CONFLICTING_ARGS_CMD, ArgumentNameConstants.CLEAR, ArgumentNameConstants.ROLLBACK)); } if (cmdArgs.hasOption(ArgumentNameConstants.UPLOAD)) { System.out.println(fmt(TranslatedStrings.CONFLICTING_ARGS_CMD, ArgumentNameConstants.CLEAR, ArgumentNameConstants.UPLOAD)); } showHelp(options); System.exit(1); return; } if (!cmdArgs.hasOption(ArgumentNameConstants.NO_UI)) { EventQueue.invokeLater(new Runnable() { public void run() { try { // Set System L&F UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); UpdaterWindow window = new UpdaterWindow(cmdArgs); window.frame.setTitle(fmt(TranslatedStrings.AGG_INSTALLER_VERSION, Preferences.VERSION)); ImageIcon icon = new ImageIcon( UpdaterWindow.class.getClassLoader().getResource("odkupdater.png")); window.frame.setIconImage(icon.getImage()); window.frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } else { try { UpdaterCLI aggregateInstallerCLI = new UpdaterCLI(cmdArgs); aggregateInstallerCLI.run(); } catch (Exception e) { e.printStackTrace(); } } }
From source file:org.opendatakit.briefcase.ui.MainBriefcaseWindow.java
/** * Launch the application.//from w ww . ja v a 2s .co m */ public static void main(String[] args) { if (args.length == 0) { EventQueue.invokeLater(new Runnable() { public void run() { try { // Set System L&F UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); MainBriefcaseWindow window = new MainBriefcaseWindow(); window.frame.setTitle(BRIEFCASE_VERSION); ImageIcon icon = new ImageIcon( MainBriefcaseWindow.class.getClassLoader().getResource("odk_logo.png")); window.frame.setIconImage(icon.getImage()); window.frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } else { Options options = addOptions(); CommandLineParser parser = new BasicParser(); CommandLine cmd = null; try { cmd = parser.parse(options, args); } catch (ParseException e1) { log.error("Launch Failed: " + e1.getMessage()); showHelp(options); System.exit(1); } if (cmd.hasOption(HELP)) { showHelp(options); System.exit(1); } if (cmd.hasOption(VERSION)) { showVersion(); System.exit(1); } // required for all operations if (!cmd.hasOption(FORM_ID) || !cmd.hasOption(STORAGE_DIRECTORY)) { log.error(FORM_ID + " and " + STORAGE_DIRECTORY + " are required"); showHelp(options); System.exit(1); } // pull from collect or aggregate, not both if (cmd.hasOption(ODK_DIR) && cmd.hasOption(AGGREGATE_URL)) { log.error("Can only have one of " + ODK_DIR + " or " + AGGREGATE_URL); showHelp(options); System.exit(1); } // pull from aggregate if (cmd.hasOption(AGGREGATE_URL) && (!(cmd.hasOption(ODK_USERNAME) && cmd.hasOption(ODK_PASSWORD)))) { log.error(ODK_USERNAME + " and " + ODK_PASSWORD + " required when " + AGGREGATE_URL + " is specified"); showHelp(options); System.exit(1); } // export files if (cmd.hasOption(EXPORT_DIRECTORY) && !cmd.hasOption(EXPORT_FILENAME) || !cmd.hasOption(EXPORT_DIRECTORY) && cmd.hasOption(EXPORT_FILENAME)) { log.error(EXPORT_DIRECTORY + " and " + EXPORT_FILENAME + " are both required to export"); showHelp(options); System.exit(1); } if (cmd.hasOption(EXPORT_END_DATE)) { if (!testDateFormat(cmd.getOptionValue(EXPORT_END_DATE))) { log.error("Invalid date format in " + EXPORT_END_DATE); showHelp(options); System.exit(1); } } if (cmd.hasOption(EXPORT_START_DATE)) { if (!testDateFormat(cmd.getOptionValue(EXPORT_START_DATE))) { log.error("Invalid date format in " + EXPORT_START_DATE); showHelp(options); System.exit(1); } } BriefcaseCLI bcli = new BriefcaseCLI(cmd); bcli.run(); } }
From source file:org.opendatakit.briefcase.ui.MainFormUploaderWindow.java
/** * Launch the application.// www .ja v a2s. com */ public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { // Set System L&F UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); MainFormUploaderWindow window = new MainFormUploaderWindow(); window.frame.setTitle(FORM_UPLOADER_VERSION); ImageIcon icon = new ImageIcon( MainFormUploaderWindow.class.getClassLoader().getResource("odk_logo.png")); window.frame.setIconImage(icon.getImage()); window.frame.setVisible(true); } catch (Exception e) { log.error("failed to launch app", e); } } }); }
From source file:org.openmicroscopy.shoola.agents.imviewer.view.ImViewerUI.java
/** * Links this View to its Controller and Model. * /* w w w .j av a2 s . c o m*/ * @param controller Reference to the Control. * Mustn't be <code>null</code>. * @param model Reference to the Model. * Mustn't be <code>null</code>. */ void initialize(ImViewerControl controller, ImViewerModel model) { if (controller == null) throw new NullPointerException("No control."); if (model == null) throw new NullPointerException("No model."); this.controller = controller; this.model = model; toolBar = new ToolBar(this, controller); controlPane = new ControlPane(controller, model, this); statusBar = new StatusBar(model, this); initSplitPanes(); refInsets = rendererSplit.getInsets(); planes = new HashMap<Integer, PlaneInfoComponent>(); ImageIcon icon = IconManager.getInstance().getImageIcon(IconManager.VIEWER); if (icon != null) setIconImage(icon.getImage()); setName("image viewer window"); }
From source file:org.openscience.jmol.app.Jmol.java
Jmol(Splash splash, JFrame frame, Jmol parent, int startupWidth, int startupHeight, String commandOptions, Point loc) {/*from w w w . j av a 2 s. com*/ super(true); this.frame = frame; this.startupWidth = startupWidth; this.startupHeight = startupHeight; numWindows++; try { say("history file is " + historyFile.getFile().getAbsolutePath()); } catch (Exception e) { } frame.setTitle("Jmol"); frame.getContentPane().setBackground(Color.lightGray); frame.getContentPane().setLayout(new BorderLayout()); this.splash = splash; setBorder(BorderFactory.createEtchedBorder()); setLayout(new BorderLayout()); language = GT.getLanguage(); status = (StatusBar) createStatusBar(); say(GT._("Initializing 3D display...")); // display = new DisplayPanel(status, guimap, haveDisplay.booleanValue(), startupWidth, startupHeight); String adapter = System.getProperty("model"); if (adapter == null || adapter.length() == 0) adapter = "smarter"; if (adapter.equals("smarter")) { report("using Smarter Model Adapter"); modelAdapter = new SmarterJmolAdapter(); } else if (adapter.equals("cdk")) { report("the CDK Model Adapter is currently no longer supported. Check out http://bioclipse.net/. -- using Smarter"); // modelAdapter = new CdkJmolAdapter(null); modelAdapter = new SmarterJmolAdapter(); } else { report("unrecognized model adapter:" + adapter + " -- using Smarter"); modelAdapter = new SmarterJmolAdapter(); } appletContext = commandOptions; viewer = JmolViewer.allocateViewer(display, modelAdapter); viewer.setAppletContext("", null, null, commandOptions); if (display != null) display.setViewer(viewer); say(GT._("Initializing Preferences...")); preferencesDialog = new PreferencesDialog(frame, guimap, viewer); say(GT._("Initializing Recent Files...")); recentFiles = new RecentFilesDialog(frame); if (haveDisplay.booleanValue()) { say(GT._("Initializing Script Window...")); scriptWindow = new ScriptWindow(viewer, frame); } MyStatusListener myStatusListener; myStatusListener = new MyStatusListener(); viewer.setJmolStatusListener(myStatusListener); say(GT._("Initializing Measurements...")); measurementTable = new MeasurementTable(viewer, frame); // Setup Plugin system // say(GT._("Loading plugins...")); // pluginManager = new CDKPluginManager( // System.getProperty("user.home") + System.getProperty("file.separator") // + ".jmol", new JmolEditBus(viewer) // ); // pluginManager.loadPlugin("org.openscience.cdkplugin.dirbrowser.DirBrowserPlugin"); // pluginManager.loadPlugin("org.openscience.cdkplugin.dirbrowser.DadmlBrowserPlugin"); // pluginManager.loadPlugins( // System.getProperty("user.home") + System.getProperty("file.separator") // + ".jmol/plugins" // ); // feature to allow for globally installed plugins // if (System.getProperty("plugin.dir") != null) { // pluginManager.loadPlugins(System.getProperty("plugin.dir")); // } if (haveDisplay.booleanValue()) { // install the command table say(GT._("Building Command Hooks...")); commands = new Hashtable(); if (display != null) { Action[] actions = getActions(); for (int i = 0; i < actions.length; i++) { Action a = actions[i]; commands.put(a.getValue(Action.NAME), a); } } menuItems = new Hashtable(); say(GT._("Building Menubar...")); executeScriptAction = new ExecuteScriptAction(); menubar = createMenubar(); add("North", menubar); JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.add("North", createToolbar()); JPanel ip = new JPanel(); ip.setLayout(new BorderLayout()); ip.add("Center", display); panel.add("Center", ip); add("Center", panel); add("South", status); say(GT._("Starting display...")); display.start(); //say(GT._("Setting up File Choosers...")); /* pcs.addPropertyChangeListener(chemFileProperty, exportAction); pcs.addPropertyChangeListener(chemFileProperty, povrayAction); pcs.addPropertyChangeListener(chemFileProperty, writeAction); pcs.addPropertyChangeListener(chemFileProperty, toWebAction); pcs.addPropertyChangeListener(chemFileProperty, printAction); pcs.addPropertyChangeListener(chemFileProperty, viewMeasurementTableAction); */ if (menuFile != null) { menuStructure = viewer.getFileAsString(menuFile); } jmolpopup = JmolPopup.newJmolPopup(viewer, true, menuStructure, true); } // prevent new Jmol from covering old Jmol if (loc != null) { frame.setLocation(loc); } else if (parent != null) { Point location = parent.frame.getLocationOnScreen(); int maxX = screenSize.width - 50; int maxY = screenSize.height - 50; location.x += 40; location.y += 40; if ((location.x > maxX) || (location.y > maxY)) { location.setLocation(0, 0); } frame.setLocation(location); } frame.getContentPane().add("Center", this); frame.addWindowListener(new Jmol.AppCloser()); frame.pack(); frame.setSize(startupWidth, startupHeight); ImageIcon jmolIcon = JmolResourceHandler.getIconX("icon"); Image iconImage = jmolIcon.getImage(); frame.setIconImage(iconImage); // Repositionning windows if (scriptWindow != null) historyFile.repositionWindow(SCRIPT_WINDOW_NAME, scriptWindow, 200, 100); say(GT._("Setting up Drag-and-Drop...")); FileDropper dropper = new FileDropper(); final JFrame f = frame; dropper.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { //System.out.println("Drop triggered..."); f.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); if (evt.getPropertyName().equals(FileDropper.FD_PROPERTY_FILENAME)) { final String filename = evt.getNewValue().toString(); viewer.openFile(filename); } else if (evt.getPropertyName().equals(FileDropper.FD_PROPERTY_INLINE)) { final String inline = evt.getNewValue().toString(); viewer.openStringInline(inline); } f.setCursor(Cursor.getDefaultCursor()); } }); this.setDropTarget(new DropTarget(this, dropper)); this.setEnabled(true); say(GT._("Launching main frame...")); }
From source file:org.openstreetmap.josm.tools.ImageProvider.java
public static Cursor getCursor(String name, String overlay) { ImageIcon img = get("cursor", name); if (overlay != null) { img = overlay(img, ImageProvider.get("cursor/modifier/" + overlay), OverlayPosition.SOUTHEAST); }/*w w w .j av a 2 s .c o m*/ Cursor c = Toolkit.getDefaultToolkit().createCustomCursor(img.getImage(), name.equals("crosshair") ? new Point(10, 10) : new Point(3, 2), "Cursor"); return c; }
From source file:org.openuat.apps.BedaApp.java
/** * Creates a new instance of this class and launches the * actual application./*from w w w.j a v a 2 s. co m*/ */ public BedaApp() { random = new SecureRandom(); devices = new RemoteDevice[0]; currentPeerUrl = null; currentChannel = null; isInitiator = false; // Initialize the logger. Use a wrapper around the log4j framework. /*LogFactory.init(new Log4jFactory()); logger = LogFactory.getLogger(BedaApp.class.getName()); logger.finer("Logger initiated!");*/ mainWindow = new JFrame("Beda App"); mainWindow.setSize(new Dimension(FRAME_WIDTH, FRAME_HIGHT)); mainWindow.setPreferredSize(new Dimension(FRAME_WIDTH, FRAME_HIGHT)); mainWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); mainWindow.getContentPane().setLayout(new FlowLayout()); URL imgURL = getClass().getResource("/resources/Button_Icon_Blue_beda.png"); ImageIcon icon = imgURL != null ? new ImageIcon(imgURL) : new ImageIcon("resources/Button_Icon_Blue_beda.png"); mainWindow.setIconImage(icon.getImage()); // prepare the button channels ActionListener abortHandler = new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getID() == ActionEvent.ACTION_PERFORMED) { logger.warning("Protocol run aborted by user"); BluetoothRFCOMMChannel.shutdownAllChannels(); alertError("Protocol run aborted."); } } }; buttonChannels = new HashMap<String, OOBChannel>(); ButtonChannelImpl impl = new AWTButtonChannelImpl(mainWindow.getContentPane(), abortHandler); OOBChannel c = new ButtonToButtonChannel(impl); buttonChannels.put(c.toString(), c); c = new FlashDisplayToButtonChannel(impl, false); buttonChannels.put(c.toString(), c); c = new TrafficLightToButtonChannel(impl); buttonChannels.put(c.toString(), c); c = new ProgressBarToButtonChannel(impl); buttonChannels.put(c.toString(), c); c = new PowerBarToButtonChannel(impl); buttonChannels.put(c.toString(), c); c = new ShortVibrationToButtonChannel(impl); buttonChannels.put(c.toString(), c); c = new LongVibrationToButtonChannel(impl); buttonChannels.put(c.toString(), c); // set up the menu bar menuBar = new JMenuBar(); JMenu menu = new JMenu("Menu"); final JMenuItem homeEntry = new JMenuItem("Home"); final JMenuItem testEntry = new JMenuItem("Test channels"); ActionListener menuListener = new ActionListener() { @Override public void actionPerformed(ActionEvent event) { JMenuItem menuItem = (JMenuItem) event.getSource(); if (menuItem == homeEntry) { showHomeScreen(); } else if (menuItem == testEntry) { showTestScreen(); } } }; homeEntry.addActionListener(menuListener); testEntry.addActionListener(menuListener); menu.add(homeEntry); menu.add(testEntry); menuBar.add(menu); mainWindow.setJMenuBar(menuBar); // set up channel list OOBChannel[] channels = { new ButtonToButtonChannel(impl), new FlashDisplayToButtonChannel(impl, false), new TrafficLightToButtonChannel(impl), new ProgressBarToButtonChannel(impl), new PowerBarToButtonChannel(impl), new ShortVibrationToButtonChannel(impl), new LongVibrationToButtonChannel(impl) }; channelList = new JList(channels); channelList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); channelList.setVisibleRowCount(15); channelList.setPreferredSize(new Dimension(LIST_WIDTH, LIST_HIGHT)); // set up device list deviceList = new JList(); deviceList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); deviceList.setVisibleRowCount(15); deviceList.setPreferredSize(new Dimension(LIST_WIDTH, LIST_HIGHT)); // enable double clicks on the two lists doubleClickListener = new MouseAdapter() { @Override public void mouseClicked(MouseEvent event) { // react on double clicks if (event.getButton() == MouseEvent.BUTTON1 && event.getClickCount() == 2) { JList source = (JList) event.getSource(); if (source == channelList && channelList.isEnabled()) { currentChannel = (OOBChannel) channelList.getSelectedValue(); startAuthentication(); } else if (source == deviceList) { int index = deviceList.getSelectedIndex(); if (index > -1) { String peerAddress = devices[index].getBluetoothAddress(); searchForService(peerAddress); } } } event.consume(); } }; deviceList.addMouseListener(doubleClickListener); // note: this listener will be set on the channelList in the showHomeScreen method ListSelectionListener selectionListener = new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent event) { channelList.setEnabled(false); } }; deviceList.addListSelectionListener(selectionListener); // create refresh button refreshButton = new JButton("Refresh list"); ActionListener buttonListener = new ActionListener() { @Override public void actionPerformed(ActionEvent event) { if ((JButton) event.getSource() == refreshButton) { refreshButton.setEnabled(false); statusLabel.setText("Please wait... scanning for devices..."); peerManager.startInquiry(false); } } }; refreshButton.addActionListener(buttonListener); // set up the bluetooth peer manager BluetoothPeerManager.PeerEventsListener listener = new BluetoothPeerManager.PeerEventsListener() { public void inquiryCompleted(Vector newDevices) { refreshButton.setEnabled(true); statusLabel.setText(""); updateDeviceList(); } public void serviceSearchCompleted(RemoteDevice remoteDevice, Vector services, int errorReason) { // ignore } }; try { peerManager = new BluetoothPeerManager(); peerManager.addListener(listener); } catch (IOException e) { logger.log(Level.SEVERE, "Could not initiate BluetoothPeerManager.", e); } // set up the bluetooth rfcomm server try { btServer = new BluetoothRFCOMMServer(null, SERVICE_UUID, SERVICE_NAME, 30000, true, false); btServer.addAuthenticationProgressHandler(this); btServer.start(); if (logger.isLoggable(Level.INFO)) { logger.info("Finished starting SDP service at " + btServer.getRegisteredServiceURL()); } } catch (IOException e) { logger.log(Level.SEVERE, "Could not create bluetooth server.", e); } ProtocolCommandHandler inputProtocolHandler = new ProtocolCommandHandler() { @Override public boolean handleProtocol(String firstLine, RemoteConnection remote) { if (logger.isLoggable(Level.FINER)) { logger.finer("Handle protocol command: " + firstLine); } if (firstLine.equals(UACAPProtocolConstants.PRE_AUTH)) { inputProtocol(false, remote, null); return true; } return false; } }; btServer.addProtocolCommandHandler(UACAPProtocolConstants.PRE_AUTH, inputProtocolHandler); // build staus bar statusLabel = new JLabel(""); statusLabel.setPreferredSize(new Dimension(FRAME_WIDTH - 40, LABEL_HIGHT)); // build initial screen (the home screen) showHomeScreen(); // launch window mainWindow.pack(); mainWindow.setVisible(true); }
From source file:org.pegadi.client.LoginDialog.java
public void init() { str = ResourceBundle.getBundle("org.pegadi.client.CommonStrings"); ImageIcon icon = new ImageIcon(getClass().getResource("/images/pegadi.gif")); setIconImage(icon.getImage()); jbInit();// ww w . j av a 2s . c o m getPreviousLogin(); }