List of usage examples for java.awt Frame getFrames
public static Frame[] getFrames()
From source file:de.tbuchloh.kiskis.gui.common.MessageBox.java
private static Frame findActiveFrame() { final Frame[] frames = Frame.getFrames(); for (int i = 0; i < frames.length; i++) { if (frames[i].isVisible()) { return frames[i]; }/*from w w w . j a v a 2 s .c o m*/ } return null; }
From source file:LCModels.MessageListener.java
public void run() { /* Keep Thread running */ while (true) { try {/*from ww w . j a v a2 s.c o m*/ /* Accept connection on server */ Socket serverSocket = server.accept(); /* DataInputStream to get message sent by client program */ DataInputStream in = new DataInputStream(serverSocket.getInputStream()); /* We are receiving message in JSON format from client. Parse String to JSONObject */ JSONObject clientMessage = new JSONObject(in.readUTF()); /* Flag to check chat window is opened for user that sent message */ boolean flagChatWindowOpened = false; /* Reading Message and Username from JSONObject */ String userName = clientMessage.get("Username").toString(); String message = clientMessage.getString("Message").toString(); /* Get list of Frame/Windows opened by mainFrame.java */ for (Frame frame : Frame.getFrames()) { /* Check Frame/Window is opened for user */ if (frame.getTitle().equals(userName)) { /* Frame/ Window is already opened */ flagChatWindowOpened = true; /* Get instance of ChatWindow */ ChatWindowUI chatWindow = (ChatWindowUI) frame; /* Get previous messages from TextArea */ String previousMessage = chatWindow.getMessageArea().getText(); /* Set message to TextArea with new message */ chatWindow.getMessageArea().setText(previousMessage + "\n" + userName + ": " + message); } } /* ChatWindow is not open for user sent message to server */ if (!flagChatWindowOpened) { /* Create an Object of ChatWindow */ ChatWindowUI chatWindow = new ChatWindowUI(); /** * We are setting title of window to identify user for next * message we gonna receive You can set hidden value in * ChatWindow.java file. */ chatWindow.setTitle(userName); /* Set message to TextArea */ chatWindow.getMessageArea().setText(message); /* Make ChatWindow visible */ chatWindow.setVisible(true); } /* Get DataOutputStream of client to repond */ DataOutputStream out = new DataOutputStream(serverSocket.getOutputStream()); /* Send response message to client */ out.writeUTF("Received from " + clientMessage.get("Username").toString()); } catch (Exception e) { e.printStackTrace(); } } }
From source file:umich.ms.batmass.filesupport.core.actions.importing.ImportFileByCategory.java
/** * Tries to find an appropriate component as a parent for the file chooser. * @return some Component: the focus owner, the active window or the app frame *//*from w ww. ja v a2 s. c o m*/ private Component findDialogParent() { Component parent = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); if (parent == null) { parent = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow(); } if (parent == null) { Frame[] f = Frame.getFrames(); parent = f.length == 0 ? null : f[f.length - 1]; } return parent; }
From source file:es.emergya.ui.gis.FleetControlMapViewer.java
@Override public void actionPerformed(final ActionEvent e) { final CustomMapView mapViewLocal = this.mapView; SwingWorker<Object, Object> sw = new SwingWorker<Object, Object>() { @Override/*w w w .j a va2 s. co m*/ protected Object doInBackground() throws Exception { try { final MouseEvent mouseEvent = FleetControlMapViewer.this.eventOriginal; if (e.getActionCommand().equals(// Centrar aqui i18n.getString(Locale.ROOT, "map.menu.centerHere"))) { mapViewLocal.zoomToFactor(mapViewLocal.getEastNorth(mouseEvent.getX(), mouseEvent.getY()), mapViewLocal.zoomFactor); } else if (e.getActionCommand().equals(// nueva incidencia i18n.getString("map.menu.newIncidence"))) { Incidencia f = new Incidencia(); f.setCreador(Authentication.getUsuario()); LatLon from = mapViewLocal.getLatLon(mouseEvent.getX(), mouseEvent.getY()); GeometryFactory gf = new GeometryFactory(); f.setGeometria(gf.createPoint(new Coordinate(from.lon(), from.lat()))); IncidenceDialog id = new IncidenceDialog(f, i18n.getString("Incidences.summary.title") + " " + i18n.getString("Incidences.nuevaIncidencia"), "tittleficha_icon_recurso"); id.setVisible(true); } else if (e.getActionCommand().equals(// ruta desde i18n.getString("map.menu.route.from"))) { routeDialog.showRouteDialog(mapViewLocal.getLatLon(mouseEvent.getX(), mouseEvent.getY()), null, mapViewLocal); } else if (e.getActionCommand().equals(// ruta hasta i18n.getString("map.menu.route.to"))) { routeDialog.showRouteDialog(null, mapViewLocal.getLatLon(mouseEvent.getX(), mouseEvent.getY()), mapViewLocal); } else if (e.getActionCommand().equals(// Actualizar gps i18n.getString("map.menu.gps"))) { if (!(menuObjective instanceof Recurso)) { return null; } GPSDialog sdsDialog = null; for (Frame f : Frame.getFrames()) { if (f instanceof GPSDialog) if (((GPSDialog) f).getRecurso().equals(menuObjective)) sdsDialog = (GPSDialog) f; } if (sdsDialog == null) sdsDialog = new GPSDialog((Recurso) menuObjective); sdsDialog.setVisible(true); sdsDialog.setExtendedState(JFrame.NORMAL); } else if (e.getActionCommand().equals(// Ficha i18n.getString("map.menu.summary"))) { if (log.isTraceEnabled()) { log.trace("Mostramos la ficha del objetivo del menu"); } if (menuObjective instanceof Recurso) { log.trace(">recurso"); SwingWorker<Object, Object> sw = new SwingWorker<Object, Object>() { @Override protected Object doInBackground() throws Exception { for (Frame f : JFrame.getFrames()) { if (f.getName().equals(((Recurso) menuObjective).getIdentificador()) && f instanceof SummaryDialog) { if (f.isShowing()) { f.toFront(); f.setExtendedState(JFrame.NORMAL); return null; } } } new SummaryDialog((Recurso) menuObjective).setVisible(true); return null; } }; sw.execute(); } else if (menuObjective instanceof Incidencia) { if (log.isTraceEnabled()) { log.trace(">incidencia"); } SwingWorker<Object, Object> sw = new SwingWorker<Object, Object>() { @Override protected Object doInBackground() throws Exception { for (Frame f : JFrame.getFrames()) { if (f.getName().equals(((Incidencia) menuObjective).getTitulo()) && f instanceof IncidenceDialog) { if (log.isTraceEnabled()) { log.trace("Ya lo tenemos abierto"); } if (f.isShowing()) { f.toFront(); f.setExtendedState(JFrame.NORMAL); } else { f.setVisible(true); f.setExtendedState(JFrame.NORMAL); } return null; } } if (log.isTraceEnabled()) { log.trace("Abrimos uno nuevo"); } new IncidenceDialog((Incidencia) menuObjective, i18n.getString("Incidences.summary.title") + " " + ((Incidencia) menuObjective).getTitulo(), "tittleficha_icon_recurso").setVisible(true); return null; } }; sw.execute(); } else { return null; } } else if (e.getActionCommand().equals( // Mas cercanos i18n.getString("map.menu.showNearest"))) { if (log.isTraceEnabled()) { log.trace("showNearest"); } if (menuObjective != null) { for (Frame f : JFrame.getFrames()) { String identificador = menuObjective.toString(); if (menuObjective instanceof Recurso) { identificador = ((Recurso) menuObjective).getIdentificador(); } if (menuObjective != null && f.getName().equals(identificador) && f instanceof NearestResourcesDialog && f.isDisplayable()) { if (log.isTraceEnabled()) { log.trace("Encontrado " + f); } if (f.isShowing()) { f.toFront(); f.setExtendedState(JFrame.NORMAL); } else { f.setVisible(true); f.setExtendedState(JFrame.NORMAL); } return null; } } } NearestResourcesDialog d; if (menuObjective instanceof Recurso) { d = new NearestResourcesDialog((Recurso) menuObjective, mapViewLocal); } else if (menuObjective instanceof Incidencia) { d = new NearestResourcesDialog((Incidencia) menuObjective, mapViewLocal.getLatLon(mouseEvent.getX(), mouseEvent.getY()), mapViewLocal); } else { d = new NearestResourcesDialog( mapViewLocal.getLatLon(mouseEvent.getX(), mouseEvent.getY()), mapViewLocal); } d.setVisible(true); } else { log.error("ActionCommand desconocido: " + e.getActionCommand()); } } catch (Throwable t) { log.error("Error al ejecutar la accion del menu contextual", t); } return null; } }; sw.execute(); }
From source file:de.uka.ilkd.key.dl.gui.initialdialog.gui.ToolInstaller.java
public void install(JComponent parent, Window dialog) { final File installDirectory; switch (OSInfosDefault.INSTANCE.getOs()) { case OSX://from w w w .j a v a 2 s . c o m System.setProperty("apple.awt.fileDialogForDirectories", "true"); FileDialog d = new FileDialog(Frame.getFrames()[0], "Choose directory for installation of " + toolName, FileDialog.LOAD); d.setVisible(true); System.setProperty("apple.awt.fileDialogForDirectories", "false"); if (d.getFile() != null) { installDirectory = new File(d.getDirectory(), d.getFile()); } else { installDirectory = null; } break; default: final JFileChooser chooser = new JFileChooser(); chooser.setMultiSelectionEnabled(false); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setDialogTitle("Choose directory for installation of " + toolName); chooser.setDialogType(JFileChooser.SAVE_DIALOG); chooser.setApproveButtonText("Install " + toolName + " here"); int result = chooser.showDialog(parent, "Install " + toolName + " here"); if (result == JFileChooser.APPROVE_OPTION) { installDirectory = chooser.getSelectedFile(); } else { installDirectory = null; } } if (installDirectory != null) { try { final File tmp = File.createTempFile("keymaeraDownload", "." + ft.toString().toLowerCase()); final FileInfo info = new FileInfo(url, tmp.getName(), false); final DownloadManager dlm = new DownloadManager(); ProgressBarWindow pbw = new ProgressBarWindow(parent, installDirectory, tmp, ft, ps, dialog); dlm.addListener(pbw); Runnable down = new Runnable() { @Override public void run() { dlm.downloadAll(new FileInfo[] { info }, 2000, tmp.getParentFile().getAbsolutePath(), true); } }; Thread thread = new Thread(down); thread.start(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
From source file:gr.csri.poeticon.praxicon.CreateNeo4JDB.java
private void createGraph() { // Create graph graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(new File(DB_PATH)); Transaction tx = graphDb.beginTx();//from www . ja v a 2 s .com ConceptDao cDao = new ConceptDaoImpl(); RelationDao rDao = new RelationDaoImpl(); LanguageRepresentationDao lrDao = new LanguageRepresentationDaoImpl(); MotoricRepresentationDao mrDao = new MotoricRepresentationDaoImpl(); VisualRepresentationDao vrDao = new VisualRepresentationDaoImpl(); RelationArgumentDao raDao = new RelationArgumentDaoImpl(); RelationSetDao rsDao = new RelationSetDaoImpl(); RelationTypeDao rtDao = new RelationTypeDaoImpl(); System.out.println(); System.out.println("---- MySQL ----"); System.out.print("Downloading Concepts... "); List<Concept> concepts = cDao.getAllConcepts(); System.out.println("" + concepts.size()); System.out.print("Downloading LanguageRepresentations... "); List<LanguageRepresentation> langRepr = lrDao.findAll(); System.out.println("" + langRepr.size()); System.out.print("Downloading VisualRepresentations... "); List<VisualRepresentation> visRepr = vrDao.findAll(); System.out.println("" + visRepr.size()); System.out.print("Downloading MotoricRepresentations... "); List<MotoricRepresentation> motRepr = mrDao.findAll(); System.out.println("" + motRepr.size()); System.out.print("Downloading Relations... "); List<Relation> rels = rDao.findAll(); System.out.println("" + rels.size()); System.out.print("Downloading RelationSets... "); List<RelationSet> relsets = rsDao.findAll(); System.out.println("" + relsets.size()); System.out.println(); System.out.println("---- Neo4J ----"); try { System.out.print("Uploading LanguageRepresentations... "); for (LanguageRepresentation repr : langRepr) { conceptNode = graphDb.createNode(); conceptNode.setProperty("id", repr.getId()); conceptNode.setProperty("text", repr.getText()); conceptNode.setProperty("lang", repr.getLanguage().toString()); conceptNode.setProperty("pos", repr.getPartOfSpeech().toString()); conceptNode.addLabel(Label.label("LanguageRepresentation")); } System.out.println("OK"); System.out.print("Uploading VisualRepresentations... "); for (VisualRepresentation repr : visRepr) { conceptNode = graphDb.createNode(); conceptNode.setProperty("id", repr.getId()); conceptNode.setProperty("name", repr.getName()); conceptNode.setProperty("mediaType", repr.getMediaType().toString()); conceptNode.setProperty("source", repr.getSource()); conceptNode.setProperty("uri", repr.getUri().toString()); conceptNode.addLabel(Label.label("VisualRepresentation")); } System.out.println("OK"); System.out.print("Uploading MotoricRepresentations... "); for (MotoricRepresentation repr : motRepr) { conceptNode = graphDb.createNode(); conceptNode.setProperty("id", repr.getId()); conceptNode.setProperty("performingAgent", repr.getPerformingAgent().toString()); conceptNode.setProperty("source", repr.getSource()); conceptNode.setProperty("uri", repr.getUri().toString()); conceptNode.addLabel(Label.label("MotoricRepresentation")); } System.out.println("OK"); System.out.print("Uploading Concepts with Representations... "); int i = 1; int max = concepts.size(); int prevPerc = 0; for (Concept concept : concepts) { conceptNode = graphDb.createNode(); conceptNode.setProperty("id", concept.getId()); conceptNode.setProperty("name", concept.getName()); conceptNode.setProperty("conceptType", concept.getConceptType().toString()); conceptNode.setProperty("conceptExternalSourceId", concept.getExternalSourceId()); conceptNode.setProperty("conceptPragmaticStatus", concept.getPragmaticStatus().toString()); conceptNode.setProperty("conceptSpecificityLevel", concept.getSpecificityLevel().toString()); conceptNode.setProperty("conceptUniqueInstance", concept.getUniqueInstance().toString()); conceptNode.setProperty("conceptSource", concept.getSource()); conceptNode.setProperty("conceptStatus", concept.getStatus().toString()); conceptNode.addLabel(Label.label("Concept")); List<LanguageRepresentation> lr = concept.getLanguageRepresentations(); for (LanguageRepresentation lrx : lr) { Node n = graphDb.findNodes(Label.label("LanguageRepresentation"), "id", lrx.getId()).next(); conceptNode.createRelationshipTo(n, RelationshipType.withName("LANGUAGE_REPR")); } List<VisualRepresentation> vr = concept.getVisualRepresentations(); for (VisualRepresentation vrx : vr) { Node n = graphDb.findNodes(Label.label("VisualRepresentation"), "id", vrx.getId()).next(); conceptNode.createRelationshipTo(n, RelationshipType.withName("VISUAL_REPR")); } List<MotoricRepresentation> mr = concept.getMotoricRepresentations(); for (MotoricRepresentation mrx : mr) { Node n = graphDb.findNodes(Label.label("MotoricRepresentation"), "id", mrx.getId()).next(); conceptNode.createRelationshipTo(n, RelationshipType.withName("MOTORIC_REPR")); } int perc = new Double((i * 1.0 / max) * 100).intValue(); if (perc > prevPerc && perc % 5 == 0) { prevPerc = perc; System.out.print(perc + "% "); } i++; } System.out.println(" OK"); System.out.print("Uploading RelationSets... "); i = 1; max = relsets.size(); prevPerc = 0; for (RelationSet rset : relsets) { conceptNode = graphDb.createNode(); conceptNode.setProperty("id", rset.getId()); conceptNode.setProperty("name", rset.getName()); conceptNode.addLabel(Label.label("RelationSet")); List<Relation> rxs = rset.getRelationsSet(); int ri = 0; for (Relation rx : rxs) { RelationArgument larg = rx.getLeftArgument(); RelationArgument rarg = rx.getRightArgument(); Long lid, rid; Node nl = null, nr = null; if (larg.isConcept()) { lid = larg.getConcept().getId(); nl = graphDb.findNodes(Label.label("Concept"), "id", lid).next(); } else if (larg.isRelationSet()) { lid = larg.getRelationSet().getId(); nl = graphDb.findNodes(Label.label("RelationSet"), "id", lid).next(); } if (rarg.isConcept()) { rid = rarg.getConcept().getId(); nr = graphDb.findNodes(Label.label("Concept"), "id", rid).next(); } else if (rarg.isRelationSet()) { rid = rarg.getRelationSet().getId(); nr = graphDb.findNodes(Label.label("RelationSet"), "id", rid).next(); } if (nl != null && nr != null) { Relationship rsx = conceptNode.createRelationshipTo(nl, RelationshipType.withName("RS_LEFT")); rsx.setProperty("n", ri); Relationship rsx2 = conceptNode.createRelationshipTo(nr, RelationshipType.withName("RS_RIGHT")); rsx2.setProperty("n", ri); ri++; } } int perc = new Double((i * 1.0 / max) * 100).intValue(); if (perc > prevPerc && perc % 5 == 0) { prevPerc = perc; System.out.print(perc + "% "); } i++; } System.out.println(" OK"); System.out.print("Uploading Relations... "); i = 1; max = rels.size(); prevPerc = 0; for (Relation rel : rels) { RelationArgument larg = rel.getLeftArgument(); RelationArgument rarg = rel.getRightArgument(); Long lid, rid; Node nl = null, nr = null; if (larg.isConcept()) { lid = larg.getConcept().getId(); nl = graphDb.findNodes(Label.label("Concept"), "id", lid).next(); } else if (larg.isRelationSet()) { lid = larg.getRelationSet().getId(); nl = graphDb.findNodes(Label.label("RelationSet"), "id", lid).next(); } if (rarg.isConcept()) { rid = rarg.getConcept().getId(); nr = graphDb.findNodes(Label.label("Concept"), "id", rid).next(); } else if (rarg.isRelationSet()) { rid = rarg.getRelationSet().getId(); nr = graphDb.findNodes(Label.label("RelationSet"), "id", rid).next(); } if (nl != null && nr != null) { Relationship rx = nl.createRelationshipTo(nr, RelationshipType.withName(rel.getRelationType().getForwardNameString())); rx.setProperty("linguisticallySupported", rel.getLinguisticallySupported().toString()); } int perc = new Double((i * 1.0 / max) * 100).intValue(); if (perc > prevPerc && perc % 5 == 0) { prevPerc = perc; System.out.print(perc + "% "); } i++; } System.out.println(" OK"); } catch (Error e) { System.out.println("Error occured: "); System.out.println(e.getMessage()); System.out.println(Arrays.toString(e.getStackTrace())); } tx.success(); if (cDao.getEntityManager().isOpen()) { cDao.close(); } if (rDao.getEntityManager().isOpen()) { rDao.close(); } if (lrDao.getEntityManager().isOpen()) { lrDao.close(); } if (vrDao.getEntityManager().isOpen()) { vrDao.close(); } if (mrDao.getEntityManager().isOpen()) { mrDao.close(); } if (rDao.getEntityManager().isOpen()) { rDao.close(); } if (raDao.getEntityManager().isOpen()) { raDao.close(); } if (rsDao.getEntityManager().isOpen()) { rsDao.close(); } if (rtDao.getEntityManager().isOpen()) { rtDao.close(); } for (Frame frame : Frame.getFrames()) { frame.dispose(); } tx.close(); }
From source file:com.ln.gui.Main.java
@SuppressWarnings("unchecked") public Main() {//from ww w.java 2 s . co m System.gc(); setIconImage(Toolkit.getDefaultToolkit().getImage(Configuration.mydir + "\\resources\\icons\\ln6464.png")); DateFormat dd = new SimpleDateFormat("dd"); DateFormat dh = new SimpleDateFormat("HH"); DateFormat dm = new SimpleDateFormat("mm"); Date day = new Date(); Date hour = new Date(); Date minute = new Date(); dayd = Integer.parseInt(dd.format(day)); hourh = Integer.parseInt(dh.format(hour)); minutem = Integer.parseInt(dm.format(minute)); setTitle("Liquid Notify Revision 2"); Description.setBackground(Color.WHITE); Description.setContentType("text/html"); Description.setEditable(false); Getcalendar.Main(); HyperlinkListener hyperlinkListener = new ActivatedHyperlinkListener(f, Description); Description.addHyperlinkListener(hyperlinkListener); //Add components setContentPane(contentPane); setJMenuBar(menuBar); contentPane.setLayout( new MigLayout("", "[220px:230.00:220,grow][209.00px:n:5000,grow]", "[22px][][199.00,grow][grow]")); eventsbtn.setToolTipText("Displays events currently set to notify"); eventsbtn.setMinimumSize(new Dimension(220, 23)); eventsbtn.setMaximumSize(new Dimension(220, 23)); contentPane.add(eventsbtn, "cell 0 0"); NewsArea.setBackground(Color.WHITE); NewsArea.setBorder(new BevelBorder(BevelBorder.LOWERED, Color.LIGHT_GRAY, Color.LIGHT_GRAY, Color.DARK_GRAY, Color.DARK_GRAY)); NewsArea.setMinimumSize(new Dimension(20, 22)); NewsArea.setMaximumSize(new Dimension(10000, 22)); contentPane.add(NewsArea, "cell 1 0,growx,aligny top"); menuBar.add(File); JMenuItem Settings = new JMenuItem("Settings"); Settings.setIcon(new ImageIcon(Configuration.mydir + "\\resources\\icons\\settings.png")); Settings.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { Settings setup = new Settings(); setup.setVisible(true); setup.setLocationRelativeTo(rootPane); } }); File.add(Settings); File.add(mntmNewMenuItem); Tray.setIcon(new ImageIcon(Configuration.mydir + "\\resources\\icons\\ln1616.png")); File.add(Tray); Exit.setIcon(new ImageIcon(Configuration.mydir + "\\resources\\icons\\exit.png")); File.add(Exit); menuBar.add(mnNewMenu); Update.setIcon(new ImageIcon(Configuration.mydir + "\\resources\\icons\\update.png")); Update.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { URL localURL = new URL("http://jiiks.net23.net/tlnotify/online.html"); URLConnection localURLConnection = localURL.openConnection(); BufferedReader localBufferedReader = new BufferedReader( new InputStreamReader(localURLConnection.getInputStream())); String str = localBufferedReader.readLine(); if (!str.contains("YES")) { String st2221 = "Updates server appears to be offline"; JOptionPane pane1 = new JOptionPane(st2221, JOptionPane.WARNING_MESSAGE, JOptionPane.DEFAULT_OPTION); JDialog dialog1 = pane1.createDialog("Update"); dialog1.setLocationRelativeTo(null); dialog1.setVisible(true); dialog1.setAlwaysOnTop(true); } else if (str.contains("YES")) { URL localURL2 = new URL("http://jiiks.net23.net/tlnotify/latestversion.html"); URLConnection localURLConnection1 = localURL2.openConnection(); BufferedReader localBufferedReader2 = new BufferedReader( new InputStreamReader(localURLConnection1.getInputStream())); String str2 = localBufferedReader2.readLine(); Updatechecker.latestver = str2; if (Integer.parseInt(str2) <= Configuration.version) { String st2221 = "No updates available =("; JOptionPane pane1 = new JOptionPane(st2221, JOptionPane.WARNING_MESSAGE, JOptionPane.DEFAULT_OPTION); JDialog dialog1 = pane1.createDialog("Update"); dialog1.setLocationRelativeTo(null); dialog1.setVisible(true); dialog1.setAlwaysOnTop(true); } else if (Integer.parseInt(str2) > Configuration.version) { String st2221 = "Updates available!"; JOptionPane pane1 = new JOptionPane(st2221, JOptionPane.WARNING_MESSAGE, JOptionPane.DEFAULT_OPTION); JDialog dialog1 = pane1.createDialog("Update"); dialog1.setLocationRelativeTo(null); dialog1.setVisible(true); dialog1.setAlwaysOnTop(true); Updatechecker upd = new Updatechecker(); upd.setVisible(true); upd.setLocationRelativeTo(rootPane); upd.setDefaultCloseOperation(DISPOSE_ON_CLOSE); } } } catch (MalformedURLException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } } }); mnNewMenu.add(Update); JMenuItem About = new JMenuItem("About"); About.setIcon(new ImageIcon(Configuration.mydir + "\\resources\\icons\\about.png")); About.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { About a = new About(); a.setVisible(true); a.setLocationRelativeTo(rootPane); a.setDefaultCloseOperation(DISPOSE_ON_CLOSE); } }); mnNewMenu.add(About); JMenuItem Github = new JMenuItem("Github"); Github.setIcon(new ImageIcon(Configuration.mydir + "\\resources\\icons\\github.png")); Github.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String url = "https://github.com/Jiiks/Liquid-Notify-Rev2"; try { java.awt.Desktop.getDesktop().browse(java.net.URI.create(url)); } catch (IOException e1) { e1.printStackTrace(); } } }); mnNewMenu.add(Github); JMenuItem Thread = new JMenuItem("Thread"); Thread.setIcon(new ImageIcon(Configuration.mydir + "\\resources\\icons\\liquid.png")); Thread.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String url = "http://www.teamliquid.net/forum/viewmessage.php?topic_id=318184"; try { java.awt.Desktop.getDesktop().browse(java.net.URI.create(url)); } catch (IOException e1) { e1.printStackTrace(); } } }); mnNewMenu.add(Thread); Refreshbtn.setToolTipText("Refreshes calendar, please don't spam ^_^"); Refreshbtn.setPreferredSize(new Dimension(90, 20)); Refreshbtn.setMinimumSize(new Dimension(100, 20)); Refreshbtn.setMaximumSize(new Dimension(100, 20)); contentPane.add(Refreshbtn, "flowx,cell 0 1,alignx left"); //Components to secondary panel Titlebox = new JComboBox(); contentPane.add(Titlebox, "cell 1 1,growx,aligny top"); Titlebox.setMinimumSize(new Dimension(20, 20)); Titlebox.setMaximumSize(new Dimension(10000, 20)); //Set other setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 686, 342); contentPane.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); NewsArea.setEnabled(false); NewsArea.setEditable(false); NewsArea.setText("News: " + News); contentPane.add(panel, "cell 0 2,grow"); panel.setLayout(null); final JCalendar calendar = new JCalendar(); calendar.getMonthChooser().setPreferredSize(new Dimension(120, 20)); calendar.getMonthChooser().setMinimumSize(new Dimension(120, 24)); calendar.getYearChooser().setLocation(new Point(20, 0)); calendar.getYearChooser().setMaximum(100); calendar.getYearChooser().setMaximumSize(new Dimension(100, 2147483647)); calendar.getYearChooser().setMinimumSize(new Dimension(50, 20)); calendar.getYearChooser().setPreferredSize(new Dimension(50, 20)); calendar.getYearChooser().getSpinner().setPreferredSize(new Dimension(100, 20)); calendar.getYearChooser().getSpinner().setMinimumSize(new Dimension(100, 20)); calendar.getMonthChooser().getSpinner().setPreferredSize(new Dimension(119, 20)); calendar.getMonthChooser().getSpinner().setMinimumSize(new Dimension(120, 24)); calendar.getDayChooser().getDayPanel().setFont(new Font("Tahoma", Font.PLAIN, 11)); calendar.setDecorationBordersVisible(true); calendar.setTodayButtonVisible(true); calendar.setBackground(Color.LIGHT_GRAY); calendar.setBounds(0, 0, 220, 199); calendar.getDate(); calendar.setWeekOfYearVisible(false); calendar.setDecorationBackgroundVisible(false); calendar.setMaxDayCharacters(2); calendar.getDayChooser().setFont(new Font("Tahoma", Font.PLAIN, 10)); panel.add(calendar); Descriptionscrollpane.setLocation(new Point(100, 100)); Descriptionscrollpane.setMaximumSize(new Dimension(10000, 10000)); Descriptionscrollpane.setMinimumSize(new Dimension(20, 200)); Description.setLocation(new Point(100, 100)); Description.setBorder(new BevelBorder(BevelBorder.LOWERED, Color.LIGHT_GRAY, Color.LIGHT_GRAY, Color.DARK_GRAY, Color.DARK_GRAY)); Description.setMaximumSize(new Dimension(1000, 400)); Description.setMinimumSize(new Dimension(400, 200)); contentPane.add(Descriptionscrollpane, "cell 1 2 1 2,growx,aligny top"); Descriptionscrollpane.setViewportView(Description); verticalStrut.setMinimumSize(new Dimension(12, 20)); contentPane.add(verticalStrut, "cell 0 1"); Notify.setToolTipText("Adds selected event to notify event list."); Notify.setHorizontalTextPosition(SwingConstants.CENTER); Notify.setPreferredSize(new Dimension(100, 20)); Notify.setMinimumSize(new Dimension(100, 20)); Notify.setMaximumSize(new Dimension(100, 20)); contentPane.add(Notify, "cell 0 1,alignx right"); calendar.getMonthChooser().addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { month = calendar.getMonthChooser().getMonth(); Parser.parse(); } }); calendar.getDayChooser().addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { try { int h = calendar.getMonthChooser().getMonth(); @SuppressWarnings("deprecation") int date = calendar.getDate().getDate(); int month = calendar.getMonthChooser().getMonth() + 1; globmonth = calendar.getMonthChooser().getMonth(); sdate = date; datestring = Integer.toString(sdate); monthstring = Integer.toString(month); String[] Hours = Betaparser.Hours; String[] Titles = Betaparser.STitle; String[] Full = new String[Hours.length]; String[] Minutes = Betaparser.Minutes; String[] Des = Betaparser.Description; String[] Des2 = new String[Betaparser.Description.length]; String Seconds = "00"; String gg; int[] IntHours = new int[Hours.length]; int[] IntMins = new int[Hours.length]; int Events = 0; monthday = monthstring + "|" + datestring + "|"; Titlebox.removeAllItems(); for (int a = 0; a != Hours.length; a++) { IntHours[a] = Integer.parseInt(Hours[a]); IntMins[a] = Integer.parseInt(Minutes[a]); } for (int i1 = 0; i1 != Hours.length; i1++) { if (Betaparser.Events[i1].startsWith(monthday)) { Full[i1] = String.format("%02d:%02d", IntHours[i1], IntMins[i1]) + " | " + Titles[i1]; Titlebox.addItem(Full[i1]); } } } catch (Exception e1) { //Catching mainly due to boot property change } } }); Image image = Toolkit.getDefaultToolkit().getImage(Configuration.mydir + "\\resources\\icons\\ln1616.png"); final SystemTray tray = SystemTray.getSystemTray(); ActionListener listener = new ActionListener() { public void actionPerformed(ActionEvent e) { setVisible(true); } }; PopupMenu popup = new PopupMenu(); MenuItem defaultItem = new MenuItem(); defaultItem.addActionListener(listener); TrayIcon trayIcon = null; trayIcon = new TrayIcon(image, "LiquidNotify Revision 2", popup); trayIcon.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { setVisible(true); } });// try { tray.add(trayIcon); } catch (AWTException e) { System.err.println(e); } if (trayIcon != null) { trayIcon.setImage(image); } Tray.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setVisible(false); } }); Titlebox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { Descparser.parsedesc(); } }); Refreshbtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { Getcalendar.Main(); Descparser.parsedesc(); } }); Notify.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { NOTIFY = Descparser.TTT; NOTIFYD = Descparser.DDD; NOTIFYH = Descparser.HHH; NOTIFYM = Descparser.MMM; int i = events; NOA[i] = NOTIFY; NOD[i] = NOTIFYD; NOH[i] = NOTIFYH; NOM[i] = NOTIFYM; Eventlist[i] = "Starts in: " + Integer.toString(NOD[i]) + " Days " + Integer.toString(NOH[i]) + " Hours " + Integer.toString(NOM[i]) + " Minutes " + " | " + NOA[i]; events = events + 1; Notifylist si = new Notifylist(); si.setVisible(false); si.setBounds(1, 1, 1, 1); si.dispose(); if (thread.getState().name().equals("PENDING")) { thread.execute(); } } }); eventsbtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { Notifylist list = new Notifylist(); if (played == 1) { asd.close(); played = 0; } list.setVisible(true); list.setLocationRelativeTo(rootPane); list.setDefaultCloseOperation(DISPOSE_ON_CLOSE); } }); mntmNewMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (thread.getState().name().equals("PENDING")) { thread.execute(); } Userstreams us = new Userstreams(); us.setVisible(true); us.setLocationRelativeTo(rootPane); } }); Exit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { //Absolute exit JOptionPane.showMessageDialog(rootPane, "Bye bye :(", "Exit", JOptionPane.INFORMATION_MESSAGE); Runtime ln = Runtime.getRuntime(); ln.gc(); final Frame[] allf = Frame.getFrames(); final Window[] allw = Window.getWindows(); for (final Window allwindows : allw) { allwindows.dispose(); } for (final Frame allframes : allf) { allframes.dispose(); System.exit(0); } } }); }
From source file:dr.app.bss.Utils.java
public static Frame getActiveFrame() { Frame result = null;/* w w w .ja va2s .co m*/ Frame[] frames = Frame.getFrames(); for (int i = 0; i < frames.length; i++) { Frame frame = frames[i]; if (frame.isVisible()) { result = frame; break; } } return result; }
From source file:org.eclipse.jubula.rc.swing.driver.RobotAwtImpl.java
/** * {@inheritDoc}/*from w ww . j a v a 2s . co m*/ */ public void activateApplication(String method) throws RobotException { try { Window window = getActiveWindow(); if (window == null) { return; } WindowActivationMethod wam = WindowActivationMethod.createWindowActivationMethod(method, m_robot, m_queuer); wam.activate(window); // Verify that window was successfully activated Window activeWindow = (Window) m_queuer.invokeAndWait("getActiveWindow", //$NON-NLS-1$ new IRunnable() { public Object run() throws StepExecutionException { if (Frame.getFrames().length == 0) { return null; } for (int i = 0; i < Frame.getFrames().length; ++i) { Window curWindow = Frame.getFrames()[i]; while (curWindow.getOwner() != null) { curWindow = curWindow.getOwner(); } if (curWindow.isFocused()) { return curWindow; } } return null; } }); if (activeWindow != window) { throw new StepExecutionException(I18n.getString(TestErrorEvent.WINDOW_ACTIVATION_FAILED, true), EventFactory.createActionError(TestErrorEvent.WINDOW_ACTIVATION_FAILED)); } } catch (Exception exc) { throw new RobotException(exc); } }
From source file:org.eclipse.jubula.rc.swing.driver.RobotAwtImpl.java
/** * Guesses the active window. Returns null if no active window is found. * @return the active window/*from ww w. ja va 2 s . c o m*/ */ private Window getActiveWindow() { return (Window) m_queuer.invokeAndWait("getActiveWindow", //$NON-NLS-1$ new IRunnable() { public Object run() throws StepExecutionException { if (Frame.getFrames().length == 0) { return null; } for (int i = 0; i < Frame.getFrames().length; ++i) { Window window = Frame.getFrames()[i]; while (window.getOwner() != null) { window = window.getOwner(); } if (window.isVisible()) { return window; } } return null; } }); }