List of usage examples for javax.swing JFrame setTitle
public void setTitle(String title)
From source file:org.openconcerto.map.ui.ITextComboVilleViewer.java
public ITextComboVilleViewer() { this.setOpaque(false); this.setLayout(new BorderLayout()); this.supp = new ValueChangeSupport<String>(this); this.emptyHelper = new EmptyObjectHelper(this, new Predicate() { public boolean evaluate(final Object object) { // object: le getUncheckedValue() return ITextComboVilleViewer.this.getValue() == null || ITextComboVilleViewer.this.getValue().trim().length() == 0; }/*from ww w. ja va 2 s .c om*/ }); this.text.addValueListener(new PropertyChangeListener() { public void propertyChange(final PropertyChangeEvent evt) { ITextComboVilleViewer.this.supp.fireValueChange(); } }); this.cache = new ITextComboCacheVille(); this.text.initCache(this.cache); this.add(this.text, BorderLayout.CENTER); this.add(this.button, BorderLayout.EAST); this.button.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { final JFrame f = new JFrame(); final MapViewerPanel mapViewerPanel = new MapViewerPanel(true); f.setContentPane(mapViewerPanel); f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); f.setSize(600, 500); f.setMinimumSize(new Dimension(600, 500)); final File conf = new File(System.getProperty("user.home"), ".java" + File.separator + "ilm" + File.separator + "map" + File.separator); new WindowStateManager(f, new File(conf, "Configuration" + File.separator + "MapFrame.properties"), true).loadState(); f.setVisible(true); if (ITextComboVilleViewer.this.currentVille != null) { final long x = ITextComboVilleViewer.this.currentVille.getXLambert(); final long y = ITextComboVilleViewer.this.currentVille.getYLambert(); f.setTitle(ITextComboVilleViewer.this.currentVille.getName()); mapViewerPanel.getVilleRendererPanel().centerScreenXYLambert(x, y); mapViewerPanel.getVilleRendererPanel().setHighlight(ITextComboVilleViewer.this.currentVille); mapViewerPanel.getVilleRendererPanel().setAlwayVisible(ITextComboVilleViewer.this.currentVille); } } }); this.text.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(final DocumentEvent e) { ITextComboVilleViewer.this.currentVille = Ville .getVilleFromVilleEtCode(ITextComboVilleViewer.this.text.getValue()); ITextComboVilleViewer.this.button.setEnabled( ITextComboVilleViewer.this.currentVille != null && ITextComboVilleViewer.this.isEnabled()); } public void insertUpdate(final DocumentEvent e) { this.changedUpdate(e); } public void removeUpdate(final DocumentEvent e) { this.changedUpdate(e); } }); final JPopupMenu popupMenu = new JPopupMenu(); // FIXME ajouter la possibilit de supprimer une ville prcdemment enregistre final JMenuItem menuItem = new JMenuItem("Enregistrer cette ville"); menuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { final String t = ITextComboVilleViewer.this.text.getTextComp().getText(); ITextComboVilleViewer.this.cache.addToCache(t); final Ville createVilleFrom = ITextComboVilleViewer.this.cache.createVilleFrom(t); if (createVilleFrom != null) { final String villeEtCode = createVilleFrom.getVilleEtCode(); ITextComboVilleViewer.this.setValue(villeEtCode); ITextComboVilleViewer.this.firePropertyChange("value", null, villeEtCode); } } }); popupMenu.add(menuItem); this.text.getTextComp().addMouseListener(new PopupMouseListener(popupMenu)); }
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 ww w . ja v a2 s .c o m 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.springframework.richclient.application.support.AbstractApplicationWindow.java
protected void applyStandardLayout(JFrame windowControl, ApplicationWindowConfigurer configurer) { windowControl.setTitle(configurer.getTitle()); windowControl.setIconImage(configurer.getImage()); windowControl.setJMenuBar(createMenuBarControl()); windowControl.getContentPane().setLayout(new BorderLayout()); windowControl.getContentPane().add(createToolBarControl(), BorderLayout.NORTH); windowControl.getContentPane().add(createWindowContentPane()); windowControl.getContentPane().add(createStatusBarControl(), BorderLayout.SOUTH); }
From source file:org.ut.biolab.medsavant.client.util.ClientMiscUtils.java
/** * Set the title of a window to reflect whether it is saved or not. On Windows and Linux, this appends an asterisk * to the title of an unsaved document; on Mac, it puts a dot inside the close-button. * //from www . jav a 2 s . c o m * @param f * @param unsaved */ public static void setUnsavedTitle(JFrame f, String title, boolean unsaved) { f.getRootPane().putClientProperty("Window.documentModified", unsaved); if (!MAC && unsaved) { f.setTitle(title + UNSAVED_MARK); } else { f.setTitle(title); } }
From source file:org.wrml.werminal.Werminal.java
public Werminal(final WerminalModel werminalModel, final Context context, final TerminalType terminalType) throws Exception { super("Werminal", context, terminalType); _WerminalModel = werminalModel;/* w ww . j a va 2 s. co m*/ final GUIScreen guiScreen = getGuiScreen(); final List<URI> schemaUriHistoryList = _WerminalModel.getSchemaUriHistoryList(); _SchemaUriHistory = new History<>(schemaUriHistoryList); _SlotValueHistories = new TreeMap<>(); _SlotValueHistoryModels = new TreeMap<>(); final List<SlotValueHistoryListModel> slotValueHistoryLists = _WerminalModel.getSlotValueHistoryLists(); compileSlotValueHistoryLists(slotValueHistoryLists); _UnimplementedActions = new HashMap<String, WerminalAction>(); _DefaultSplashTheme = new DefaultSplashTheme(); _DefaultMenuTheme = new DefaultWindowTheme(); _LightTheme = new LightTheme(); _CancelAction = new CancelAction(this); _CloseAction = new CloseBeforeAction(this); _DeleteAction = new DeleteAction(this); _ExitAction = new ExitAction(this); _NewAction = new NewAction(this); _NewConfirmationAction = new NewConfirmationAction(this); _OpenAction = new OpenAction(this); _OpenConfirmationAction = new OpenConfirmationAction(this); _SetOriginAction = new SetOriginAction(this); _SaveAction = new SaveAction(this); _PrintPreviewAction = new PrintPreviewAction(this); _PrintAction = new PrintAction(this); _PrintConfirmationAction = new PrintConfirmationAction(this); _LoadAction = new LoadAction(this); _ShowModelMenuAction = new ShowModelMenuAction(this); _ShowListMenuAction = new ShowListMenuAction(this); _HelpGuideAction = new HelpGuideAction(this); _WrmlOrgAction = new WrmlOrgAction(this); _ClosingWrmlOrgAction = new CloseBeforeAction(this, _WrmlOrgAction); _SplashWindow = new SplashWindow(this); _MainMenuWindow = new TerminalAppMenuWindow(this, "WRML - Werminal", new MainMenu(this), new TerminalAppButtonPanel(_ExitAction)); _NewModelDialog = new NewModelDialog(this, "New Model", _NewConfirmationAction, _CancelAction); _OpenModelDialog = new OpenModelDialog(this, "Open Model", _OpenConfirmationAction, _CancelAction); _ModelMenuWindow = new TerminalAppMenuWindow(this, "", new ModelMenu(this), new TerminalAppButtonPanel(_CloseAction)); _ListMenuWindow = new TerminalAppMenuWindow(this, "", new ListMenu(this), new TerminalAppButtonPanel(_CloseAction)); _PrintDialog = new PrintDialog(this, "Print Model"); _LoadApiDialog = new LoadApiDialog(this, "Load REST API Metadata"); final URI metaSchemaUri = getContext().getSchemaLoader().getSchemaSchemaUri(); _NewModelDialog.setSchemaUri(metaSchemaUri); for (final URI historySchemaUri : schemaUriHistoryList) { addToSchemaUriHistory(historySchemaUri); } final JsonSchemaLoader jsonSchemaLoader = context.getSchemaLoader().getJsonSchemaLoader(); final SortedSet<URI> loadedJsonSchemaUris = jsonSchemaLoader.getLoadedJsonSchemaUris(); for (final URI loadedJsonSchemaUri : loadedJsonSchemaUris) { addToSchemaUriHistory(loadedJsonSchemaUri); } final Screen screen = guiScreen.getScreen(); screen.startScreen(); final Terminal terminal = screen.getTerminal(); if (terminal instanceof SwingTerminal) { final JFrame frame = ((SwingTerminal) terminal).getJFrame(); frame.setTitle(getAppTitle()); // TODO: Do something fun with the JFrame. =) } showSplashWindow(); String errorMessage = null; while (true) { try { showMainMenuBarWindow(); break; } catch (final Exception e) { errorMessage = "An unexpected error has occurred."; showError(errorMessage, e); LOG.error(errorMessage + " (" + e.getMessage() + ")", e); } } screen.stopScreen(); schemaUriHistoryList.clear(); schemaUriHistoryList.addAll(_SchemaUriHistory.getElementSet()); getContext().saveModel(_WerminalModel); }
From source file:simcommunity.TheSim.java
public static void disegnapallocco(final Community c, final int[][] vicinato, final String titleFrame) { //Graph<String, String> g = new SparseMultigraph<String, String>(); //StaticLayout<String, String> layout = new StaticLayout<String, String>(g); final DirectedSparseGraph<String, String> g = new DirectedSparseGraph<>(); final Layout<String, String> layout = new StaticLayout<>(g); int lung, R, G, B; int[] vicini; String sR, sG, sB, nomeV, nomeE; String[] test2 = new String[GlobalVar.dimensionecom]; for (int i = 0; i < GlobalVar.dimensionecom; i++) { R = c.getPersona(i).getR();//w w w . j a v a2s . c o m G = c.getPersona(i).getG(); B = c.getPersona(i).getB(); if (R > 255) { R = 255; } if (G > 255) { G = 255; } if (B > 255) { B = 255; } sR = Integer.toString(R); sG = Integer.toString(G); sB = Integer.toString(B); if (sR.length() == 2) { sR = "0" + sR; } if (sR.length() == 1) { sR = "00" + sR; } if (sG.length() == 2) { sG = "0" + sG; } if (sG.length() == 1) { sG = "00" + sG; } if (sB.length() == 2) { sB = "0" + sB; } if (sB.length() == 1) { sB = "00" + sB; } //nome=Integer.toString(R)+"a"+Integer.toString(G)+"a"+Integer.toString(B)+"a"+Integer.toString(i); test2[i] = sR + sG + sB + Integer.toString(i); } for (int i = 0; i < GlobalVar.dimensionecom; i++) { R = c.getPersona(i).getR(); G = c.getPersona(i).getG(); B = c.getPersona(i).getB(); if (R > 255) { R = 255; } if (G > 255) { G = 255; } if (B > 255) { B = 255; } sR = Integer.toString(R); sG = Integer.toString(G); sB = Integer.toString(B); if (sR.length() == 2) { sR = "0" + sR; } if (sR.length() == 1) { sR = "00" + sR; } if (sG.length() == 2) { sG = "0" + sG; } if (sG.length() == 1) { sG = "00" + sG; } if (sB.length() == 2) { sB = "0" + sB; } if (sB.length() == 1) { sB = "00" + sB; } nomeV = sR + sG + sB; g.addVertex(nomeV + Integer.toString(i)); Point2D point = new Point2D.Double(c.getPersona(i).getX(), c.getPersona(i).getY()); layout.setLocation(nomeV + Integer.toString(i), point); //layout.setLocation(i, c.getPersona(i).getX(), c.getPersona(i).getY()); //setto la posizione senza Point2D solo con Static Layout vicini = vicinato[i]; lung = vicini.length; for (int j = 0; j < lung; j++) { if (vicini[j] == -1) { } else { nomeE = "Edge" + Integer.toString(i) + Integer.toString(j); g.addEdge(nomeE, nomeV + Integer.toString(i), test2[vicini[j]]); } } } layout.setSize(new Dimension(GlobalVar.videoW, GlobalVar.videoH)); final VisualizationViewer<String, String> vv = new VisualizationViewer<>(layout); /* vv.getRenderContext().setVertexLabelTransformer(transformer); transformer = new Transformer<String, String>() { @Override public String transform(String arg0) { return arg0; } }; vv.getRenderContext().setEdgeLabelTransformer(transformer);*/ vv.setPreferredSize(new Dimension(1024, 768)); // The following code adds capability for mouse picking of vertices/edges. Vertices can even be moved! final DefaultModalGraphMouse<String, Number> graphMouse = new DefaultModalGraphMouse<>(); vv.setGraphMouse(graphMouse); graphMouse.setMode(ModalGraphMouse.Mode.PICKING); Transformer<String, String> transformer = new Transformer<String, String>() { @Override public String transform(String arg0) { return arg0; } }; vv.getRenderer().setVertexRenderer(new MyRenderer(c)); JFrame frame = new JFrame(); frame.setTitle(titleFrame); frame.getContentPane().add(vv); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); }
From source file:spacetrader.demos.M5Demo.java
public static void main(String[] args) { // EllipticalGalaxy test GalaxyGenerator gaxGen = new EllipticalGalaxyGenerator("Fartdust", SYSTEM_NUM_MEAN, SYSTEM_NUM_SD, X_SD, Y_SD, BOUND_FACTOR * X_SD, BOUND_FACTOR * Y_SD, Util.sampleFromUniformReal(0, Math.PI)); gax = gaxGen.generate();/*from ww w .j a v a 2 s . c o m*/ List<StarSystem> systems = gax.getSystems(); StarSystem t1 = systems.get(0); StarSystem t2 = systems.get(1); FactionSelector f1 = new FactionSelector(new Faction.Test1Heurstic(), Faction.Test1); f1.addNeighbor(t1); FactionSelector f2 = new FactionSelector(new Faction.Test1Heurstic(), Faction.Test2); f2.addNeighbor(t2); do { f1.update(); f2.update(); } while (!f1.isDone() && !f2.isDone()); JFrame frame = new JFrame(); frame.setVisible(true); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.setTitle("WAT"); frame.setSize((int) (FRAME_SIZE), (int) (FRAME_SIZE)); frame.add(new M4Demo()); }
From source file:uk.ac.abdn.csd.p2p.server.ServerGUI.java
/** * This method prepares all the graphical components that are contained with P2P Visualisation Server. */// w w w . j av a2 s.com // <editor-fold defaultstate="collapsed" desc="...GUI"> private void initializeComponent() { listeningPort = 0; JFrame frame = new JFrame(); BorderLayout layout = new BorderLayout(); //create a graph overlay = new UndirectedSparseGraph<Vertex, Edge>(); ObservableGraph<Vertex, Edge> og = new ObservableGraph<Vertex, Edge>(overlay); /* og.addGraphEventListener(new GraphEventListener<Vertex, Edge>() { @Override public void handleGraphEvent( GraphEvent<Vertex, Edge> evt) { System.err.println("got " + evt); } });*/ this.overlay = og; layout1 = new FRLayout2<Vertex, Edge>(overlay); vv = new VisualizationViewer<Vertex, Edge>(layout1, new Dimension(700, 200)); vv.setGraphMouse(new DefaultModalGraphMouse<Vertex, Edge>()); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<Vertex>()); vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller<Edge>()); vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR); vv.getRenderContext().setVertexFillPaintTransformer(new VertexPainter()); DefaultModalGraphMouse gm1 = new DefaultModalGraphMouse(); gm1.setMode(ModalGraphMouse.Mode.TRANSFORMING); gm1.setMode(ModalGraphMouse.Mode.PICKING); gm1.add(new MyPopupGraphMousePlugin()); vv.setGraphMouse(gm1); vv.addKeyListener(gm1.getModeKeyListener()); contentPane = new JPanel(layout); displayPanel = new javax.swing.JPanel(); consoleTextArea = new JTextArea(); jScrollPane2 = new JScrollPane(); clearButton = new JButton(); consolePanel = new JPanel(); clearButton = new javax.swing.JButton(); nodeTextArea = new JTextArea(); jScrollPane1 = new JScrollPane(); nodePanel = new JPanel(); linkTextArea = new JTextArea(); jScrollPane3 = new JScrollPane(); linkPanel = new JPanel(); menuBar = new javax.swing.JMenuBar(); serverMenu = new javax.swing.JMenu(); startServerMenuItem = new javax.swing.JMenuItem(); jSeparator1 = new javax.swing.JPopupMenu.Separator(); exitMenuItem = new javax.swing.JMenuItem(); editMenu = new javax.swing.JMenu(); settingMenuItem = new javax.swing.JMenuItem(); colorSettingMenuItem = new javax.swing.JMenuItem(); toolMenuItem = new javax.swing.JMenu(); clearMenuItem = new javax.swing.JMenuItem(); helpMenu = new javax.swing.JMenu(); aboutMenuItem = new javax.swing.JMenuItem(); zoominMenuItem = new javax.swing.JMenuItem(); zoomoutMenuItem = new javax.swing.JMenuItem(); layoutSettingMenuItem = new javax.swing.JMenuItem(); labelPositionMenuItem = new javax.swing.JMenuItem(); speedSettingMenuItem = new javax.swing.JMenuItem(); topologySettingMenuItem = new javax.swing.JMenuItem(); findNodeMenuItem = new javax.swing.JMenuItem(); serverMenu.setText("Server"); serverMenu.setToolTipText("Server"); startServerMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.ALT_MASK)); startServerMenuItem.setText("Start Server"); startServerMenuItem.setToolTipText("Start Server"); startServerMenuItem.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { startServerMenuItemActionPerformed(evt); } }); serverMenu.add(startServerMenuItem); serverMenu.add(jSeparator1); exitMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.ALT_MASK)); exitMenuItem.setText("Exit"); exitMenuItem.setToolTipText("Exit"); exitMenuItem.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { exitMenuItemActionPerformed(evt); } }); serverMenu.add(exitMenuItem); menuBar.add(serverMenu); editMenu.setText("Edit"); editMenu.setToolTipText("Edit"); settingMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.ALT_MASK)); settingMenuItem.setText("Server Settings"); settingMenuItem.setToolTipText("Server Settings"); settingMenuItem.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { settingMenuItemActionPerformed(evt); } }); editMenu.add(settingMenuItem); colorSettingMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_M, java.awt.event.InputEvent.ALT_MASK)); colorSettingMenuItem.setText("Colour Settings"); colorSettingMenuItem.setToolTipText("Colour Settings"); colorSettingMenuItem.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { colorSettingMenuItemActionPerformed(evt); } }); editMenu.add(colorSettingMenuItem); layoutSettingMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_L, java.awt.event.InputEvent.ALT_MASK)); layoutSettingMenuItem.setText("Layout Settings"); layoutSettingMenuItem.setToolTipText("Layout Settings"); layoutSettingMenuItem.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { layoutSettingMenuItemActionPerformed(evt); } }); editMenu.add(layoutSettingMenuItem); speedSettingMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_V, java.awt.event.InputEvent.ALT_MASK)); speedSettingMenuItem.setText("Speed Settings"); speedSettingMenuItem.setToolTipText("Speed Settings"); speedSettingMenuItem.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { speedSettingMenuItemActionPerformed(evt); } }); editMenu.add(speedSettingMenuItem); topologySettingMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T, java.awt.event.InputEvent.ALT_MASK)); topologySettingMenuItem.setText("Topology Settings"); topologySettingMenuItem.setToolTipText("Topology Settings"); topologySettingMenuItem.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { topologySettingMenuItemActionPerformed(evt); } }); editMenu.add(topologySettingMenuItem); menuBar.add(editMenu); toolMenuItem.setText("Tools"); toolMenuItem.setToolTipText("Tools"); labelPositionMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, java.awt.event.InputEvent.ALT_MASK)); labelPositionMenuItem.setText("Vertex Label Position"); labelPositionMenuItem.setToolTipText("Vertex Label Position"); toolMenuItem.add(labelPositionMenuItem); labelPositionMenuItem.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { labelPositionMenuItemActionPerformed(evt); } }); final ScalingControl scaler = new CrossoverScalingControl(); zoominMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I, java.awt.event.InputEvent.ALT_MASK)); zoominMenuItem.setText("Zoom-In"); zoominMenuItem.setToolTipText("Zoom-In"); toolMenuItem.add(zoominMenuItem); zoominMenuItem.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); zoomoutMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.ALT_MASK)); zoomoutMenuItem.setText("Zoom-Out"); zoomoutMenuItem.setToolTipText("Zoom-Out"); toolMenuItem.add(zoomoutMenuItem); zoomoutMenuItem.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { scaler.scale(vv, 0.9f, vv.getCenter()); } }); findNodeMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F, java.awt.event.InputEvent.ALT_MASK)); findNodeMenuItem.setText("Find Node on Overlay"); findNodeMenuItem.setToolTipText("Find Node"); toolMenuItem.add(findNodeMenuItem); findNodeMenuItem.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { findNodeMenuItemMenuItemActionPerformed(evt); } }); menuBar.add(toolMenuItem); helpMenu.setText("Help"); helpMenu.setToolTipText("Help"); aboutMenuItem.setText("About"); aboutMenuItem.setToolTipText("About"); aboutMenuItem.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { aboutMenuItemActionPerformed(evt); } }); helpMenu.add(aboutMenuItem); menuBar.add(helpMenu); displayPanel.setLayout(new BorderLayout()); displayPanel.setBorder(new TitledBorder("P2P Overlay")); displayPanel.add(vv); validate(); // // nodeTextArea // nodeTextArea.setEditable(false); nodeTextArea.setLineWrap(true); // // jScrollPane1 // jScrollPane1.setViewportView(nodeTextArea); //jScrollPane1.setsi // // nodePanel // nodePanel.setLayout(new BoxLayout(nodePanel, BoxLayout.X_AXIS)); nodePanel.add(jScrollPane1, 0); nodePanel.setBorder(new TitledBorder("Nodes Active")); // // linkTextArea // linkTextArea.setEditable(false); linkTextArea.setLineWrap(true); // // jScrollPane3 // jScrollPane3.setViewportView(linkTextArea); // // linkPanel // linkPanel.setLayout(new BoxLayout(linkPanel, BoxLayout.X_AXIS)); linkPanel.add(jScrollPane3, 0); linkPanel.setBorder(new TitledBorder("Node Links")); // // consoleTextArea // consoleTextArea.setEditable(false); consoleTextArea.setLineWrap(true); // // jScrollPane2 // jScrollPane2.setViewportView(consoleTextArea); // // clearButton // clearButton.setText("Clear"); clearButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { clearButton_actionPerformed(e); } }); // // consolePanel // consolePanel.setLayout(new BoxLayout(consolePanel, BoxLayout.X_AXIS)); consolePanel.add(jScrollPane2, 0); consolePanel.add(clearButton, 1); consolePanel.setBorder(new TitledBorder("Console")); // // ServerGUI // Dimension panelD = new Dimension(700, 330); // display Panel Dimension panelD1 = new Dimension(700, 134); // control Panel Dimension panelD2 = new Dimension(350, 140); // nodepanel and linkpanel Dimension panelD3 = new Dimension(700, 140); // nodepanel and linkpanel togther consolePanel.setPreferredSize(panelD1); displayPanel.setPreferredSize(panelD); nodePanel.setPreferredSize(panelD2); linkPanel.setPreferredSize(panelD2); Box box = new Box(BoxLayout.X_AXIS); // put nodepanel and linkpanel in one box box.add(nodePanel); box.add(linkPanel); box.setSize(panelD3); //contentPane.add(BorderLayout.NORTH,displayPanel); //contentPane.add(BorderLayout.CENTER,box); contentPane.add(BorderLayout.NORTH, box); contentPane.add(BorderLayout.CENTER, displayPanel); contentPane.add(BorderLayout.SOUTH, consolePanel); frame.setJMenuBar(menuBar); frame.getContentPane().add(contentPane); frame.setTitle("P2P Visualisation Server"); frame.setSize(new Dimension(800, 600)); frame.setResizable(true); // This code has been adapted from http://lookass.ch/?id=4&area=art&art=47 Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension size = frame.getSize(); screenSize.height = screenSize.height / 2; screenSize.width = screenSize.width / 2; size.height = size.height / 2; size.width = size.width / 2; int y = screenSize.height - size.height; int x = screenSize.width - size.width; frame.setLocation(x, y); frame.setVisible(true); frame.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); frame.addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { formWindowClosing(evt); } }); }
From source file:views.online.Panel_RejoindrePartieMulti.java
/** * Constructeur/*from ww w. j ava 2 s . co m*/ * * @param parent le fenetre parent */ public Panel_RejoindrePartieMulti(JFrame parent) { // initialisation super(new BorderLayout()); this.parent = parent; parent.setTitle(Language.getTexte(Language.ID_TITRE_REJOINDRE_UNE_PARTIE_MULTI)); setBorder(new EmptyBorder(new Insets(MARGES_PANEL, MARGES_PANEL, MARGES_PANEL, MARGES_PANEL))); setBackground(LookInterface.COULEUR_DE_FOND_PRI); // --------- // -- TOP -- // --------- JPanel pTop = new JPanel(new BorderLayout()); pTop.setBackground(LookInterface.COULEUR_DE_FOND_PRI); JLabel titre = new JLabel(Language.getTexte(Language.ID_TITRE_REJOINDRE_UNE_PARTIE_MULTI)); titre.setFont(ManageFonts.POLICE_TITRE); titre.setForeground(LookInterface.COULEUR_TEXTE_PRI); pTop.add(titre, BorderLayout.NORTH); // filtre JPanel pADroite = new JPanel(new BorderLayout()); pADroite.setBackground(LookInterface.COULEUR_DE_FOND_PRI); tfFiltre.setPreferredSize(new Dimension(100, 25)); tfFiltre.addKeyListener(this); tfFiltre.addMouseListener(this); pADroite.add(tfFiltre, BorderLayout.WEST); pTop.add(pADroite, BorderLayout.CENTER); ManageFonts.setStyle(bRafraichir); pTop.add(bRafraichir, BorderLayout.EAST); bRafraichir.addActionListener(this); add(pTop, BorderLayout.NORTH); // ------------ // -- CENTER -- // ------------ // cration de la table avec boquage des editions tbServeurs = new JTable(model) { public boolean isCellEditable(int rowIndex, int colIndex) { return false; // toujours dsactiv } }; // Simple selection tbServeurs.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // nom de colonnes model.addColumn(Language.getTexte(Language.ID_TXT_NOM)); model.addColumn(Language.getTexte(Language.ID_TXT_IP)); model.addColumn(Language.getTexte(Language.ID_TXT_PORT)); model.addColumn(Language.getTexte(Language.ID_TXT_MODE)); model.addColumn(Language.getTexte(Language.ID_TXT_TERRAIN)); model.addColumn(Language.getTexte(Language.ID_TXT_PLACES_DISPO)); // Cration du canal avec le serveur d'enregistrement try { canalServeurEnregistrement = new ChannelTCP(Configuration.getIpSE(), Configuration.getPortSE()); mettreAJourListeDesServeurs(); } catch (ConnectException e) { connexionSEImpossible(); } catch (ChannelException e) { connexionSEImpossible(); } // ajout dans le panel add(new JScrollPane(tbServeurs), BorderLayout.CENTER); // ------------ // -- BOTTOM -- // ------------ JPanel pBottom = new JPanel(new BorderLayout()); pBottom.setBackground(LookInterface.COULEUR_DE_FOND_PRI); bRetour.addActionListener(this); ManageFonts.setStyle(bRetour); bRetour.setPreferredSize(new Dimension(80, 50)); pBottom.add(bRetour, BorderLayout.WEST); JPanel bottomCenter = new JPanel(); bottomCenter.setBackground(LookInterface.COULEUR_DE_FOND_PRI); // connexion par IP lblConnexionParIP.setFont(ManageFonts.POLICE_SOUS_TITRE); lblConnexionParIP.setForeground(LookInterface.COULEUR_TEXTE_PRI); bottomCenter.add(lblConnexionParIP); tfConnexionParIP.setPreferredSize(new Dimension(100, 25)); bottomCenter.add(tfConnexionParIP); tfConnexionParIP.addMouseListener(this); // pseudo JPanel pPseudo = new JPanel(); JPanel pTmp = new JPanel(); lblPseudo.setFont(ManageFonts.POLICE_SOUS_TITRE); lblPseudo.setForeground(LookInterface.COULEUR_TEXTE_PRI); bottomCenter.add(lblPseudo); tfPseudo.setText(Configuration.getPseudoJoueur()); bottomCenter.add(tfPseudo); pPseudo.add(pTmp, BorderLayout.EAST); pBottom.add(bottomCenter, BorderLayout.CENTER); // bouton rejoindre bRejoindre.setPreferredSize(new Dimension(100, 50)); ManageFonts.setStyle(bRejoindre); pBottom.add(bRejoindre, BorderLayout.EAST); bRejoindre.addActionListener(this); pBottom.add(lblEtat, BorderLayout.SOUTH); add(pBottom, BorderLayout.SOUTH); }
From source file:vues.reseau.Panel_RejoindrePartieMulti.java
/** * Constructeur/* w ww . j a va2 s . co m*/ * * @param parent le fenetre parent */ public Panel_RejoindrePartieMulti(JFrame parent) { // initialisation super(new BorderLayout()); this.parent = parent; parent.setTitle(Langue.getTexte(Langue.ID_TITRE_REJOINDRE_UNE_PARTIE_MULTI)); setBorder(new EmptyBorder(new Insets(MARGES_PANEL, MARGES_PANEL, MARGES_PANEL, MARGES_PANEL))); setBackground(LookInterface.COULEUR_DE_FOND_PRI); // --------- // -- TOP -- // --------- JPanel pTop = new JPanel(new BorderLayout()); pTop.setBackground(LookInterface.COULEUR_DE_FOND_PRI); JLabel titre = new JLabel(Langue.getTexte(Langue.ID_TITRE_REJOINDRE_UNE_PARTIE_MULTI)); titre.setFont(GestionnaireDesPolices.POLICE_TITRE); titre.setForeground(LookInterface.COULEUR_TEXTE_PRI); pTop.add(titre, BorderLayout.NORTH); // filtre JPanel pADroite = new JPanel(new BorderLayout()); pADroite.setBackground(LookInterface.COULEUR_DE_FOND_PRI); tfFiltre.setPreferredSize(new Dimension(100, 25)); tfFiltre.addKeyListener(this); tfFiltre.addMouseListener(this); pADroite.add(tfFiltre, BorderLayout.WEST); pTop.add(pADroite, BorderLayout.CENTER); GestionnaireDesPolices.setStyle(bRafraichir); pTop.add(bRafraichir, BorderLayout.EAST); bRafraichir.addActionListener(this); add(pTop, BorderLayout.NORTH); // ------------ // -- CENTER -- // ------------ // cration de la table avec boquage des editions tbServeurs = new JTable(model) { public boolean isCellEditable(int rowIndex, int colIndex) { return false; // toujours dsactiv } }; // Simple selection tbServeurs.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // nom de colonnes model.addColumn(Langue.getTexte(Langue.ID_TXT_NOM)); model.addColumn(Langue.getTexte(Langue.ID_TXT_IP)); model.addColumn(Langue.getTexte(Langue.ID_TXT_PORT)); model.addColumn(Langue.getTexte(Langue.ID_TXT_MODE)); model.addColumn(Langue.getTexte(Langue.ID_TXT_TERRAIN)); model.addColumn(Langue.getTexte(Langue.ID_TXT_PLACES_DISPO)); // Cration du canal avec le serveur d'enregistrement try { canalServeurEnregistrement = new CanalTCP(Configuration.getIpSE(), Configuration.getPortSE()); mettreAJourListeDesServeurs(); } catch (ConnectException e) { connexionSEImpossible(); } catch (CanalException e) { connexionSEImpossible(); } // ajout dans le panel add(new JScrollPane(tbServeurs), BorderLayout.CENTER); // ------------ // -- BOTTOM -- // ------------ JPanel pBottom = new JPanel(new BorderLayout()); pBottom.setBackground(LookInterface.COULEUR_DE_FOND_PRI); bRetour.addActionListener(this); GestionnaireDesPolices.setStyle(bRetour); bRetour.setPreferredSize(new Dimension(80, 50)); pBottom.add(bRetour, BorderLayout.WEST); JPanel bottomCenter = new JPanel(); bottomCenter.setBackground(LookInterface.COULEUR_DE_FOND_PRI); // connexion par IP lblConnexionParIP.setFont(GestionnaireDesPolices.POLICE_SOUS_TITRE); lblConnexionParIP.setForeground(LookInterface.COULEUR_TEXTE_PRI); bottomCenter.add(lblConnexionParIP); tfConnexionParIP.setPreferredSize(new Dimension(100, 25)); bottomCenter.add(tfConnexionParIP); tfConnexionParIP.addMouseListener(this); // pseudo JPanel pPseudo = new JPanel(); JPanel pTmp = new JPanel(); lblPseudo.setFont(GestionnaireDesPolices.POLICE_SOUS_TITRE); lblPseudo.setForeground(LookInterface.COULEUR_TEXTE_PRI); bottomCenter.add(lblPseudo); tfPseudo.setText(Configuration.getPseudoJoueur()); bottomCenter.add(tfPseudo); pPseudo.add(pTmp, BorderLayout.EAST); pBottom.add(bottomCenter, BorderLayout.CENTER); // bouton rejoindre bRejoindre.setPreferredSize(new Dimension(100, 50)); GestionnaireDesPolices.setStyle(bRejoindre); pBottom.add(bRejoindre, BorderLayout.EAST); bRejoindre.addActionListener(this); pBottom.add(lblEtat, BorderLayout.SOUTH); add(pBottom, BorderLayout.SOUTH); }