private JMenu createFileMenu() { ActionMap actionMap = context.getActionMap(this); final JMenu file = new JMenu("File"); file.setMnemonic('f'); file.add(actionMap.get("openProject")); final JMenu fileRecent = new JMenu("Recent Projects"); fileRecent.setIcon(new ImageIcon("/resources/icons/open.png")); fileRecent.addMenuListener(new RecentProjectsMenuManager(application, projectService)); file.add(fileRecent); file.addSeparator(); final JMenu fileExport = new JMenu("Export To"); fileExport.setIcon(new ImageIcon("/resources/icons/exportTo.png")); fileExport.add(application.getAction(ExportToHtml.COMMAND)); fileExport.add(application.getAction(ExportToRecordBundle.COMMAND)); file.add(fileExport); final JMenu fileImport = new JMenu("Import From"); fileExport.setIcon(new ImageIcon("/resources/icons/import.png")); fileImport.add(application.getAction(ImportFromRecordBundle.COMMAND)); file.add(fileImport); file.addSeparator(); file.add(application.getAction(NewRvConnection.COMMAND)); final JMenu connRecent = new JMenu("Recent Connections"); connRecent.addMenuListener(new RecentConnectionsMenuManager(application)); file.add(connRecent); return file; }
public DemoControls(Gradient demo) { super(demo.name); this.demo = demo; JMenuBar inMenuBar = new JMenuBar(); add(inMenuBar); JMenuBar outMenuBar = new JMenuBar(); add(outMenuBar); Font font = new Font("serif", Font.PLAIN, 10); imenu = (JMenu) inMenuBar.add(new JMenu("Inner Color")); imenu.setFont(font); imenu.setIcon(new ColoredSquare(demo.innerC)); omenu = (JMenu) outMenuBar.add(new JMenu("Outer Color")); omenu.setFont(font); omenu.setIcon(new ColoredSquare(demo.outerC)); for (int i = 0; i < colors.length; i++) { squares[i] = new ColoredSquare(colors[i]); innerMI[i] = imenu.add(new JMenuItem(colorName[i])); innerMI[i].setFont(font); innerMI[i].setIcon(squares[i]); innerMI[i].addActionListener(this); outerMI[i] = omenu.add(new JMenuItem(colorName[i])); outerMI[i].setFont(font); outerMI[i].setIcon(squares[i]); outerMI[i].addActionListener(this); } }
public void actionPerformed(ActionEvent e) { for (int i = 0; i < colors.length; i++) { if (e.getSource().equals(innerMI[i])) { demo.innerC = colors[i]; imenu.setIcon(squares[i]); break; } else if (e.getSource().equals(outerMI[i])) { demo.outerC = colors[i]; omenu.setIcon(squares[i]); break; } } demo.repaint(); }
/** Remove all types from the menu. Then cycle through all available values, and add them. */ public static void populateSpecialFieldMenu(JMenu menu, SpecialField field, JabRefFrame frame) { menu.setText(field.getMenuString()); menu.setIcon(((IconTheme.FontBasedIcon) field.getRepresentingIcon()).createSmallIcon()); for (SpecialFieldValue val : field.getValues()) { menu.add(val.getMenuAction(frame)); } }
private JMenuItem createSubMenu() throws MissingResourceException { String label = presenter.getSubmenuTitle(); JMenu subMenu = new JMenu(label); subMenu.setIcon(presenter.getIcon()); for (ServerRecord record : ServerList.getRecords()) { if (record.isRemote()) { String text = presenter.getItemTitle(record.getDisplayName()); JMenuItem item = new JMenuItem(text); item.putClientProperty(RemoteOpenActionBase.ENV_KEY, record.getExecutionEnvironment()); item.addActionListener(this); subMenu.add(item); } } if (subMenu.getItemCount() > 0) { subMenu.add(new JSeparator()); } JMenuItem item = new JMenuItem( NbBundle.getMessage( OpenRemoteProjectAction.class, "LBL_ManagePlatforms_Name")); // NOI18N item.putClientProperty(RemoteOpenActionBase.ENV_KEY, null); item.addActionListener(this); subMenu.add(item); return subMenu; }
/** * Updates menu configuration * * @param menu * @param prefix (in properties file) */ public void configureMenu(JMenu menu, String prefix) { menu.setName(prefix); String text = bundle.getString(prefix + ".text"); menu.setText(text); try { String mnemonic = bundle.getString(prefix + ".mnemonic"); menu.setMnemonic(mnemonic.charAt(0)); } catch (MissingResourceException exception) { // ok not to set mnemonic } try { String tooltip = bundle.getString(prefix + ".tooltip"); menu.setToolTipText(tooltip); } catch (MissingResourceException exception) { // ok not to set tooltip } try { String iconPath = bundle.getString(prefix + ".icon"); if (iconPath != null) { ImageIcon icon = new ImageIcon(this.referenceClass.getResource(iconPath)); menu.setIcon(icon); } } catch (MissingResourceException exception) { // ok not to set tooltip } }
/** Remove all types from the menu. Then cycle through all available values, and add them. */ public static void populateSpecialFieldMenu(JMenu menu, SpecialField field, JabRefFrame frame) { // menu.removeAll(); menu.setText(field.getMenuString()); menu.setIcon(field.getRepresentingIcon()); for (SpecialFieldValue val : field.getValues()) { menu.add(val.getMenuAction(frame)); } }
private void createSelectAnotherMenu(int mode) { if (mode == EuclidianConstants.MODE_MOVE) { selectAnotherMenu = new JMenu(app.getMenu("SelectAnother")); } else { selectAnotherMenu = new JMenu(app.getMenu("PerformToolOn")); } selectAnotherMenu.setIcon(((AppD) app).getEmptyIcon()); selectAnotherMenu.setBackground(getWrappedPopup().getBackground()); selectAnotherMenu.setFont(((AppD) app).getItalicFont()); }
private JMenu createViewMenu(RecordLedgerTable table) { final JMenu view = new JMenu("View"); view.setMnemonic('v'); view.add(application.getAction(SelectAllRecords.COMMAND)); view.add(application.getAction(ShowAllColumns.COMMAND)); view.addSeparator(); view.add(application.getAction(Filter.COMMAND)); view.add(application.getAction(FilterBySelection.COMMAND)); view.addSeparator(); final JMenu viewColumns = new JMenu("Columns"); viewColumns.setIcon(new ImageIcon("/resources/icons/filter_columns.png")); viewColumns.addMenuListener(new VisibleColumnsMenuManager(table.getTableFormat())); view.add(viewColumns); final JMenu viewTypes = new JMenu("Types"); viewTypes.setIcon(new ImageIcon("/resources/icons/editRecordTypes.png")); viewTypes.addMenuListener(new RecordTypesMenuManager(application)); view.add(viewTypes); return view; }
/** @param args the command line arguments */ public static void main(String[] args) { JFrame frame = new JFrame("Editing and Mouse Menu Demo"); SparseMultigraph<GraphElements.MyVertex, GraphElements.MyEdge> g = new SparseMultigraph<GraphElements.MyVertex, GraphElements.MyEdge>(); // Layout<V, E>, VisualizationViewer<V,E> // Map<GraphElements.MyVertex,Point2D> vertexLocations = new // HashMap<GraphElements.MyVertex, Point2D>(); Layout<GraphElements.MyVertex, GraphElements.MyEdge> layout = new StaticLayout(g); layout.setSize(new Dimension(300, 300)); VisualizationViewer<GraphElements.MyVertex, GraphElements.MyEdge> vv = new VisualizationViewer<GraphElements.MyVertex, GraphElements.MyEdge>(layout); vv.setPreferredSize(new Dimension(350, 350)); // Show vertex and edge labels vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller()); // Create a graph mouse and add it to the visualization viewer EditingModalGraphMouse gm = new EditingModalGraphMouse( vv.getRenderContext(), GraphElements.MyVertexFactory.getInstance(), GraphElements.MyEdgeFactory.getInstance()); // Set some defaults for the Edges... GraphElements.MyEdgeFactory.setDefaultCapacity(192.0); GraphElements.MyEdgeFactory.setDefaultWeight(5.0); // Trying out our new popup menu mouse plugin... PopupVertexEdgeMenuMousePlugin myPlugin = new PopupVertexEdgeMenuMousePlugin(); // Add some popup menus for the edges and vertices to our mouse plugin. JPopupMenu edgeMenu = new MyMouseMenus.EdgeMenu(frame); JPopupMenu vertexMenu = new MyMouseMenus.VertexMenu(); myPlugin.setEdgePopup(edgeMenu); myPlugin.setVertexPopup(vertexMenu); gm.remove(gm.getPopupEditingPlugin()); // Removes the existing popup editing plugin gm.add(myPlugin); // Add our new plugin to the mouse vv.setGraphMouse(gm); // JFrame frame = new JFrame("Editing and Mouse Menu Demo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(vv); // Let's add a menu for changing mouse modes JMenuBar menuBar = new JMenuBar(); JMenu modeMenu = gm.getModeMenu(); modeMenu.setText("Mouse Mode"); modeMenu.setIcon(null); // I'm using this in a main menu modeMenu.setPreferredSize(new Dimension(80, 20)); // Change the size so I can see the text menuBar.add(modeMenu); frame.setJMenuBar(menuBar); gm.setMode(ModalGraphMouse.Mode.EDITING); // Start off in editing mode frame.pack(); frame.setVisible(true); }
public JPopupMenu makePopup(Obj obj) { JPopupMenu menu = new JPopupMenu(); Op[] ops = (Op[]) obj.list(Op.class); if (ops.length > 0) { JMenu sub = new JMenu("Operations"); sub.setIcon(UiSession.iconOp); for (int i = 0; i < ops.length; ++i) sub.add(new Invoke(ops[i])); menu.add(sub); } if (obj.getHref() != null) menu.add(new Goto(obj.getNormalizedHref())); if (obj instanceof Op) menu.add(new Invoke((Op) obj)); return menu; }
/** * Gets the <tt>JMenu</tt> which is the component of this plug-in. If it still doesn't exist, it's * created. * * @return the <tt>JMenu</tt> which is the component of this plug-in */ private JMenu getMenu() { if (menu == null) { menu = new SIPCommMenu(); menu.setText(getName()); if (Container.CONTAINER_CONTACT_RIGHT_BUTTON_MENU.equals(getContainer())) { Icon icon = OtrActivator.resourceService.getImage("plugin.otr.MENU_ITEM_ICON_16x16"); if (icon != null) menu.setIcon(icon); } if (!inMacOSXScreenMenuBar) menu.getPopupMenu().addPopupMenuListener(this); } return menu; }
public static void main(String args[]) { JFrame frame = new JFrame("Welcome To MLDN"); JTextArea text = new JTextArea(); text.setEditable(true); // 可编辑 frame.getContentPane().add(new JScrollPane(text)); // 加入滚动条 JMenu menu1 = new JMenu("文件"); // menuFile.setIcon(new ImageIcon("d:"+File.separator+"icons"+File.separator+"file.gif")) ; menu1.setIcon(new ImageIcon("icons" + File.separator + "file.gif")); // 创建JMenuBar 容器 JMenuBar menuBar = new JMenuBar(); menuBar.add(menu1); // 此时定义完了四个菜单的选项 JMenuItem newItem = new JMenuItem("新建", new ImageIcon("icons" + File.separator + "new.gif")); JMenuItem openItem = new JMenuItem("打开", new ImageIcon("icons" + File.separator + "open.gif")); JMenuItem closeItem = new JMenuItem("关闭", new ImageIcon("icons" + File.separator + "close.gif")); JMenuItem exitItem = new JMenuItem("退出", new ImageIcon("icons" + File.separator + "exit.gif")); // 增加快捷键 newItem.setMnemonic('N'); openItem.setMnemonic('O'); closeItem.setMnemonic('C'); exitItem.setMnemonic('E'); newItem.setAccelerator(KeyStroke.getKeyStroke('N', java.awt.Event.CTRL_MASK)); openItem.setAccelerator(KeyStroke.getKeyStroke('O', java.awt.Event.CTRL_MASK)); closeItem.setAccelerator(KeyStroke.getKeyStroke('C', java.awt.Event.ALT_MASK)); exitItem.setAccelerator(KeyStroke.getKeyStroke('E', java.awt.Event.ALT_MASK)); menu1.add(newItem); menu1.add(openItem); menu1.add(closeItem); menu1.add(exitItem); frame.setJMenuBar(menuBar); // 菜单是需要通过此方法增加的 frame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(1); } }); frame.setVisible(true); frame.setSize(300, 100); frame.setLocation(300, 200); }
/** Create a submenu with teh different messages for one status. */ private static JMenu createSubMenu(final int status) { JMenu subMenu = new JMenu(); I18N.setTextAndMnemonic(Presence.getI18NKey(status), subMenu); subMenu.setIcon(StatusIcons.getStatusIcon(status)); List messages = Preferences.getStatusMessages(status); for (Iterator it = messages.iterator(); it.hasNext(); ) { final String messageText = (String) it.next(); JMenuItem menuItem = new JMenuItem(messageText); menuItem.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { changeStatus(status, messageText); } }); subMenu.add(menuItem); } return subMenu; }
private void setMouseSettings() { // mouse interaction EditingModalGraphMouse<VertexNode, EdgeLink> gm = new EditingModalGraphMouse<VertexNode, EdgeLink>(getRenderContext(), vFactory, eFactory); // Trying out our new popup menu mouse plugin... PopupMousePlugin<VertexNode, EdgeLink> myPlugin = new PopupMousePlugin<VertexNode, EdgeLink>(); gm.remove(gm.getPopupEditingPlugin()); // Removes the existing popup editing plugin gm.add(myPlugin); // Add our new plugin to the mouse // need an editing mouse that will notify when an edge is potentially created EditingNotifyingMousePlugin<VertexNode, EdgeLink> myEditor = new EditingNotifyingMousePlugin<VertexNode, EdgeLink>(); gm.add(myEditor); setGraphMouse(gm); // menu bar JMenuBar bar = new JMenuBar(); JMenu modeMenu = gm.getModeMenu(); modeMenu.setText("Mouse Mode"); modeMenu.setIcon(null); // I'm using this in a main menu modeMenu.setPreferredSize(new Dimension(200, 20)); // Change the size so I can see the text gm.setMode(ModalGraphMouse.Mode.EDITING); // Start off in editing mode JMenuItem refresh = new JMenuItem("Refresh Screen"); refresh.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { stateChanged(null); } }); bar.add(modeMenu); bar.add(refresh); add(bar); }
@Override public void install(Controller c) throws Exception { super.install(c); viewMenuBar = c.getPlugin(ViewMenuBar.class); View view = c.getPlugin(View.class); ViewerSwitch viewer = view.getViewer(); Component parent = viewer.getViewingComponent(); exportMenu.setIcon(ImageHook.getIcon("disk.png")); exportMenu.add(new ExportImage("Image", viewer, parent)); exportMenu.add(new ExportScreenshot("Screenshot", viewer, parent)); exportMenu.add(new ExportRIB("RIB", viewer, parent)); exportMenu.add(new ExportSVG("SVG", viewer, parent)); exportMenu.add(new ExportPS("PS", viewer, parent)); exportMenu.add(new ExportVRML("VRML", viewer, parent)); exportMenu.add(new ExportSTL("STL", viewer, parent)); exportMenu.add(new ExportOBJ("OBJ", viewer, parent)); exportMenu.add(new ExportU3D("U3D", viewer, parent)); exportMenu.add(exportPDF = new ExportPDF("PDF", viewer, parent)); exportMenu.add(new SunflowMenu(viewer)); SaveScene saveSceneAction = new SaveScene("Save Scene", viewer, parent); saveSceneAction.setIcon(ImageHook.getIcon("disk.png")); viewMenuBar.addMenuItem(getClass(), 1, saveSceneAction, "File"); viewMenuBar.addMenuItem(getClass(), 2, exportMenu, "File"); }
/** Initialize all items. */ private void updateItems() { removeAll(); JMenuItem mi; if (!app.isApplet()) { // "New" in application: new window mi = new JMenuItem(newWindowAction); setMenuShortCutAccelerator(mi, 'N'); add(mi); } // "New": reset mi = add(deleteAll); mi = add(loadAction); setMenuShortCutAccelerator(mi, 'O'); // open mi = add(loadURLAction); addSeparator(); mi = add(saveAction); setMenuShortCutAccelerator(mi, 'S'); mi = add(saveAsAction); addSeparator(); mi = add(printEuclidianViewAction); mi.setText(app.getMenu("PrintPreview")); mi.setIcon(app.getImageIcon("document-print-preview.png")); setMenuShortCutAccelerator(mi, 'P'); addSeparator(); mi = add(exportLMSAction); addSeparator(); // export JMenu submenu = new JMenu(app.getMenu("Export")); submenu.setIcon(app.getEmptyIcon()); add(submenu); mi = submenu.add(exportWorksheet); setMenuShortCutShiftAccelerator(mi, 'W'); mi = submenu.add(exportGraphicAction); setMenuShortCutShiftAccelerator(mi, 'P'); mi = submenu.add(drawingPadToClipboardAction); setMenuShortCutShiftAccelerator(mi, 'C'); submenu.addSeparator(); mi = submenu.add(exportPSTricksAction); setMenuShortCutShiftAccelerator(mi, 'T'); mi = submenu.add(exportPgfAction); mi = submenu.add(exportAsymptoteAction); // End Export SubMenu // mi = submenu.add(exportGeoGebraTubeAction); // DONE HERE WHEN APPLET if (app.isApplet()) return; // recent SubMenu addSeparator(); JMenu submenuRecent = new JMenu(app.getMenu("Recent")); submenu.setIcon(app.getEmptyIcon()); add(submenuRecent); // Recent files list int size = Application.getFileListSize(); if (size > 0) { for (int i = 0; i < Application.MAX_RECENT_FILES; i++) { File file = Application.getFromFileList(i); if (file != null) { mi = new JMenuItem(file.getName()); mi.setIcon(app.getImageIcon("geogebra.gif")); ActionListener al = new LoadFileListener(app, file); mi.addActionListener(al); submenuRecent.add(mi); } } } // close addSeparator(); mi = add(exitAction); if (Application.MAC_OS) { setMenuShortCutAccelerator(mi, 'W'); } else { // Alt + F4 KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_F4, InputEvent.ALT_MASK); mi.setAccelerator(ks); } // close all if (GeoGebraFrame.getInstanceCount() > 1) { add(exitAllAction); } }
public JMenuLookup(final Program program) { super(GuiShared.get().lookup(), program); ListenerClass listener = new ListenerClass(); this.setIcon(Images.LINK_LOOKUP.getIcon()); jDotlan = new JMenu(GuiShared.get().dotlan()); jDotlan.setIcon(Images.LINK_DOTLAN_EVEMAPS.getIcon()); add(jDotlan); jDotlanStation = new JMenuItem(GuiShared.get().station()); jDotlanStation.setIcon(Images.LOC_STATION.getIcon()); jDotlanStation.setActionCommand(MenuLookupAction.EVEMAPS_DOTLAN_STATION.name()); jDotlanStation.addActionListener(listener); jDotlan.add(jDotlanStation); jDotlanSystem = new JMenuItem(GuiShared.get().system()); jDotlanSystem.setIcon(Images.LOC_SYSTEM.getIcon()); jDotlanSystem.setActionCommand(MenuLookupAction.EVEMAPS_DOTLAN_SYSTEM.name()); jDotlanSystem.addActionListener(listener); jDotlan.add(jDotlanSystem); jDotlanRegion = new JMenuItem(GuiShared.get().region()); jDotlanRegion.setIcon(Images.LOC_REGION.getIcon()); jDotlanRegion.setActionCommand(MenuLookupAction.EVEMAPS_DOTLAN_REGION.name()); jDotlanRegion.addActionListener(listener); jDotlan.add(jDotlanRegion); jDotlanLocations = new JMenuItem(TabsOverview.get().locations()); jDotlanLocations.setIcon(Images.LOC_LOCATIONS.getIcon()); addSeparator(); jEveCentral = new JMenuItem(GuiShared.get().eveCentral()); jEveCentral.setIcon(Images.LINK_EVE_CENTRAL.getIcon()); jEveCentral.setActionCommand(MenuLookupAction.EVE_CENTRAL.name()); jEveCentral.addActionListener(listener); add(jEveCentral); jEveMarketdata = new JMenuItem(GuiShared.get().eveMarketdata()); jEveMarketdata.setIcon(Images.LINK_EVE_MARKETDATA.getIcon()); jEveMarketdata.setActionCommand(MenuLookupAction.EVE_MARKETDATA.name()); jEveMarketdata.addActionListener(listener); add(jEveMarketdata); // Dead /* jEveMarketeer = new JMenuItem(GuiShared.get().eveMarketeer()); jEveMarketeer.setIcon(Images.LINK_EVEMARKETEER.getIcon()); jEveMarketeer.setActionCommand(MenuLookupAction.EVEMARKETEER.name()); jEveMarketeer.addActionListener(listener); add(jEveMarketeer); */ jEveMarkets = new JMenuItem(GuiShared.get().eveMarkets()); jEveMarkets.setIcon(Images.LINK_EVE_MARKETS.getIcon()); jEveMarkets.setActionCommand(MenuLookupAction.EVE_MARKETS.name()); jEveMarkets.addActionListener(listener); add(jEveMarkets); // Dead /* jEveAddicts = new JMenuItem(GuiShared.get().eveAddicts()); jEveAddicts.setIcon(Images.LINK_EVE_ADDICTS.getIcon()); jEveAddicts.setActionCommand(MenuLookupAction.EVE_ADDICTS.name()); jEveAddicts.addActionListener(listener); add(jEveAddicts); */ addSeparator(); jChruker = new JMenuItem(GuiShared.get().chruker()); jChruker.setIcon(Images.LINK_CHRUKER.getIcon()); jChruker.setActionCommand(MenuLookupAction.GAMES_CHRUKER.name()); jChruker.addActionListener(listener); add(jChruker); jEveOnline = new JMenuItem(GuiShared.get().eveOnline()); jEveOnline.setIcon(Images.MISC_EVE.getIcon()); jEveOnline.setActionCommand(MenuLookupAction.EVE_ITEM_DATABASE.name()); jEveOnline.addActionListener(listener); add(jEveOnline); }
/** * Creates new ZoomMenu * * @param app * @param px * @param py */ public ContextMenuGraphicsWindow(Application app, double px, double py) { this(app); iconZoom = app.getImageIcon("zoom16.gif"); // zoom point this.px = px; this.py = py; EuclidianViewInterfaceCommon ev = app.getActiveEuclidianView(); if (ev.getEuclidianViewNo() == 2) { setTitle("<html>" + app.getPlain("DrawingPad2") + "</html>"); } else { setTitle("<html>" + app.getPlain("DrawingPad") + "</html>"); } addAxesAndGridCheckBoxes(); addSeparator(); // zoom for both axes JMenu zoomMenu = new JMenu(app.getMenu("Zoom")); zoomMenu.setIcon(iconZoom); zoomMenu.setBackground(getBackground()); addZoomItems(zoomMenu); add(zoomMenu); // zoom for y-axis JMenu yaxisMenu = new JMenu(app.getPlain("xAxis") + " : " + app.getPlain("yAxis")); yaxisMenu.setIcon(app.getEmptyIcon()); yaxisMenu.setBackground(getBackground()); addAxesRatioItems(yaxisMenu); add(yaxisMenu); JMenuItem miShowAllObjectsView = new JMenuItem(app.getPlain("ShowAllObjects")); miShowAllObjectsView.setIcon(app.getEmptyIcon()); miShowAllObjectsView.setActionCommand("showAllObjects"); miShowAllObjectsView.addActionListener(this); miShowAllObjectsView.setBackground(bgColor); add(miShowAllObjectsView); JMenuItem miStandardView = new JMenuItem(app.getPlain("StandardView")); setMenuShortCutAccelerator(miStandardView, 'M'); miStandardView.setIcon(app.getEmptyIcon()); miStandardView.setActionCommand("standardView"); miStandardView.addActionListener(this); miStandardView.setBackground(bgColor); add(miStandardView); addSeparator(); if (!ev.isZoomable()) { zoomMenu.setEnabled(false); yaxisMenu.setEnabled(false); miShowAllObjectsView.setEnabled(false); miStandardView.setEnabled(false); } if (ev.isUnitAxesRatio()) { yaxisMenu.setEnabled(false); } addMiProperties(); }
/** Initialize the contents of the frame. */ private void initialize() { Image img = new ImageIcon(this.getClass().getResource("/logo2.jpg")).getImage(); frame = new JFrame(); frame.setBackground(new Color(0, 153, 255)); frame.getContentPane().setBackground(Color.WHITE); frame.setIconImage(img); JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP); tabbedPane.setFont(new Font("Microsoft YaHei UI Light", Font.PLAIN, 13)); tabbedPane.setBackground(Color.WHITE); frame.getContentPane().add(tabbedPane, BorderLayout.CENTER); frame.setResizable(false); JPanel panel = new JPanel(); panel.setBackground(new Color(255, 255, 255)); tabbedPane.addTab("Ewidencja", null, panel, null); SpringLayout sl_panel = new SpringLayout(); panel.setLayout(sl_panel); JLabel lblISBN_1 = new JLabel("Kod ISBN:"); lblISBN_1.setForeground(new Color(0, 102, 255)); sl_panel.putConstraint(SpringLayout.WEST, lblISBN_1, 10, SpringLayout.WEST, panel); lblISBN_1.setFont(new Font("Microsoft YaHei UI Light", Font.PLAIN, 20)); panel.add(lblISBN_1); JLabel lblINFO = new JLabel("INFORMACJE:"); sl_panel.putConstraint(SpringLayout.NORTH, lblINFO, 0, SpringLayout.NORTH, lblISBN_1); lblINFO.setForeground(new Color(0, 102, 255)); lblINFO.setFont(new Font("Microsoft YaHei UI Light", Font.PLAIN, 20)); panel.add(lblINFO); JLabel lblWyszukaj = new JLabel("Wyszukaj:"); sl_panel.putConstraint(SpringLayout.WEST, lblWyszukaj, 0, SpringLayout.WEST, lblISBN_1); lblWyszukaj.setForeground(new Color(0, 102, 255)); lblWyszukaj.setFont(new Font("Microsoft YaHei UI Light", Font.PLAIN, 20)); panel.add(lblWyszukaj); JButton btnZnajd = new JButton("Znajd\u017A\r\n"); btnZnajd.setBackground(SystemColor.control); btnZnajd.setFont(new Font("Microsoft YaHei UI Light", Font.PLAIN, 15)); // ImageIcon im = new ImageIcon(getClass().getResource("/Calculator.png")); // btnZnajd.setIcon(im); panel.add(btnZnajd); JButton btnSprawdz = new JButton("Sprawd\u017A"); sl_panel.putConstraint(SpringLayout.NORTH, btnSprawdz, 103, SpringLayout.NORTH, panel); btnSprawdz.setForeground(Color.BLACK); btnSprawdz.setBackground(SystemColor.control); btnSprawdz.setFont(new Font("Microsoft YaHei UI Light", Font.PLAIN, 14)); panel.add(btnSprawdz); JButton btnDodaj = new JButton("Dodaj"); sl_panel.putConstraint(SpringLayout.WEST, btnZnajd, -32, SpringLayout.WEST, btnDodaj); sl_panel.putConstraint(SpringLayout.WEST, btnDodaj, 236, SpringLayout.WEST, panel); sl_panel.putConstraint(SpringLayout.EAST, btnSprawdz, -15, SpringLayout.WEST, btnDodaj); btnDodaj.setBackground(new Color(255, 255, 255)); btnDodaj.setFont(new Font("Microsoft YaHei UI Light", Font.PLAIN, 14)); panel.add(btnDodaj); final JTextField textISBN_1 = new JTextField(); sl_panel.putConstraint(SpringLayout.WEST, textISBN_1, 10, SpringLayout.WEST, panel); sl_panel.putConstraint(SpringLayout.NORTH, btnDodaj, 6, SpringLayout.SOUTH, textISBN_1); sl_panel.putConstraint(SpringLayout.NORTH, lblWyszukaj, 67, SpringLayout.SOUTH, textISBN_1); sl_panel.putConstraint(SpringLayout.SOUTH, lblISBN_1, -6, SpringLayout.NORTH, textISBN_1); sl_panel.putConstraint(SpringLayout.SOUTH, textISBN_1, -6, SpringLayout.NORTH, btnSprawdz); textISBN_1.setFont(new Font("Segoe UI Light", Font.PLAIN, 18)); textISBN_1.setBorder(new LineBorder(new Color(0, 102, 204))); textISBN_1.addMouseListener( new MouseAdapter() { @Override public void mouseEntered(MouseEvent arg0) { textISBN_1.setBorder(new LineBorder(new Color(0, 0, 0))); } @Override public void mouseExited(MouseEvent arg0) { textISBN_1.setBorder(new LineBorder(new Color(0, 102, 204))); } }); panel.add(textISBN_1); JLabel lblSOWA = new JLabel(""); sl_panel.putConstraint(SpringLayout.NORTH, lblSOWA, 487, SpringLayout.NORTH, panel); sl_panel.putConstraint(SpringLayout.WEST, lblSOWA, 0, SpringLayout.WEST, lblISBN_1); sl_panel.putConstraint(SpringLayout.SOUTH, lblSOWA, -10, SpringLayout.SOUTH, panel); sl_panel.putConstraint(SpringLayout.EAST, lblSOWA, -929, SpringLayout.EAST, panel); lblSOWA.setIcon(new ImageIcon(img)); panel.add(lblSOWA); final JTextField textWyszukaj = new JTextField(); sl_panel.putConstraint(SpringLayout.SOUTH, btnZnajd, 33, SpringLayout.SOUTH, textWyszukaj); sl_panel.putConstraint(SpringLayout.WEST, textWyszukaj, 10, SpringLayout.WEST, panel); sl_panel.putConstraint(SpringLayout.NORTH, btnZnajd, 6, SpringLayout.SOUTH, textWyszukaj); sl_panel.putConstraint(SpringLayout.NORTH, textWyszukaj, 6, SpringLayout.SOUTH, lblWyszukaj); textWyszukaj.setFont(new Font("Segoe UI Light", Font.PLAIN, 18)); textWyszukaj.setBorder(new LineBorder(new Color(0, 102, 204))); textWyszukaj.addMouseListener( new MouseAdapter() { @Override public void mouseEntered(MouseEvent arg0) { textWyszukaj.setBorder(new LineBorder(new Color(0, 0, 0))); } @Override public void mouseExited(MouseEvent arg0) { textWyszukaj.setBorder(new LineBorder(new Color(0, 102, 204))); } }); panel.add(textWyszukaj); JScrollPane scrollPane_1 = new JScrollPane(); sl_panel.putConstraint(SpringLayout.EAST, textISBN_1, -322, SpringLayout.WEST, scrollPane_1); sl_panel.putConstraint(SpringLayout.EAST, btnDodaj, -322, SpringLayout.WEST, scrollPane_1); sl_panel.putConstraint(SpringLayout.WEST, scrollPane_1, 627, SpringLayout.WEST, panel); sl_panel.putConstraint(SpringLayout.EAST, textWyszukaj, -322, SpringLayout.WEST, scrollPane_1); sl_panel.putConstraint(SpringLayout.EAST, btnZnajd, -322, SpringLayout.WEST, scrollPane_1); sl_panel.putConstraint(SpringLayout.NORTH, scrollPane_1, 6, SpringLayout.SOUTH, lblINFO); sl_panel.putConstraint(SpringLayout.SOUTH, scrollPane_1, -10, SpringLayout.SOUTH, panel); sl_panel.putConstraint(SpringLayout.EAST, scrollPane_1, -7, SpringLayout.EAST, panel); sl_panel.putConstraint(SpringLayout.WEST, lblINFO, 0, SpringLayout.WEST, scrollPane_1); scrollPane_1.setBorder(new LineBorder(new Color(0, 102, 204))); scrollPane_1.addMouseListener( new MouseAdapter() { @Override public void mouseEntered(MouseEvent arg0) { scrollPane_1.setBorder(new LineBorder(new Color(0, 0, 0))); } @Override public void mouseExited(MouseEvent arg0) { scrollPane_1.setBorder(new LineBorder(new Color(0, 102, 204))); } }); panel.add(scrollPane_1); final JTextArea textArea = new JTextArea(); scrollPane_1.setViewportView(textArea); sl_panel.putConstraint(SpringLayout.NORTH, textArea, 243, SpringLayout.NORTH, panel); sl_panel.putConstraint(SpringLayout.EAST, textArea, -346, SpringLayout.EAST, panel); textArea.setFont(new Font("Segoe UI Light", Font.PLAIN, 18)); textArea.setEditable(false); textArea.setBackground(Color.WHITE); sl_panel.putConstraint(SpringLayout.WEST, textArea, 16, SpringLayout.EAST, lblSOWA); sl_panel.putConstraint(SpringLayout.SOUTH, textArea, 0, SpringLayout.SOUTH, lblSOWA); btnSprawdz.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { excel.getArrayListBook().clear(); textArea.setText(null); try { textArea.setText( excel.arrayStringValue(excel.searchBook(textISBN_1.getText(), path))); textISBN_1.setText(null); } catch (FileNotFoundException e) { e.printStackTrace(); JOptionPane.showMessageDialog( null, "Brak pliku Ÿród³owego lub plik jest otwarty w innym programie!"); } catch (Exception e) { e.printStackTrace(); } excel.getArrayListBook().clear(); } }); btnZnajd.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { textArea.setText(null); excel.getArrayListBook().clear(); try { textArea.setText( excel.arrayStringValue(excel.searchBook(textWyszukaj.getText(), path))); textWyszukaj.setText(null); } catch (FileNotFoundException ex) { ex.printStackTrace(); JOptionPane.showMessageDialog( null, "Brak pliku Ÿród³owego lub plik jest otwarty w innym programie!"); } catch (Exception ea) { ea.printStackTrace(); } excel.getArrayListBook().clear(); } }); textISBN_1.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { excel.getArrayListBook().clear(); textArea.setText(null); try { textArea.setText( excel.arrayStringValue(excel.searchBook(textISBN_1.getText(), path))); textISBN_1.setText(null); } catch (FileNotFoundException ex) { ex.printStackTrace(); JOptionPane.showMessageDialog( null, "Brak pliku Ÿród³owego lub plik jest otwarty w innym programie!"); } catch (Exception ex) { ex.printStackTrace(); } excel.getArrayListBook().clear(); } }); textWyszukaj.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { excel.getArrayListBook().clear(); textArea.setText(null); try { textArea.setText( excel.arrayStringValue(excel.searchBook(textWyszukaj.getText(), path))); textWyszukaj.setText(null); } catch (FileNotFoundException ex) { ex.printStackTrace(); JOptionPane.showMessageDialog( null, "Brak pliku Ÿród³owego lub plik jest otwarty w innym programie!"); } catch (Exception ex) { ex.printStackTrace(); } excel.getArrayListBook().clear(); } }); btnDodaj.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { excel.getArrayListBook().clear(); textArea.setText(null); try { textArea.setText( excel.arrayStringValue(excel.searchBook(textISBN_1.getText(), path))); textISBN_1.setText(null); } catch (FileNotFoundException e) { e.printStackTrace(); JOptionPane.showMessageDialog( null, "Brak pliku Ÿród³owego lub plik jest otwarty w innym programie!"); } catch (Exception e) { e.printStackTrace(); } try { for (int i = 0; i < excel.getArrayListBook().size(); i++) excel.addBookToExcel(excel.getArrayListBook().get(i), path); } catch (IOException e) { e.printStackTrace(); } excel.getArrayListBook().clear(); } }); JMenuBar menuBar = new JMenuBar(); menuBar.setForeground(new Color(51, 153, 255)); menuBar.setBackground(new Color(0, 153, 255)); frame.setJMenuBar(menuBar); JMenu mnFile = new JMenu("Plik"); menuBar.add(mnFile); Image img3 = new ImageIcon(this.getClass().getResource("/open.jpg")).getImage(); JMenu mnOtworz = new JMenu("Otw\u00F3rz..."); mnFile.add(mnOtworz); mnOtworz.setIcon(new ImageIcon(img3)); Image img2 = new ImageIcon(this.getClass().getResource("/excel.jpg")).getImage(); JMenuItem mntmArkuszRejestru = new JMenuItem("Arkusz rejestru"); mnOtworz.add(mntmArkuszRejestru); mntmArkuszRejestru.setIcon(new ImageIcon(img2)); mntmArkuszRejestru.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { try { JFileChooser chooser = new JFileChooser(); chooser.showOpenDialog(null); File f = chooser.getSelectedFile(); path2 = f.getAbsolutePath(); } catch (NullPointerException ex) { ex.printStackTrace(); } } }); JMenuItem mntmArkuszEwidencyjny = new JMenuItem("Arkusz ewidencyjny"); mntmArkuszEwidencyjny.setIcon(new ImageIcon(img2)); mntmArkuszEwidencyjny.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { try { JFileChooser chooser = new JFileChooser(); chooser.showOpenDialog(null); File f = chooser.getSelectedFile(); path = f.getAbsolutePath(); } catch (NullPointerException ex) { ex.printStackTrace(); } } }); mnOtworz.add(mntmArkuszEwidencyjny); JMenu mnNarzdzia = new JMenu("Narz\u0119dzia"); menuBar.add(mnNarzdzia); JMenuItem mntmWycennik = new JMenuItem("Wycennik"); mntmWycennik.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { JFrame calc = new JFrame(); calc.setBounds(100, 100, 580, 361); // calc.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); calc.setVisible(true); calc.setResizable(false); JPanel panel_calc = new JPanel(); panel_calc.setBackground(new Color(154, 205, 50)); calc.getContentPane().add(panel_calc, BorderLayout.CENTER); SpringLayout sl_panel_calc = new SpringLayout(); panel_calc.setLayout(sl_panel_calc); final JTextArea textArea_calc = new JTextArea(); sl_panel_calc.putConstraint( SpringLayout.WEST, textArea_calc, 60, SpringLayout.WEST, panel_calc); sl_panel_calc.putConstraint( SpringLayout.SOUTH, textArea_calc, -107, SpringLayout.SOUTH, panel_calc); sl_panel_calc.putConstraint( SpringLayout.EAST, textArea_calc, -57, SpringLayout.EAST, panel_calc); textArea_calc.setEditable(false); textArea_calc.setFont(new Font("Microsoft YaHei UI Light", Font.PLAIN, 16)); panel_calc.add(textArea_calc); final JTextField textField_1_calc = new JTextField(); sl_panel_calc.putConstraint( SpringLayout.WEST, textField_1_calc, 111, SpringLayout.WEST, panel_calc); sl_panel_calc.putConstraint( SpringLayout.SOUTH, textField_1_calc, -24, SpringLayout.SOUTH, panel_calc); sl_panel_calc.putConstraint( SpringLayout.EAST, textField_1_calc, -107, SpringLayout.EAST, panel_calc); textField_1_calc.setFont(new Font("Microsoft JhengHei UI Light", Font.PLAIN, 16)); panel_calc.add(textField_1_calc); textField_1_calc.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { textArea_calc.setText(null); Double price = Double.parseDouble(textField_1_calc.getText()); textField_1_calc.setText(null); String price_percent = "75% - " + price * 75 / 100 + "z³ (Stan Bdb- oraz 2 i 3 LO rozszerzenia)\n" + "80% - " + price * 80 / 100 + "z³ (specjalistyczne)\n" + "85% - " + price * 85 / 100 + "z³ (nowe)\n" + "70% - " + price * 70 / 100 + "z³ (pozosta³e)\n"; textArea_calc.setText(price_percent); } }); JLabel Wycena_calc = new JLabel("Wycena:"); sl_panel_calc.putConstraint( SpringLayout.WEST, Wycena_calc, 60, SpringLayout.WEST, panel_calc); sl_panel_calc.putConstraint( SpringLayout.SOUTH, Wycena_calc, -283, SpringLayout.SOUTH, panel_calc); sl_panel_calc.putConstraint( SpringLayout.NORTH, textArea_calc, 6, SpringLayout.SOUTH, Wycena_calc); Wycena_calc.setForeground(new Color(255, 255, 255)); Wycena_calc.setBackground(new Color(255, 255, 255)); Wycena_calc.setFont(new Font("Microsoft YaHei UI Light", Font.BOLD, 20)); panel_calc.add(Wycena_calc); JLabel lblCena = new JLabel("Cena:"); sl_panel_calc.putConstraint( SpringLayout.WEST, lblCena, 0, SpringLayout.WEST, textField_1_calc); sl_panel_calc.putConstraint( SpringLayout.SOUTH, lblCena, -6, SpringLayout.NORTH, textField_1_calc); lblCena.setForeground(Color.WHITE); lblCena.setFont(new Font("Microsoft YaHei UI Light", Font.BOLD, 20)); lblCena.setBackground(Color.WHITE); panel_calc.add(lblCena); } }); mnNarzdzia.add(mntmWycennik); JPanel panel_2 = new JPanel(); panel_2.setBackground(new Color(255, 255, 255)); tabbedPane.addTab("Uzupe\u0142nianie", null, panel_2, null); SpringLayout sl_panel_2 = new SpringLayout(); panel_2.setLayout(sl_panel_2); JLabel label = new JLabel("Kod ISBN:"); label.setBackground(new Color(255, 255, 255)); label.setForeground(new Color(0, 102, 255)); label.setFont(new Font("Microsoft YaHei UI Light", Font.PLAIN, 20)); panel_2.add(label); final JTextField textISBN_3 = new JTextField(); sl_panel_2.putConstraint(SpringLayout.WEST, textISBN_3, 44, SpringLayout.WEST, panel_2); sl_panel_2.putConstraint(SpringLayout.EAST, textISBN_3, -631, SpringLayout.EAST, panel_2); sl_panel_2.putConstraint(SpringLayout.WEST, label, 0, SpringLayout.WEST, textISBN_3); sl_panel_2.putConstraint(SpringLayout.SOUTH, label, -6, SpringLayout.NORTH, textISBN_3); textISBN_3.setFont(new Font("Segoe UI Light", Font.PLAIN, 18)); textISBN_3.setBorder(new LineBorder(new Color(0, 102, 204))); textISBN_3.addMouseListener( new MouseAdapter() { @Override public void mouseEntered(MouseEvent arg0) { textISBN_3.setBorder(new LineBorder(new Color(0, 0, 0))); } @Override public void mouseExited(MouseEvent arg0) { textISBN_3.setBorder(new LineBorder(new Color(0, 102, 204))); } }); panel_2.add(textISBN_3); final JTextField textPrice = new JTextField(); sl_panel_2.putConstraint(SpringLayout.EAST, textPrice, -369, SpringLayout.EAST, panel_2); textPrice.setFont(new Font("Segoe UI Light", Font.PLAIN, 18)); textPrice.setBorder(new LineBorder(new Color(0, 102, 204))); textPrice.addMouseListener( new MouseAdapter() { @Override public void mouseEntered(MouseEvent arg0) { textPrice.setBorder(new LineBorder(new Color(0, 0, 0))); } @Override public void mouseExited(MouseEvent arg0) { textPrice.setBorder(new LineBorder(new Color(0, 102, 204))); } }); panel_2.add(textPrice); JLabel label_1 = new JLabel("Cena:"); sl_panel_2.putConstraint(SpringLayout.WEST, label_1, 0, SpringLayout.WEST, textPrice); sl_panel_2.putConstraint(SpringLayout.SOUTH, label_1, -6, SpringLayout.NORTH, textPrice); label_1.setForeground(new Color(0, 102, 255)); label_1.setFont(new Font("Microsoft YaHei UI Light", Font.PLAIN, 20)); panel_2.add(label_1); final JTextField textTitle = new JTextField(); sl_panel_2.putConstraint(SpringLayout.WEST, textTitle, 44, SpringLayout.WEST, panel_2); sl_panel_2.putConstraint(SpringLayout.EAST, textTitle, -765, SpringLayout.EAST, panel_2); textTitle.setFont(new Font("Segoe UI Light", Font.PLAIN, 18)); textTitle.setBorder(new LineBorder(new Color(0, 102, 204))); textTitle.addMouseListener( new MouseAdapter() { @Override public void mouseEntered(MouseEvent arg0) { textTitle.setBorder(new LineBorder(new Color(0, 0, 0))); } @Override public void mouseExited(MouseEvent arg0) { textTitle.setBorder(new LineBorder(new Color(0, 102, 204))); } }); panel_2.add(textTitle); JLabel lblTytu = new JLabel("Tytu\u0142:"); sl_panel_2.putConstraint(SpringLayout.SOUTH, lblTytu, -401, SpringLayout.SOUTH, panel_2); sl_panel_2.putConstraint(SpringLayout.NORTH, textTitle, 6, SpringLayout.SOUTH, lblTytu); sl_panel_2.putConstraint(SpringLayout.WEST, lblTytu, 44, SpringLayout.WEST, panel_2); sl_panel_2.putConstraint(SpringLayout.SOUTH, textISBN_3, -27, SpringLayout.NORTH, lblTytu); lblTytu.setForeground(new Color(0, 102, 255)); lblTytu.setFont(new Font("Microsoft YaHei UI Light", Font.PLAIN, 20)); panel_2.add(lblTytu); JLabel lblAutorzy = new JLabel("Autor(zy):"); sl_panel_2.putConstraint(SpringLayout.WEST, lblAutorzy, 44, SpringLayout.WEST, panel_2); sl_panel_2.putConstraint(SpringLayout.SOUTH, lblAutorzy, -319, SpringLayout.SOUTH, panel_2); lblAutorzy.setForeground(new Color(0, 102, 255)); lblAutorzy.setFont(new Font("Microsoft YaHei UI Light", Font.PLAIN, 20)); panel_2.add(lblAutorzy); final JTextField textAuthors = new JTextField(); sl_panel_2.putConstraint(SpringLayout.NORTH, textAuthors, 6, SpringLayout.SOUTH, lblAutorzy); sl_panel_2.putConstraint(SpringLayout.WEST, textAuthors, 44, SpringLayout.WEST, panel_2); sl_panel_2.putConstraint(SpringLayout.EAST, textAuthors, -765, SpringLayout.EAST, panel_2); textAuthors.setFont(new Font("Segoe UI Light", Font.PLAIN, 18)); textAuthors.setBorder(new LineBorder(new Color(0, 102, 204))); textAuthors.addMouseListener( new MouseAdapter() { @Override public void mouseEntered(MouseEvent arg0) { textAuthors.setBorder(new LineBorder(new Color(0, 0, 0))); } @Override public void mouseExited(MouseEvent arg0) { textAuthors.setBorder(new LineBorder(new Color(0, 102, 204))); } }); panel_2.add(textAuthors); JLabel lblIlo = new JLabel("Ilo\u015B\u0107:"); sl_panel_2.putConstraint(SpringLayout.WEST, lblIlo, 44, SpringLayout.WEST, panel_2); lblIlo.setForeground(new Color(0, 102, 255)); lblIlo.setFont(new Font("Microsoft YaHei UI Light", Font.PLAIN, 20)); panel_2.add(lblIlo); final JTextField textAmount = new JTextField(); sl_panel_2.putConstraint(SpringLayout.NORTH, textPrice, 0, SpringLayout.NORTH, textAmount); sl_panel_2.putConstraint(SpringLayout.NORTH, textAmount, 415, SpringLayout.NORTH, panel_2); sl_panel_2.putConstraint(SpringLayout.WEST, textAmount, 44, SpringLayout.WEST, panel_2); sl_panel_2.putConstraint(SpringLayout.EAST, textAmount, -990, SpringLayout.EAST, panel_2); sl_panel_2.putConstraint(SpringLayout.SOUTH, lblIlo, -6, SpringLayout.NORTH, textAmount); textAmount.setFont(new Font("Segoe UI Light", Font.PLAIN, 18)); textAmount.setBorder(new LineBorder(new Color(0, 102, 204))); textAmount.addMouseListener( new MouseAdapter() { @Override public void mouseEntered(MouseEvent arg0) { textAmount.setBorder(new LineBorder(new Color(0, 0, 0))); } @Override public void mouseExited(MouseEvent arg0) { textAmount.setBorder(new LineBorder(new Color(0, 102, 204))); } }); panel_2.add(textAmount); JLabel lblWydawnictwo = new JLabel("Wydawnictwo:"); sl_panel_2.putConstraint(SpringLayout.NORTH, lblWydawnictwo, 0, SpringLayout.NORTH, lblAutorzy); sl_panel_2.putConstraint(SpringLayout.WEST, lblWydawnictwo, 0, SpringLayout.WEST, textPrice); lblWydawnictwo.setForeground(new Color(0, 102, 255)); lblWydawnictwo.setFont(new Font("Microsoft YaHei UI Light", Font.PLAIN, 20)); panel_2.add(lblWydawnictwo); final JTextField textPublisher = new JTextField(); sl_panel_2.putConstraint(SpringLayout.NORTH, textPublisher, 0, SpringLayout.NORTH, textAuthors); sl_panel_2.putConstraint(SpringLayout.WEST, textPublisher, 0, SpringLayout.WEST, textPrice); sl_panel_2.putConstraint(SpringLayout.EAST, textPublisher, -141, SpringLayout.EAST, panel_2); textPublisher.setFont(new Font("Segoe UI Light", Font.PLAIN, 18)); textPublisher.setBorder(new LineBorder(new Color(0, 102, 204))); textPublisher.addMouseListener( new MouseAdapter() { @Override public void mouseEntered(MouseEvent arg0) { textPublisher.setBorder(new LineBorder(new Color(0, 0, 0))); } @Override public void mouseExited(MouseEvent arg0) { textPublisher.setBorder(new LineBorder(new Color(0, 102, 204))); } }); panel_2.add(textPublisher); final JTextField textLevel = new JTextField(); sl_panel_2.putConstraint(SpringLayout.NORTH, textLevel, 0, SpringLayout.NORTH, textISBN_3); sl_panel_2.putConstraint(SpringLayout.WEST, textLevel, 0, SpringLayout.WEST, textPrice); sl_panel_2.putConstraint(SpringLayout.EAST, textLevel, -43, SpringLayout.EAST, panel_2); textLevel.setFont(new Font("Segoe UI Light", Font.PLAIN, 18)); textLevel.setBorder(new LineBorder(new Color(0, 102, 204))); textLevel.addMouseListener( new MouseAdapter() { @Override public void mouseEntered(MouseEvent arg0) { textLevel.setBorder(new LineBorder(new Color(0, 0, 0))); } @Override public void mouseExited(MouseEvent arg0) { textLevel.setBorder(new LineBorder(new Color(0, 102, 204))); } }); panel_2.add(textLevel); JLabel lblPoziom = new JLabel("Poziom zaawansowania:"); sl_panel_2.putConstraint(SpringLayout.NORTH, lblPoziom, 0, SpringLayout.NORTH, label); sl_panel_2.putConstraint(SpringLayout.WEST, lblPoziom, 0, SpringLayout.WEST, textPrice); lblPoziom.setForeground(new Color(0, 102, 255)); lblPoziom.setFont(new Font("Microsoft YaHei UI Light", Font.PLAIN, 20)); panel_2.add(lblPoziom); final JTextField textSchool = new JTextField(); sl_panel_2.putConstraint(SpringLayout.NORTH, textSchool, 0, SpringLayout.NORTH, textTitle); sl_panel_2.putConstraint(SpringLayout.WEST, textSchool, 0, SpringLayout.WEST, textPrice); sl_panel_2.putConstraint(SpringLayout.EAST, textSchool, -97, SpringLayout.EAST, panel_2); textSchool.setFont(new Font("Segoe UI Light", Font.PLAIN, 18)); textSchool.setBorder(new LineBorder(new Color(0, 102, 204))); textSchool.addMouseListener( new MouseAdapter() { @Override public void mouseEntered(MouseEvent arg0) { textSchool.setBorder(new LineBorder(new Color(0, 0, 0))); } @Override public void mouseExited(MouseEvent arg0) { textSchool.setBorder(new LineBorder(new Color(0, 102, 204))); } }); panel_2.add(textSchool); JLabel lblSzkoa = new JLabel("Szko\u0142a:"); sl_panel_2.putConstraint(SpringLayout.NORTH, lblSzkoa, 0, SpringLayout.NORTH, lblTytu); sl_panel_2.putConstraint(SpringLayout.WEST, lblSzkoa, 0, SpringLayout.WEST, textPrice); lblSzkoa.setForeground(new Color(0, 102, 255)); lblSzkoa.setFont(new Font("Microsoft YaHei UI Light", Font.PLAIN, 20)); panel_2.add(lblSzkoa); /* * final JTextField textClass = new JTextField(); * sl_panel_2.putConstraint(SpringLayout.NORTH, textClass, 6, * SpringLayout.SOUTH, lblKlasa); * sl_panel_2.putConstraint(SpringLayout.WEST, textAmount, 29, * SpringLayout.EAST, textClass); * sl_panel_2.putConstraint(SpringLayout.EAST, textClass, -608, * SpringLayout.EAST, panel_2); * sl_panel_2.putConstraint(SpringLayout.WEST, textClass, 0, * SpringLayout.WEST, label); textClass.setFont(new * Font("Segoe UI Light", Font.PLAIN, 18)); panel_2.add(textClass); */ final JLabel lblComm = new JLabel(""); lblComm.setForeground(new Color(0, 102, 255)); sl_panel_2.putConstraint(SpringLayout.WEST, textPrice, 378, SpringLayout.EAST, lblComm); sl_panel_2.putConstraint(SpringLayout.NORTH, lblComm, 54, SpringLayout.SOUTH, textAuthors); sl_panel_2.putConstraint(SpringLayout.WEST, lblComm, 15, SpringLayout.EAST, textAmount); sl_panel_2.putConstraint(SpringLayout.SOUTH, lblComm, -197, SpringLayout.SOUTH, panel_2); sl_panel_2.putConstraint(SpringLayout.EAST, lblComm, 271, SpringLayout.WEST, panel_2); lblComm.setFont(new Font("Microsoft YaHei UI Light", Font.PLAIN, 15)); panel_2.add(lblComm); JButton btnUzupelnij = new JButton("Wprowad\u017A"); sl_panel_2.putConstraint(SpringLayout.WEST, btnUzupelnij, 829, SpringLayout.WEST, panel_2); sl_panel_2.putConstraint(SpringLayout.SOUTH, btnUzupelnij, -10, SpringLayout.SOUTH, panel_2); sl_panel_2.putConstraint(SpringLayout.EAST, btnUzupelnij, -43, SpringLayout.EAST, panel_2); btnUzupelnij.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { { try { String message = excel.fillInfo( textTitle.getText(), /* textClass.getText(), */ textLevel.getText(), textAuthors.getText(), textPublisher.getText(), textAmount.getText(), textPrice.getText(), textISBN_3.getText(), textSchool.getText(), path); textTitle.setText(null); // textClass.setText(null); textLevel.setText(null); textAuthors.setText(null); textPublisher.setText(null); textAmount.setText(null); textPrice.setText(null); textISBN_3.setText(null); textSchool.setText(null); lblComm.setText(null); JOptionPane.showMessageDialog(null, message); } catch (FileNotFoundException e1) { JOptionPane.showMessageDialog( null, "Brak pliku Ÿród³owego lub plik jest otwarty w innym programie!"); } catch (IllegalFormatException e2) { JOptionPane.showMessageDialog( null, "Brakuje danych lub s¹ wprowadzone niepoprawnie!"); } catch (IOException e2) { e2.printStackTrace(); } catch (NumberFormatException e3) { JOptionPane.showMessageDialog( null, "Brakuje danych lub s¹ wprowadzone niepoprawnie!"); } } } }); btnUzupelnij.setFont(new Font("Microsoft YaHei UI Light", Font.PLAIN, 14)); btnUzupelnij.setBackground(SystemColor.control); panel_2.add(btnUzupelnij); JButton btnSprawdz2 = new JButton("Sprawd\u017A ISBN"); sl_panel_2.putConstraint(SpringLayout.SOUTH, btnSprawdz2, -6, SpringLayout.NORTH, btnUzupelnij); sl_panel_2.putConstraint(SpringLayout.EAST, btnSprawdz2, -43, SpringLayout.EAST, panel_2); btnSprawdz2.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { excel.getArrayListBook().clear(); try { if (!excel.searchBook(textISBN_3.getText(), path).isEmpty()) { /* * textClass.setText(String.valueOf(excel * .getArrayListBook().get(0).getClass1())); */ textSchool.setText(excel.getArrayListBook().get(0).getSchool()); textPrice.setText(String.valueOf(excel.getArrayListBook().get(0).getPrice())); textAuthors.setText(excel.getArrayListBook().get(0).getAuthors()); textAmount.setText(null); textPublisher.setText(excel.getArrayListBook().get(0).getPublisher()); textLevel.setText(excel.getArrayListBook().get(0).getLevel()); textTitle.setText(excel.getArrayListBook().get(0).getTitle()); lblComm.setText("Ile chcesz dodaæ ?"); } else JOptionPane.showMessageDialog(null, "Brak danych o zadanym kryterium"); } catch (FileNotFoundException e) { e.printStackTrace(); JOptionPane.showMessageDialog( null, "Brak pliku Ÿród³owego lub plik jest otwarty w innym programie!"); } catch (Exception e) { e.printStackTrace(); } excel.getArrayListBook().clear(); } }); btnSprawdz2.setFont(new Font("Microsoft YaHei UI Light", Font.PLAIN, 14)); btnSprawdz2.setBackground(SystemColor.control); panel_2.add(btnSprawdz2); JLabel label_2 = new JLabel(""); sl_panel_2.putConstraint(SpringLayout.NORTH, label_2, -156, SpringLayout.SOUTH, panel_2); sl_panel_2.putConstraint(SpringLayout.WEST, label_2, 10, SpringLayout.WEST, panel_2); sl_panel_2.putConstraint(SpringLayout.SOUTH, label_2, -10, SpringLayout.SOUTH, panel_2); label_2.setIcon(new ImageIcon(img)); panel_2.add(label_2); JPanel panel_1 = new JPanel(); panel_1.setBackground(new Color(255, 255, 255)); tabbedPane.addTab("Sprzeda\u017C", null, panel_1, null); SpringLayout sl_panel_1 = new SpringLayout(); panel_1.setLayout(sl_panel_1); final JTextField textISBN_2 = new JTextField(); sl_panel_1.putConstraint(SpringLayout.WEST, textISBN_2, 10, SpringLayout.WEST, panel_1); textISBN_2.setFont(new Font("Segoe UI Light", Font.PLAIN, 18)); textISBN_2.setBorder(new LineBorder(new Color(0, 102, 204))); textISBN_2.addMouseListener( new MouseAdapter() { @Override public void mouseEntered(MouseEvent arg0) { textISBN_2.setBorder(new LineBorder(new Color(0, 0, 0))); } @Override public void mouseExited(MouseEvent arg0) { textISBN_2.setBorder(new LineBorder(new Color(0, 102, 204))); } }); panel_1.add(textISBN_2); JLabel lblISBN_2 = new JLabel("Kod ISBN:"); sl_panel_1.putConstraint(SpringLayout.WEST, lblISBN_2, 10, SpringLayout.WEST, panel_1); sl_panel_1.putConstraint(SpringLayout.SOUTH, lblISBN_2, -6, SpringLayout.NORTH, textISBN_2); lblISBN_2.setForeground(new Color(0, 102, 255)); lblISBN_2.setFont(new Font("Microsoft YaHei UI Light", Font.PLAIN, 20)); panel_1.add(lblISBN_2); final JTextField textCENA = new JTextField(); sl_panel_1.putConstraint(SpringLayout.SOUTH, textISBN_2, -6, SpringLayout.NORTH, textCENA); textCENA.setFont(new Font("Segoe UI Light", Font.PLAIN, 18)); textCENA.setBorder(new LineBorder(new Color(0, 102, 204))); textCENA.addMouseListener( new MouseAdapter() { @Override public void mouseEntered(MouseEvent arg0) { textCENA.setBorder(new LineBorder(new Color(0, 0, 0))); } @Override public void mouseExited(MouseEvent arg0) { textCENA.setBorder(new LineBorder(new Color(0, 102, 204))); } }); panel_1.add(textCENA); JLabel lblCENA = new JLabel("Cena:"); sl_panel_1.putConstraint(SpringLayout.WEST, textCENA, 6, SpringLayout.EAST, lblCENA); sl_panel_1.putConstraint(SpringLayout.WEST, lblCENA, 10, SpringLayout.WEST, panel_1); lblCENA.setForeground(new Color(0, 102, 255)); lblCENA.setFont(new Font("Microsoft YaHei UI Light", Font.PLAIN, 20)); panel_1.add(lblCENA); JLabel lblSOWA_2 = new JLabel(""); sl_panel_1.putConstraint(SpringLayout.SOUTH, lblCENA, -303, SpringLayout.NORTH, lblSOWA_2); sl_panel_1.putConstraint(SpringLayout.SOUTH, textCENA, -303, SpringLayout.NORTH, lblSOWA_2); sl_panel_1.putConstraint(SpringLayout.NORTH, lblSOWA_2, -155, SpringLayout.SOUTH, panel_1); sl_panel_1.putConstraint(SpringLayout.WEST, lblSOWA_2, 10, SpringLayout.WEST, panel_1); sl_panel_1.putConstraint(SpringLayout.SOUTH, lblSOWA_2, -10, SpringLayout.SOUTH, panel_1); lblSOWA_2.setIcon(new ImageIcon(img)); panel_1.add(lblSOWA_2); JButton btnOk = new JButton("OK"); sl_panel_1.putConstraint(SpringLayout.EAST, textCENA, -233, SpringLayout.WEST, btnOk); sl_panel_1.putConstraint(SpringLayout.NORTH, btnOk, 2, SpringLayout.NORTH, textCENA); sl_panel_1.putConstraint(SpringLayout.WEST, btnOk, 358, SpringLayout.WEST, panel_1); sl_panel_1.putConstraint(SpringLayout.EAST, btnOk, 0, SpringLayout.EAST, textISBN_2); btnOk.setFont(new Font("Microsoft YaHei UI Light", Font.PLAIN, 14)); btnOk.setBackground(SystemColor.control); panel_1.add(btnOk); final JButton btnPOTWIERDZ = new JButton("POTWIERD\u0179"); sl_panel_1.putConstraint(SpringLayout.NORTH, btnPOTWIERDZ, 592, SpringLayout.NORTH, panel_1); sl_panel_1.putConstraint(SpringLayout.WEST, btnPOTWIERDZ, -127, SpringLayout.EAST, panel_1); sl_panel_1.putConstraint(SpringLayout.SOUTH, btnPOTWIERDZ, -20, SpringLayout.SOUTH, panel_1); btnPOTWIERDZ.setEnabled(false); sl_panel_1.putConstraint(SpringLayout.EAST, btnPOTWIERDZ, -10, SpringLayout.EAST, panel_1); btnPOTWIERDZ.setFont(new Font("Microsoft YaHei UI Light", Font.PLAIN, 14)); btnPOTWIERDZ.setBackground(SystemColor.control); panel_1.add(btnPOTWIERDZ); JLabel lblParagon = new JLabel("Paragon:"); sl_panel_1.putConstraint(SpringLayout.NORTH, lblParagon, 0, SpringLayout.NORTH, lblISBN_2); lblParagon.setForeground(new Color(0, 102, 255)); lblParagon.setFont(new Font("Microsoft YaHei UI Light", Font.PLAIN, 20)); panel_1.add(lblParagon); JButton btnSUMA = new JButton("Suma"); sl_panel_1.putConstraint(SpringLayout.EAST, btnSUMA, 0, SpringLayout.EAST, btnPOTWIERDZ); btnSUMA.setFont(new Font("Microsoft YaHei UI Light", Font.PLAIN, 14)); btnSUMA.setBackground(SystemColor.control); panel_1.add(btnSUMA); JButton btnAnuluj = new JButton("Anuluj"); sl_panel_1.putConstraint(SpringLayout.SOUTH, btnAnuluj, -57, SpringLayout.SOUTH, panel_1); sl_panel_1.putConstraint(SpringLayout.NORTH, btnSUMA, 0, SpringLayout.NORTH, btnAnuluj); sl_panel_1.putConstraint(SpringLayout.EAST, lblSOWA_2, -389, SpringLayout.WEST, btnAnuluj); sl_panel_1.putConstraint(SpringLayout.EAST, btnAnuluj, -84, SpringLayout.EAST, panel_1); btnAnuluj.setFont(new Font("Microsoft YaHei UI Light", Font.PLAIN, 14)); btnAnuluj.setBackground(SystemColor.control); panel_1.add(btnAnuluj); JScrollPane scrollPane = new JScrollPane(); sl_panel_1.putConstraint(SpringLayout.WEST, lblParagon, 0, SpringLayout.WEST, scrollPane); sl_panel_1.putConstraint(SpringLayout.EAST, textISBN_2, -103, SpringLayout.WEST, scrollPane); sl_panel_1.putConstraint(SpringLayout.NORTH, scrollPane, 0, SpringLayout.NORTH, textISBN_2); sl_panel_1.putConstraint(SpringLayout.WEST, scrollPane, 551, SpringLayout.WEST, panel_1); sl_panel_1.putConstraint(SpringLayout.EAST, scrollPane, -10, SpringLayout.EAST, panel_1); sl_panel_1.putConstraint(SpringLayout.SOUTH, scrollPane, 52, SpringLayout.NORTH, lblSOWA_2); scrollPane.setBorder(new LineBorder(new Color(0, 102, 204))); scrollPane.addMouseListener( new MouseAdapter() { @Override public void mouseEntered(MouseEvent arg0) { scrollPane.setBorder(new LineBorder(new Color(0, 0, 0))); } @Override public void mouseExited(MouseEvent arg0) { scrollPane.setBorder(new LineBorder(new Color(0, 102, 204))); } }); panel_1.add(scrollPane); final JTextArea textArea_1 = new JTextArea(); scrollPane.setViewportView(textArea_1); sl_panel_1.putConstraint(SpringLayout.NORTH, textArea_1, 189, SpringLayout.NORTH, textISBN_2); sl_panel_1.putConstraint(SpringLayout.WEST, textArea_1, 79, SpringLayout.EAST, lblSOWA_2); sl_panel_1.putConstraint(SpringLayout.SOUTH, textArea_1, -37, SpringLayout.SOUTH, panel_1); textArea_1.setFont(new Font("Segoe UI Light", Font.PLAIN, 18)); textArea_1.setEditable(false); textArea_1.setBackground(Color.WHITE); sl_panel_1.putConstraint(SpringLayout.EAST, textArea_1, -340, SpringLayout.EAST, btnPOTWIERDZ); btnOk.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { try { int cena = Integer.parseInt(textCENA.getText()); String ISBN = textISBN_2.getText(); excel.searchBook(ISBN, path); if (excel.getChanges()) { prices.add(cena); textArea_1.append( excel.printReceipt( excel.getArrayListBook().get(excel.getArrayListBook().size() - 1), cena)); } else JOptionPane.showMessageDialog( null, "Brak takiego ISBN w bazie.\nDodaj najpierw ksi¹¿kê do arkusza ewidencyjnego!"); textISBN_2.setText(null); textCENA.setText(null); } catch (FileNotFoundException ex) { JOptionPane.showMessageDialog( null, "Brak pliku Ÿród³owego lub plik jest otwarty w innym programie!"); ex.printStackTrace(); } catch (NumberFormatException e) { e.printStackTrace(); textISBN_2.setText(null); textCENA.setText(null); JOptionPane.showMessageDialog( null, "B³¹d!\n\nSprawdŸ czy wszystkie dane zosta³y podane poprawnie !"); } catch (Exception e) { e.printStackTrace(); } } }); btnSUMA.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { int ceny = 0; for (int i = 0; i < prices.size(); i++) { ceny += prices.get(i); } textArea_1.append("\n\tRazem:\t" + ceny + "z³\n"); if (!excel.getArrayListBook().isEmpty()) btnPOTWIERDZ.setEnabled(true); } }); btnAnuluj.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { textArea_1.setText(null); btnPOTWIERDZ.setEnabled(false); excel.getArrayListBook().clear(); prices.clear(); JOptionPane.showMessageDialog(null, "Anulowano."); } }); btnPOTWIERDZ.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { try { for (int i = 0; i < excel.getArrayListBook().size(); i++) System.out.println(excel.getArrayListBook().get(i).getTitle()); excel.prepareRaport(prices, path2); excel.updateExcel(path); textArea_1.setText(null); excel.getArrayListBook().clear(); prices.clear(); btnPOTWIERDZ.setEnabled(false); JOptionPane.showMessageDialog(null, "Wyewidencjonowano z powodzeniem."); } catch (FileNotFoundException ex) { JOptionPane.showMessageDialog( null, "Brak pliku Ÿród³owego lub plik jest otwarty w innym programie!"); ex.printStackTrace(); } catch (IndexOutOfBoundsException a) { JOptionPane.showMessageDialog( null, "Do pola kodu ISBN wprowadzano b³êdne dane np. tytu³y ksi¹¿ek!"); textArea_1.setText(null); excel.getArrayListBook().clear(); prices.clear(); btnPOTWIERDZ.setEnabled(false); a.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }); frame.setBounds(100, 100, 1100, 725); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
public ClassEntityView(final GraphicView parent, Entity component) { super(parent); if (component == null) throw new IllegalArgumentException("component is null"); this.component = component; // Create a textBox for display the entity name. entityName = new TextBoxEntityName(parent, component); // Create the popup menu. JMenuItem menuItem; popupMenu.addSeparator(); menuItem = makeMenuItem("Add attribute", "AddAttribute", "attribute"); popupMenu.add(menuItem); menuItem = makeMenuItem("Add method", "AddMethod", "method"); popupMenu.add(menuItem); popupMenu.addSeparator(); menuItemMoveUp = menuItem = makeMenuItem("Move up", Slyum.ACTION_TEXTBOX_UP, "direction_up"); menuItemMoveUp.setEnabled(false); popupMenu.add(menuItem); menuItemMoveDown = menuItem = makeMenuItem("Move down", Slyum.ACTION_TEXTBOX_DOWN, "direction_down"); menuItemMoveDown.setEnabled(false); popupMenu.add(menuItem); popupMenu.addSeparator(); menuItemDelete = menuItem = makeMenuItem("Delete", "Delete", "delete16"); popupMenu.add(menuItem); popupMenu.addSeparator(); JMenu subMenu = new JMenu("View"); subMenu.setIcon(PersonalizedIcon.createImageIcon(Slyum.ICON_PATH + "visibility.png")); ButtonGroup group = new ButtonGroup(); JRadioButtonMenuItem rbMenuItem = makeRadioButtonMenuItem("All", "ViewAll", group); rbMenuItem.setSelected(true); subMenu.add(rbMenuItem); rbMenuItem = makeRadioButtonMenuItem("Only Attributes", "ViewAttribute", group); subMenu.add(rbMenuItem, 1); rbMenuItem = makeRadioButtonMenuItem("Only Methods", "ViewMethods", group); subMenu.add(rbMenuItem, 2); rbMenuItem = makeRadioButtonMenuItem("Nothing", "ViewNothing", group); subMenu.add(rbMenuItem); popupMenu.add(subMenu); subMenu = new JMenu("Methods View"); subMenu.setIcon(PersonalizedIcon.createImageIcon("resources/icon/visibility.png")); group = new ButtonGroup(); rbMenuItem = makeRadioButtonMenuItem("Type and Name", "ViewTypeAndName", group); rbMenuItem.setSelected(true); subMenu.add(rbMenuItem); rbMenuItem = makeRadioButtonMenuItem("Type", "ViewType", group); subMenu.add(rbMenuItem, 1); rbMenuItem = makeRadioButtonMenuItem("Name", "ViewName", group); subMenu.add(rbMenuItem, 2); rbMenuItem = makeRadioButtonMenuItem("Nothing", "ViewMethodNothing", group); subMenu.add(rbMenuItem); popupMenu.add(subMenu); popupMenu.addSeparator(); SPanelZOrder p = SPanelZOrder.getInstance(); menuItem = makeMenuItem("Move top", "ZOrderTOP", "top"); p.getBtnTop().linkComponent(menuItem); popupMenu.add(menuItem); menuItem = makeMenuItem("Up", "ZOrderUP", "up"); p.getBtnUp().linkComponent(menuItem); popupMenu.add(menuItem); menuItem = makeMenuItem("Down", "ZOrderDown", "down"); p.getBtnDown().linkComponent(menuItem); popupMenu.add(menuItem); menuItem = makeMenuItem("Move bottom", "ZOrderBottom", "bottom"); p.getBtnBottom().linkComponent(menuItem); popupMenu.add(menuItem); component.addObserver(this); setColor(getBasicColor()); }
public JMenuItem getOffsetMenuItem() { JMenu subMenu = new JMenu(trc("layer", "Offset")); subMenu.setIcon(ImageProvider.get("mapmode", "adjustimg")); return (JMenuItem) getOffsetMenuItem(subMenu); }
@SuppressWarnings({"unchecked", "rawtypes"}) public static void main(String[] args) { final EditingGraphViewer sgv = new EditingGraphViewer(); // Layout<V, E>, VisualizationViewer<V,E> final Layout<Integer, String> layout = new StaticLayout<Integer, String>(g); layout.setSize(new Dimension(300, 300)); final VisualizationViewer<Integer, String> vv = new VisualizationViewer<Integer, String>(layout); vv.setBackground(Color.white); vv.setPreferredSize(new Dimension(350, 350)); Transformer<Integer, Paint> vertexPaint = new Transformer<Integer, Paint>() { public Paint transform(Integer i) { return (Paint) Color.WHITE; } }; vv.getRenderContext() .setVertexFillPaintTransformer((Transformer<Integer, java.awt.Paint>) vertexPaint); // Show vertex and edge labels vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<Integer>()); vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller<String>()); // Create a graph mouse and add it to the visualization viewer // Our Vertices are going to be Integer objects so we need an Integer factory EditingModalGraphMouse gm = new EditingModalGraphMouse(vv.getRenderContext(), sgv.vertexFactory, sgv.edgeFactory); vv.setGraphMouse(gm); JFrame frame = new JFrame("Editing Graph"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(vv); // =========================================================================== // Menu for changing mouse modes JMenuBar menuBar = new JMenuBar(); JMenu modeMenu = gm.getModeMenu(); modeMenu.setText("Mode"); modeMenu.setIcon(null); modeMenu.setPreferredSize(new Dimension(80, 20)); menuBar.add(modeMenu); // --------------------------------------------------------------------------- // Menu Item to compute Centrality Measures JMenu centrality = new JMenu("Centrality"); JMenuItem execB = new JMenuItem("Betweenness C."); execB.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Betweenness.compute(g); } }); centrality.add(execB); JMenuItem execC = new JMenuItem("Closeness C"); execC.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Closeness.compute(g); } }); centrality.add(execC); menuBar.add(centrality); // --------------------------------------------------------------------------- // Menu Item to change Vertices Color colorArray.add(2); JMenu selColor = new JMenu("NodeColor"); JMenuItem selBlack = new JMenuItem("black"); selBlack.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { colorArray.add(1); int v = g.getVertexCount(); for (int j = 0; j < nodeArray.size(); j++) v = v - nodeArray.get(j); int vC = g.getVertexCount(); nodeArray.add(v); SelectColor.choiceColor(1, vv, nodeArray, colorArray, vC); } }); selColor.add(selBlack); JMenuItem selGray = new JMenuItem("gray"); selGray.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { colorArray.add(0); int v = g.getVertexCount(); for (int j = 0; j < nodeArray.size(); j++) v = v - nodeArray.get(j); nodeArray.add(v); int vC = g.getVertexCount(); SelectColor.choiceColor(0, vv, nodeArray, colorArray, vC); } }); selColor.add(selGray); JMenuItem selWhite = new JMenuItem("white"); selWhite.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { colorArray.add(2); int v = g.getVertexCount(); for (int j = 0; j < nodeArray.size(); j++) v = v - nodeArray.get(j); nodeArray.add(v); int vC = g.getVertexCount(); SelectColor.choiceColor(2, vv, nodeArray, colorArray, vC); } }); selColor.add(selWhite); JMenuItem selYellow = new JMenuItem("yellow"); selYellow.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { colorArray.add(3); int v = g.getVertexCount(); for (int j = 0; j < nodeArray.size(); j++) v = v - nodeArray.get(j); nodeArray.add(v); int vC = g.getVertexCount(); SelectColor.choiceColor(3, vv, nodeArray, colorArray, vC); } }); selColor.add(selYellow); menuBar.add(selColor); // ------------------------------------------------------------------------------------ // MenuItem to save the graph as jpeg ,or eps, or to save code generation graph JMenu saveImg = new JMenu("Save"); JMenuItem saveJPG = new JMenuItem("Save as jpeg"); saveJPG.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Save.saveJpeg(vv); } }); saveImg.add(saveJPG); JMenuItem saveEPS = new JMenuItem("Save as eps"); saveEPS.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Save.saveEps(vv); } }); saveImg.add(saveEPS); JMenuItem saveCode = new JMenuItem("Save Graph Code"); saveCode.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Save.saveCode(g, colorArray, nodeArray); } }); saveImg.add(saveCode); menuBar.add(saveImg); // ------------------------------------------------------------------------------------- frame.setJMenuBar(menuBar); gm.setMode(ModalGraphMouse.Mode.EDITING); // Start off in editing mode frame.pack(); frame.setVisible(true); }
/** * Constructs a JMenuBar that can be added to a JFrame * * @return a JMenuBar */ private JMenuBar menuBar() { JMenuBar mb = new JMenuBar(); JMenu fileMenu, editMenu, viewMenu, helpMenu, newEntry, viewDatabase; JMenuItem newChild, newEmployee, newAccount, openChild, viewFileChild, viewFileEmployee, saveChild, saveAs, printDocument, properties, viewDatabaseChild, viewDatabaseEmployee, viewFinances, viewCalendar, exit, cut, copy, paste, help, faq, report, about, checkupdate; // Initialize JMenu's fileMenu = new JMenu(lang_model.getValue(12)); editMenu = new JMenu(lang_model.getValue(23)); viewMenu = new JMenu(lang_model.getValue(27)); helpMenu = new JMenu(lang_model.getValue(33)); fileMenu.setRolloverEnabled(true); editMenu.setRolloverEnabled(true); helpMenu.setRolloverEnabled(true); // Initialize sub-JMenu's newEntry = new JMenu(lang_model.getValue(13)); newEntry.setIcon(images.loadImage("Images/menubar/application_icon.png")); openChild = new JMenu(lang_model.getValue(14)); openChild.setIcon(images.loadImage("Images/menubar/XML_icon_small.png")); viewDatabase = new JMenu(lang_model.getValue(29)); viewDatabase.setIcon(images.loadImage("Images/menubar/database_icon.png")); // Initialize JMenuItem's newChild = new JMenuItem(lang_model.getValue(20)); newEmployee = new JMenuItem(lang_model.getValue(21)); newAccount = new JMenuItem(lang_model.getValue(22)); saveChild = new JMenuItem(lang_model.getValue(15), images.loadImage("Images/menubar/save_icon.png")); saveAs = new JMenuItem(lang_model.getValue(16)); printDocument = new JMenuItem(lang_model.getValue(18), images.loadImage("Images/menubar/print_icon.png")); properties = new JMenuItem( lang_model.getValue(17), images.loadImage("Images/menubar/properties_icon.png")); viewCalendar = new JMenuItem( lang_model.getValue(28), images.loadImage("Images/menubar/calendar_icon.png")); viewDatabaseChild = new JMenuItem(lang_model.getValue(31)); viewDatabaseEmployee = new JMenuItem(lang_model.getValue(32)); viewFileChild = new JMenuItem(lang_model.getValue(20)); viewFileEmployee = new JMenuItem(lang_model.getValue(21)); saveChild.setEnabled(false); saveAs.setEnabled(false); printDocument.setEnabled(false); viewCalendar.setEnabled(false); viewFinances = new JMenuItem( lang_model.getValue(30), images.loadImage("Images/menubar/finances_icon_small.png")); exit = new JMenuItem(lang_model.getValue(19)); cut = new JMenuItem(lang_model.getValue(24), images.loadImage("Images/menubar/cut_icon.png")); copy = new JMenuItem(lang_model.getValue(25), images.loadImage("Images/menubar/copy_icon.png")); paste = new JMenuItem(lang_model.getValue(26), images.loadImage("Images/menubar/paste_icon.png")); viewFinances.setEnabled(false); cut.setEnabled(false); copy.setEnabled(false); paste.setEnabled(false); help = new JMenuItem(lang_model.getValue(33), images.loadImage("Images/menubar/help_icon.png")); faq = new JMenuItem(lang_model.getValue(34)); report = new JMenuItem(lang_model.getValue(35)); about = new JMenuItem( lang_model.getValue(36), images.loadImage("Images/menubar/exclamation_icon.png")); checkupdate = new JMenuItem(lang_model.getValue(105)); faq.setEnabled(false); checkupdate.setEnabled(false); // Add JMenuItem's to the JMenu's fileMenu.add(newEntry); newEntry.add(newChild); // Sub-Menu of fileMenu newEntry.add(newEmployee); // Sub-Menu of fileMenu newEntry.add(newAccount); // Sub-Menu of fileMenu fileMenu.add(openChild); openChild.add(viewFileChild); openChild.add(viewFileEmployee); // fileMenu.add(view); fileMenu.addSeparator(); fileMenu.add(saveChild); fileMenu.add(saveAs); fileMenu.addSeparator(); fileMenu.add(printDocument); fileMenu.addSeparator(); fileMenu.add(properties); fileMenu.addSeparator(); fileMenu.add(exit); editMenu.add(cut); editMenu.add(copy); editMenu.add(paste); viewMenu.add(viewCalendar); viewMenu.add(viewDatabase); viewDatabase.add(viewDatabaseChild); viewDatabase.add(viewDatabaseEmployee); viewMenu.add(viewFinances); helpMenu.add(help); helpMenu.add(faq); helpMenu.add(report); helpMenu.add(about); helpMenu.add(checkupdate); // Add JMenu's to the MenuBar mb.add(fileMenu); mb.add(editMenu); mb.add(viewMenu); mb.add(helpMenu); // Mnemonics fileMenu.setMnemonic('F'); newEntry.setMnemonic('N'); editMenu.setMnemonic('E'); viewMenu.setMnemonic('V'); helpMenu.setMnemonic('H'); // Accelerators newChild.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); newEmployee.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_E, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); saveChild.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK)); printDocument.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.CTRL_MASK)); viewFinances.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_F, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); viewCalendar.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); cut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK)); copy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK)); paste.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK)); // Action Listening newChild.setActionCommand("newchild"); newChild.addActionListener(this); newEmployee.setActionCommand("newemployee"); newEmployee.addActionListener(this); newAccount.setActionCommand("newaccount"); newAccount.addActionListener(this); openChild.setActionCommand("openfile"); openChild.addActionListener(this); viewFileChild.setActionCommand("viewfilechild"); viewFileChild.addActionListener(this); viewFileEmployee.setActionCommand("viewfileemployee"); viewFileEmployee.addActionListener(this); viewDatabaseChild.setActionCommand("viewchilddatabase"); viewDatabaseChild.addActionListener(this); viewDatabaseEmployee.setActionCommand("viewemployeedatabase"); viewDatabaseEmployee.addActionListener(this); viewFinances.setActionCommand("viewfinances"); viewFinances.addActionListener(this); viewCalendar.setActionCommand("viewcalendar"); viewCalendar.addActionListener(this); printDocument.setActionCommand("printdocument"); printDocument.addActionListener(this); properties.setActionCommand("properties"); properties.addActionListener(this); exit.setActionCommand("exit"); exit.addActionListener(this); help.setActionCommand("help"); help.addActionListener(this); faq.setActionCommand("faq"); faq.addActionListener(this); report.setActionCommand("reportbug"); report.addActionListener(this); about.setActionCommand("about"); about.addActionListener(this); checkupdate.setActionCommand("checkupdate"); checkupdate.addActionListener(this); return mb; }
/** Create the frame. */ public TelaPrincipal() { blockParaLogin(); setTitle("Menu Principal\r\n"); setExtendedState(TelaPrincipal.MAXIMIZED_BOTH); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 800, 600); setLocationRelativeTo(null); JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenu mnNewMenu = new JMenu(""); mnNewMenu.setIcon(new ImageIcon(TelaPrincipal.class.getResource("/icon/add.png"))); menuBar.add(mnNewMenu); JMenuItem mntmProduto = new JMenuItem("Produto"); mntmProduto.setIcon( new ImageIcon(TelaPrincipal.class.getResource("/icon/1449205752_product.png"))); mntmProduto.setHorizontalAlignment(SwingConstants.LEFT); mntmProduto.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { abrirTelaProduto(); } }); mnNewMenu.add(mntmProduto); JMenuItem mntmCliente = new JMenuItem("Cliente"); mntmCliente.setIcon( new ImageIcon(TelaPrincipal.class.getResource("/icon/1449205797_Add-Male-User.png"))); mntmCliente.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { abrirTelaCliente(); } }); mnNewMenu.add(mntmCliente); JMenuItem mntmBloquear = new JMenuItem("Bloquear"); mntmBloquear.setHorizontalAlignment(SwingConstants.LEFT); mntmBloquear.setIcon(new ImageIcon(TelaPrincipal.class.getResource("/icon/padlock.png"))); mntmBloquear.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { blockLoad(); } }); JMenuItem mntmCategoria = new JMenuItem("Categoria"); mntmCategoria.setIcon( new ImageIcon(TelaPrincipal.class.getResource("/icon/1449206103_category.png"))); mntmCategoria.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { abrirTelacategoria(); } }); mnNewMenu.add(mntmCategoria); mnNewMenu.add(mntmBloquear); JMenu mnVenda = new JMenu(""); mnVenda.setIcon(new ImageIcon(TelaPrincipal.class.getResource("/icon/1449206519_Money.png"))); menuBar.add(mnVenda); JMenuItem mntmVendaCliente = new JMenuItem("Venda Produto"); mntmVendaCliente.setIcon( new ImageIcon(TelaPrincipal.class.getResource("/icon/cash-register.png"))); mntmVendaCliente.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { abrirTelaVenda(); } }); mnVenda.add(mntmVendaCliente); JMenu mnRelatorios = new JMenu(""); mnRelatorios.setIcon( new ImageIcon( TelaPrincipal.class.getResource("/icon/1449206648_product-sales-report.png"))); menuBar.add(mnRelatorios); JMenuItem mntmCliente_1 = new JMenuItem("Clientes"); mntmCliente_1.setIcon(new ImageIcon(TelaPrincipal.class.getResource("/icon/report user.png"))); mntmCliente_1.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { new JasperReportCliente(); } }); mnRelatorios.add(mntmCliente_1); JMenuItem mntmProdutos = new JMenuItem("Produtos"); mntmProdutos.setIcon( new ImageIcon(TelaPrincipal.class.getResource("/icon/Product-report.png"))); mntmProdutos.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { new JasperReportProduto(); } }); mnRelatorios.add(mntmProdutos); JMenuItem mntmVendas = new JMenuItem("Vendas"); mntmVendas.setIcon(new ImageIcon(TelaPrincipal.class.getResource("/icon/sales-report.png"))); mntmVendas.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { new JasperReportVendas(); } }); mnRelatorios.add(mntmVendas); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); contentPane.setLayout(new BorderLayout(0, 0)); setContentPane(contentPane); tabbedPane = new JTabbedPane(JTabbedPane.TOP); contentPane.add(tabbedPane, BorderLayout.CENTER); }
/** * @param netView * @param view a View<CyNode>, View<CyEdge> or View<CyNetwork> object * @return */ public CyMenuItem build(final CyNetworkView netView, final View<? extends CyIdentifiable> view) { final Class<? extends CyIdentifiable> targetClass = view.getModel().getClass(); final Queue<VisualLexiconNode> queue = new PriorityQueue<VisualLexiconNode>(50, new VisualLexiconNodeComparator()); final Map<VisualLexiconNode, JMenuItem> menuMap = new HashMap<VisualLexiconNode, JMenuItem>(); final JMenu rootJMenu = new JMenu(ROOT_MENU_LABEL); final CyMenuItem rootMenu = new CyMenuItem(rootJMenu, ROOT_GRAVITY); queue.addAll(root.getChildren()); menuMap.put(root, rootMenu.getMenuItem()); // Node size, width and height JMenuItem menuItemNodeSize = null; JMenuItem menuItemNodeWidth = null; JMenuItem menuItemNodeHeight = null; final Set<VisualLexiconNode> nextNodes = new HashSet<VisualLexiconNode>(); while (!queue.isEmpty()) { final VisualLexiconNode curretNode = queue.poll(); final VisualProperty<?> vp = curretNode.getVisualProperty(); if (vp.getTargetDataType().isAssignableFrom(targetClass)) { final Collection<VisualLexiconNode> children = curretNode.getChildren(); nextNodes.addAll(children); final JMenuItem menu; if (children.isEmpty() && PropertySheetUtil.isCompatible(vp)) { final boolean lock = view.isDirectlyLocked(vp); if (lock) { menu = new JMenu(vp.getDisplayName()); final JMenuItem clear = new JMenuItem("Clear"); clear.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { view.clearValueLock(vp); netView.updateView(); } }); final JMenuItem edit = new JMenuItem("Edit Bypass"); edit.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { applBypassValue(netView, view, vp); } }); menu.add(clear); menu.add(edit); // Update color menu.setForeground(ENABLED_COLOR); menu.setIcon(ENABLED_ICON); menu.setFont(ENABLED_FONT); VisualLexiconNode parent = curretNode.getParent(); while (parent != root) { JMenuItem enabledPath = menuMap.get(parent); enabledPath.setForeground(ENABLED_COLOR); enabledPath.setIcon(ENABLED_ICON); enabledPath.setFont(ENABLED_FONT); parent = parent.getParent(); } rootJMenu.setIcon(ENABLED_ICON); rootJMenu.setForeground(ENABLED_COLOR); rootJMenu.setFont(ENABLED_FONT); vpSet.add(vp); } else { menu = new JMenuItem(vp.getDisplayName()); menu.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { applBypassValue(netView, view, vp); } }); if (vp.getDisplayName() .equalsIgnoreCase(BasicVisualLexicon.NODE_WIDTH.getDisplayName())) { menuItemNodeWidth = menu; } if (vp.getDisplayName() .equalsIgnoreCase(BasicVisualLexicon.NODE_HEIGHT.getDisplayName())) { menuItemNodeHeight = menu; } } } else { menu = new JMenu(vp.getDisplayName()); if (vp.getDisplayName().equalsIgnoreCase(BasicVisualLexicon.NODE_SIZE.getDisplayName())) { menuItemNodeSize = menu; vp_nodeSize = vp; } } if (PropertySheetUtil.isCompatible(vp)) { menuMap.get(curretNode.getParent()).add(menu); menuMap.put(curretNode, menu); } } if (queue.isEmpty()) { queue.addAll(nextNodes); nextNodes.clear(); } } // handle node size if (menuItemNodeSize != null) { // JMenuItem menuItemNodeSize1 = new JMenuItem(vp_nodeSize.getDisplayName()); menuItemNodeSize1.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { applBypassValue(netView, view, vp_nodeSize); } }); menuItemNodeSize.add(menuItemNodeSize1); // Check if nose size is locked boolean nodeSizeIsLocked = false; java.util.Iterator it = vmm.getCurrentVisualStyle().getAllVisualPropertyDependencies().iterator(); while (it.hasNext()) { org.cytoscape.view.vizmap.VisualPropertyDependency dep = (org.cytoscape.view.vizmap.VisualPropertyDependency) it.next(); if (dep.getDisplayName().equalsIgnoreCase("Lock node width and height") && dep.isDependencyEnabled()) { nodeSizeIsLocked = true; } } if (nodeSizeIsLocked) { // In case the Node size is locked, disable menuItem Node_width and Nod_height if (menuItemNodeWidth != null) menuItemNodeWidth.setEnabled(false); if (menuItemNodeHeight != null) menuItemNodeHeight.setEnabled(false); } else { // In case the Node size is not locked, disable menuItem Node_size if (menuItemNodeSize1 != null) menuItemNodeSize1.setEnabled(false); } } final JSeparator separator = new JSeparator(); final JMenuItem resetMenu = new JMenuItem("Reset All"); resetMenu.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { clearAll(netView, view); } }); rootJMenu.add(separator); rootJMenu.add(resetMenu); return rootMenu; }
/* * (non-Javadoc) * * @see * pt.up.fe.dceg.neptus.planeditor.IEditorMenuExtension#getApplicableItems(pt.up.fe.dceg.neptus.types.coord.LocationType * , pt.up.fe.dceg.neptus.planeditor.IMapPopup) */ @Override public Collection<JMenuItem> getApplicableItems(LocationType loc, IMapPopup source) { final LocationType l = new LocationType(loc); Vector<JMenuItem> menus = new Vector<JMenuItem>(); JMenu myLocMenu = new JMenu(I18n.text("My location")); myLocMenu.setIcon(ICON); menus.add(myLocMenu); AbstractAction addToMap = new AbstractAction(I18n.text("Add My location to map as marker")) { @Override public void actionPerformed(ActionEvent e) { new Thread() { @Override public void run() { long tstamp = System.currentTimeMillis(); LocationType locContact = new LocationType(MyState.getLocation()); if (getConsole() == null) return; if (getConsole().getMission() == null) return; MissionType mission = getConsole().getMission(); LinkedHashMap<String, MapMission> mapList = mission.getMapsList(); if (mapList == null) return; if (mapList.size() == 0) return; MapMission mapMission = mapList.values().iterator().next(); MapType mapType = mapMission.getMap(); MarkElement contact = new MarkElement(); contact.setCenterLocation(locContact); String id = I18n.textc("MyLoc", "String prefix for a marker") + "_" + DateTimeUtil.dateTimeFileNameFormaterMillis.format(new Date(tstamp)); contact.setId(id); contact.setName(id); contact.setParentMap(mapType); contact.setMapGroup(mapType.getMapGroup()); mapType.addObject(contact); mission.save(false); mapType .getMapGroup() .warnListeners(new MapChangeEvent(MapChangeEvent.OBJECT_ADDED)); }; }.start(); } }; myLocMenu.add(new JMenuItem(addToMap)); JMenuItem mid = new JMenuItem("" + location.toString()); mid.setEnabled(false); myLocMenu.add(mid); JMenuItem mid2 = new JMenuItem(I18n.text("Heading") + ": " + ((int) headingDegrees) + "\u00B0"); mid2.setEnabled(false); myLocMenu.add(mid2); AbstractAction copy = new AbstractAction(I18n.text("Copy")) { @Override public void actionPerformed(ActionEvent e) { ClipboardOwner owner = new ClipboardOwner() { @Override public void lostOwnership(Clipboard clipboard, Transferable contents) {}; }; Toolkit.getDefaultToolkit() .getSystemClipboard() .setContents(new StringSelection(MyState.getLocation().getClipboardText()), owner); } }; myLocMenu.add(new JMenuItem(copy)); AbstractAction paste = new AbstractAction(I18n.text("Paste")) { @Override public void actionPerformed(ActionEvent e) { @SuppressWarnings("unused") ClipboardOwner owner = new ClipboardOwner() { @Override public void lostOwnership(Clipboard clipboard, Transferable contents) {}; }; Transferable contents = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null); boolean hasTransferableText = (contents != null) && contents.isDataFlavorSupported(DataFlavor.stringFlavor); if (hasTransferableText) { try { String text = (String) contents.getTransferData(DataFlavor.stringFlavor); LocationType lt = new LocationType(); lt.fromClipboardText(text); MyState.setLocation(lt); } catch (Exception e1) { NeptusLog.pub().error(e1); } } } }; myLocMenu.add(new JMenuItem(paste)); myLocMenu.add(new JSeparator()); AbstractAction add = new AbstractAction(I18n.text("Set this location as Mine")) { @Override public void actionPerformed(ActionEvent e) { MyState.setLocation(new LocationType(l)); } }; myLocMenu.add(new JMenuItem(add)); String txtUsingSysLoc = followingPositionOf != null && followingPositionOf.length() != 0 ? " [" + I18n.text("using") + " " + followingPositionOf + "]" : ""; txtUsingSysLoc = (txtUsingSysLoc.length() == 0 ? I18n.text("Set to use a system location as mine") : I18n.text("Change the system to use location from") + txtUsingSysLoc); AbstractAction useThisLoc = new AbstractAction(txtUsingSysLoc) { @Override public void actionPerformed(ActionEvent e) { Vector<String> options = new Vector<String>(); String noneStr = I18n.text("NONE"); options.add(noneStr); options.add(getConsole().getMainSystem()); String initialValue = followingPositionOf == null || followingPositionOf.length() == 0 ? noneStr : followingPositionOf; // fill the options Vector<String> sysList = new Vector<String>(); for (ImcSystem sys : ImcSystemsHolder.lookupAllSystems()) { if (!options.contains(sys.getName())) sysList.add(sys.getName()); } Collections.sort(sysList); options.addAll(sysList); Vector<String> extList = new Vector<String>(); for (ExternalSystem ext : ExternalSystemsHolder.lookupAllSystems()) { if (!options.contains(ext.getName())) sysList.add(ext.getName()); } Collections.sort(extList); options.addAll(extList); if (!options.contains(initialValue)) options.add(2, initialValue); String[] aopt = options.toArray(new String[options.size()]); String ret = (String) JOptionPane.showInputDialog( getConsole(), I18n.text("Set to use a system location as mine"), I18n.text("Choose a system"), JOptionPane.QUESTION_MESSAGE, ICON, aopt, initialValue); if (ret == null) return; if (noneStr.equalsIgnoreCase(ret)) followingPositionOf = ""; else { followingPositionOf = ret; } } }; myLocMenu.add(new JMenuItem(useThisLoc)); String txtUsingSysDeriveHeading = useSystemToDeriveHeadingOf != null && useSystemToDeriveHeadingOf.length() != 0 ? " [" + I18n.text("using") + " " + useSystemToDeriveHeadingOf + "]" : ""; txtUsingSysDeriveHeading = (txtUsingSysDeriveHeading.length() == 0 ? I18n.text("Set to use a system to derive heading") : I18n.text("Change the system to derive heading from") + txtUsingSysDeriveHeading); AbstractAction useThisForHeading = new AbstractAction(txtUsingSysDeriveHeading) { @Override public void actionPerformed(ActionEvent e) { Vector<String> options = new Vector<String>(); String noneStr = I18n.text("NONE"); options.add(noneStr); options.add(getConsole().getMainSystem()); String initialValue = useSystemToDeriveHeadingOf == null || useSystemToDeriveHeadingOf.length() == 0 ? noneStr : useSystemToDeriveHeadingOf; // fill the options Vector<String> sysList = new Vector<String>(); for (ImcSystem sys : ImcSystemsHolder.lookupAllSystems()) { if (!options.contains(sys.getName())) sysList.add(sys.getName()); } Collections.sort(sysList); options.addAll(sysList); Vector<String> extList = new Vector<String>(); for (ExternalSystem ext : ExternalSystemsHolder.lookupAllSystems()) { if (!options.contains(ext.getName())) sysList.add(ext.getName()); } Collections.sort(extList); options.addAll(extList); if (!options.contains(initialValue)) options.add(2, initialValue); if (followingPositionOf != null && followingPositionOf.length() > 0) { if (options.contains(followingPositionOf)) options.remove(followingPositionOf); } String[] aopt = options.toArray(new String[options.size()]); String ret = (String) JOptionPane.showInputDialog( getConsole(), I18n.text("Set to use a system location as mine"), I18n.text("Choose a system"), JOptionPane.QUESTION_MESSAGE, ICON, aopt, initialValue); if (ret == null) return; if (noneStr.equalsIgnoreCase(ret)) useSystemToDeriveHeadingOf = ""; else { useSystemToDeriveHeadingOf = ret; boolean validValue = false; while (!validValue) { String res = JOptionPane.showInputDialog( getConsole(), I18n.text("Introduce the heading angle to derived heading"), Double.valueOf( AngleCalc.nomalizeAngleDegrees180(useHeadingAngleToDerivedHeading)) .shortValue()); if (res == null) return; try { useHeadingAngleToDerivedHeading = Short.parseShort(res); validValue = true; } catch (Exception ex) { NeptusLog.pub().debug(ex.getMessage()); GuiUtils.errorMessage( ConfigFetch.getSuperParentFrame(), I18n.text("Introduce the heading angle to derived heading"), I18n.text("Value must be a numeric value from [-180, 180]")); } } validValue = false; while (!validValue) { String res = JOptionPane.showInputDialog( getConsole(), I18n.text("Introduce the offset angle to add to the derived heading"), Double.valueOf( AngleCalc.nomalizeAngleDegrees180( useHeadingOffsetFromDerivedHeading)) .shortValue()); if (res == null) return; try { useHeadingOffsetFromDerivedHeading = Short.parseShort(res); validValue = true; } catch (Exception ex) { NeptusLog.pub().debug(ex.getMessage()); GuiUtils.errorMessage( ConfigFetch.getSuperParentFrame(), I18n.text("Introduce the offset angle to add to the derived heading"), I18n.text("Value must be a numeric value from [-180, 180]")); } } } } }; myLocMenu.add(new JMenuItem(useThisForHeading)); myLocMenu.add(new JSeparator()); AbstractAction settings = new AbstractAction(I18n.text("Settings")) { @Override public void actionPerformed(ActionEvent e) { PropertiesEditor.editProperties(MyLocationDisplay.this, getConsole(), true); } }; myLocMenu.add(new JMenuItem(settings)); return menus; }