List of usage examples for java.awt.event KeyEvent VK_2
int VK_2
To view the source code for java.awt.event KeyEvent VK_2.
Click Source Link
From source file:MenuDemo.java
public JMenuBar createMenuBar() { JMenuBar menuBar;//from ww w. jav a 2 s. com JMenu menu, submenu; JMenuItem menuItem; JRadioButtonMenuItem rbMenuItem; JCheckBoxMenuItem cbMenuItem; //Create the menu bar. menuBar = new JMenuBar(); //Build the first menu. menu = new JMenu("A Menu"); menu.setMnemonic(KeyEvent.VK_A); menu.getAccessibleContext().setAccessibleDescription("The only menu in this program that has menu items"); menuBar.add(menu); //a group of JMenuItems menuItem = new JMenuItem("A text-only menu item", KeyEvent.VK_T); //menuItem.setMnemonic(KeyEvent.VK_T); //used constructor instead menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1, ActionEvent.ALT_MASK)); menuItem.getAccessibleContext().setAccessibleDescription("This doesn't really do anything"); menuItem.addActionListener(this); menu.add(menuItem); ImageIcon icon = createImageIcon("images/1.gif"); menuItem = new JMenuItem("Both text and icon", icon); menuItem.setMnemonic(KeyEvent.VK_B); menuItem.addActionListener(this); menu.add(menuItem); menuItem = new JMenuItem(icon); menuItem.setMnemonic(KeyEvent.VK_D); menuItem.addActionListener(this); menu.add(menuItem); //a group of radio button menu items menu.addSeparator(); ButtonGroup group = new ButtonGroup(); rbMenuItem = new JRadioButtonMenuItem("A radio button menu item"); rbMenuItem.setSelected(true); rbMenuItem.setMnemonic(KeyEvent.VK_R); group.add(rbMenuItem); rbMenuItem.addActionListener(this); menu.add(rbMenuItem); rbMenuItem = new JRadioButtonMenuItem("Another one"); rbMenuItem.setMnemonic(KeyEvent.VK_O); group.add(rbMenuItem); rbMenuItem.addActionListener(this); menu.add(rbMenuItem); //a group of check box menu items menu.addSeparator(); cbMenuItem = new JCheckBoxMenuItem("A check box menu item"); cbMenuItem.setMnemonic(KeyEvent.VK_C); cbMenuItem.addItemListener(this); menu.add(cbMenuItem); cbMenuItem = new JCheckBoxMenuItem("Another one"); cbMenuItem.setMnemonic(KeyEvent.VK_H); cbMenuItem.addItemListener(this); menu.add(cbMenuItem); //a submenu menu.addSeparator(); submenu = new JMenu("A submenu"); submenu.setMnemonic(KeyEvent.VK_S); menuItem = new JMenuItem("An item in the submenu"); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_2, ActionEvent.ALT_MASK)); menuItem.addActionListener(this); submenu.add(menuItem); menuItem = new JMenuItem("Another item"); menuItem.addActionListener(this); submenu.add(menuItem); menu.add(submenu); //Build second menu in the menu bar. menu = new JMenu("Another Menu"); menu.setMnemonic(KeyEvent.VK_N); menu.getAccessibleContext().setAccessibleDescription("This menu does nothing"); menuBar.add(menu); return menuBar; }
From source file:MenuSelectionManagerDemo.java
public JMenuBar createMenuBar() { JMenuBar menuBar;//from w ww . jav a 2 s .c om JMenu menu, submenu; JMenuItem menuItem; JRadioButtonMenuItem rbMenuItem; JCheckBoxMenuItem cbMenuItem; //Create the menu bar. menuBar = new JMenuBar(); //Build the first menu. menu = new JMenu("A Menu"); menu.setMnemonic(KeyEvent.VK_A); menu.getAccessibleContext().setAccessibleDescription("The only menu in this program that has menu items"); menuBar.add(menu); //a group of JMenuItems menuItem = new JMenuItem("A text-only menu item", KeyEvent.VK_T); //menuItem.setMnemonic(KeyEvent.VK_T); //used constructor instead menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1, ActionEvent.ALT_MASK)); menuItem.getAccessibleContext().setAccessibleDescription("This doesn't really do anything"); menuItem.addActionListener(this); menu.add(menuItem); ImageIcon icon = createImageIcon("1.gif"); menuItem = new JMenuItem("Both text and icon", icon); menuItem.setMnemonic(KeyEvent.VK_B); menuItem.addActionListener(this); menu.add(menuItem); menuItem = new JMenuItem(icon); menuItem.setMnemonic(KeyEvent.VK_D); menuItem.addActionListener(this); menu.add(menuItem); //a group of radio button menu items menu.addSeparator(); ButtonGroup group = new ButtonGroup(); rbMenuItem = new JRadioButtonMenuItem("A radio button menu item"); rbMenuItem.setSelected(true); rbMenuItem.setMnemonic(KeyEvent.VK_R); group.add(rbMenuItem); rbMenuItem.addActionListener(this); menu.add(rbMenuItem); rbMenuItem = new JRadioButtonMenuItem("Another one"); rbMenuItem.setMnemonic(KeyEvent.VK_O); group.add(rbMenuItem); rbMenuItem.addActionListener(this); menu.add(rbMenuItem); //a group of check box menu items menu.addSeparator(); cbMenuItem = new JCheckBoxMenuItem("A check box menu item"); cbMenuItem.setMnemonic(KeyEvent.VK_C); cbMenuItem.addItemListener(this); menu.add(cbMenuItem); cbMenuItem = new JCheckBoxMenuItem("Another one"); cbMenuItem.setMnemonic(KeyEvent.VK_H); cbMenuItem.addItemListener(this); menu.add(cbMenuItem); //a submenu menu.addSeparator(); submenu = new JMenu("A submenu"); submenu.setMnemonic(KeyEvent.VK_S); menuItem = new JMenuItem("An item in the submenu"); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_2, ActionEvent.ALT_MASK)); menuItem.addActionListener(this); submenu.add(menuItem); menuItem = new JMenuItem("Another item"); menuItem.addActionListener(this); submenu.add(menuItem); menu.add(submenu); //Build second menu in the menu bar. menu = new JMenu("Another Menu"); menu.setMnemonic(KeyEvent.VK_N); menu.getAccessibleContext().setAccessibleDescription("This menu does nothing"); menuBar.add(menu); Timer timer = new Timer(ONE_SECOND, new ActionListener() { public void actionPerformed(ActionEvent evt) { MenuElement[] path = MenuSelectionManager.defaultManager().getSelectedPath(); for (int i = 0; i < path.length; i++) { if (path[i].getComponent() instanceof javax.swing.JMenuItem) { JMenuItem mi = (JMenuItem) path[i].getComponent(); if ("".equals(mi.getText())) { output.append("ICON-ONLY MENU ITEM > "); } else { output.append(mi.getText() + " > "); } } } if (path.length > 0) output.append(newline); } }); timer.start(); return menuBar; }
From source file:de.tor.tribes.ui.windows.DSWorkbenchMainFrame.java
/** * Creates new form MapFrame/*from ww w .j a v a 2 s . c o m*/ */ DSWorkbenchMainFrame() { initComponents(); setAlwaysOnTop(false); if (!GlobalOptions.isMinimal()) { setTitle("DS Workbench " + Constants.VERSION + Constants.VERSION_ADDITION); } else { setTitle("DS Workbench Mini " + Constants.VERSION + Constants.VERSION_ADDITION); } jExportDialog.pack(); jAddROIDialog.pack(); JOutlookBar outlookBar = new JOutlookBar(); outlookBar.addBar("Navigation", jNavigationPanel); outlookBar.addBar("Information", jInformationPanel); outlookBar.addBar("Karte", jMapPanel); outlookBar.addBar("ROI", jROIPanel); outlookBar.setVisibleBar(1); jSettingsScrollPane.setViewportView(outlookBar); mAbout = new AboutDialog(this, true); mAbout.pack(); chooser.setDialogTitle("Speichern unter..."); chooser.addChoosableFileFilter(new javax.swing.filechooser.FileFilter() { @Override public boolean accept(File f) { return (f != null) && (f.isDirectory() || f.getName().endsWith(".png")); } @Override public String getDescription() { return "PNG Image (*.png)"; } }); chooser.addChoosableFileFilter(new javax.swing.filechooser.FileFilter() { @Override public boolean accept(File f) { return (f != null) && (f.isDirectory() || f.getName().endsWith(".jpeg")); } @Override public String getDescription() { return "JPEG Image (*.jpeg)"; } }); //Schedule Backup new Timer("BackupTimer", true).schedule(new BackupTask(), 60 * 10000, 60 * 10000); //give focus to map panel if mouse enters map jMapPanelHolder.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { jMapPanelHolder.requestFocusInWindow(); } }); getContentPane().setBackground(Constants.DS_BACK); pack(); capabilityInfoPanel1.addActionListener(MapPanel.getSingleton()); // <editor-fold defaultstate="collapsed" desc=" Add global KeyListener "> Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() { @Override public void eventDispatched(AWTEvent event) { if (event.getID() == KeyEvent.KEY_PRESSED) { KeyEvent e = (KeyEvent) event; if (DSWorkbenchMainFrame.getSingleton().isActive()) { //move shortcuts if (e.getKeyCode() == KeyEvent.VK_DOWN) { scroll(0.0, 2.0); } else if (e.getKeyCode() == KeyEvent.VK_UP) { scroll(0.0, -2.0); } else if (e.getKeyCode() == KeyEvent.VK_LEFT) { scroll(-2.0, 0.0); } else if (e.getKeyCode() == KeyEvent.VK_RIGHT) { scroll(2.0, 0.0); } else if ((e.getKeyCode() == KeyEvent.VK_1) && e.isShiftDown() && !e.isControlDown() && !e.isAltDown()) { //shot minimap tool shortcut MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_AXE); } else if ((e.getKeyCode() == KeyEvent.VK_2) && e.isShiftDown() && !e.isControlDown() && !e.isAltDown()) { //attack axe tool shortcut MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_RAM); } else if ((e.getKeyCode() == KeyEvent.VK_3) && e.isShiftDown() && !e.isControlDown() && !e.isAltDown()) { //attack ram tool shortcut MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_SNOB); } else if ((e.getKeyCode() == KeyEvent.VK_4) && e.isShiftDown() && !e.isControlDown() && !e.isAltDown()) { //attack snob tool shortcut MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_SPY); } else if ((e.getKeyCode() == KeyEvent.VK_5) && e.isShiftDown() && !e.isControlDown() && !e.isAltDown()) { //attack sword tool shortcut MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_LIGHT); } else if ((e.getKeyCode() == KeyEvent.VK_6) && e.isShiftDown() && !e.isControlDown() && !e.isAltDown()) { //attack light tool shortcut MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_HEAVY); } else if ((e.getKeyCode() == KeyEvent.VK_7) && e.isShiftDown() && !e.isControlDown() && !e.isAltDown()) { //attack heavy tool shortcut MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_SWORD); } else if ((e.getKeyCode() == KeyEvent.VK_S) && e.isControlDown() && !e.isAltDown()) { //search frame shortcut DSWorkbenchSearchFrame.getSingleton() .setVisible(!DSWorkbenchSearchFrame.getSingleton().isVisible()); } } //misc shortcuts if ((e.getKeyCode() == KeyEvent.VK_0) && e.isAltDown()) { //no tool shortcut MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_DEFAULT); } else if ((e.getKeyCode() == KeyEvent.VK_1) && e.isAltDown() && !e.isShiftDown() && !e.isControlDown()) { //measure tool shortcut MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_MEASURE); } else if ((e.getKeyCode() == KeyEvent.VK_2) && e.isAltDown() && !e.isShiftDown() && !e.isControlDown()) { //mark tool shortcut MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_MARK); } else if ((e.getKeyCode() == KeyEvent.VK_3) && e.isAltDown() && !e.isShiftDown() && !e.isControlDown()) { //tag tool shortcut MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_TAG); } else if ((e.getKeyCode() == KeyEvent.VK_4) && e.isAltDown() && !e.isShiftDown() && !e.isControlDown()) { //attack ingame tool shortcut MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_SUPPORT); } else if ((e.getKeyCode() == KeyEvent.VK_5) && e.isAltDown() && !e.isShiftDown() && !e.isControlDown()) { //attack ingame tool shortcut MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_SELECTION); } else if ((e.getKeyCode() == KeyEvent.VK_6) && e.isAltDown() && !e.isShiftDown() && !e.isControlDown()) { //attack ingame tool shortcut MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_RADAR); } else if ((e.getKeyCode() == KeyEvent.VK_7) && e.isAltDown() && !e.isShiftDown() && !e.isControlDown()) { //attack ingame tool shortcut MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_INGAME); } else if ((e.getKeyCode() == KeyEvent.VK_8) && e.isAltDown() && !e.isShiftDown() && !e.isControlDown()) { //res ingame tool shortcut MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_SEND_RES_INGAME); } else if ((e.getKeyCode() == KeyEvent.VK_1) && e.isControlDown() && !e.isShiftDown() && !e.isAltDown()) { //move minimap tool shortcut MinimapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_MOVE); } else if ((e.getKeyCode() == KeyEvent.VK_2) && e.isControlDown() && !e.isShiftDown() && !e.isAltDown()) { //zoom minimap tool shortcut MinimapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ZOOM); } else if ((e.getKeyCode() == KeyEvent.VK_3) && e.isControlDown() && !e.isShiftDown() && !e.isAltDown()) { //shot minimap tool shortcut MinimapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_SHOT); } else if ((e.getKeyCode() == KeyEvent.VK_T) && e.isControlDown() && !e.isShiftDown() && !e.isAltDown()) { //search time shortcut ClockFrame.getSingleton().setVisible(!ClockFrame.getSingleton().isVisible()); } else if ((e.getKeyCode() == KeyEvent.VK_S) && e.isAltDown() && !e.isShiftDown() && !e.isControlDown()) { planMapshot(); } else if (e.getKeyCode() == KeyEvent.VK_F2) { DSWorkbenchAttackFrame.getSingleton() .setVisible(!DSWorkbenchAttackFrame.getSingleton().isVisible()); } else if (e.getKeyCode() == KeyEvent.VK_F3) { DSWorkbenchMarkerFrame.getSingleton() .setVisible(!DSWorkbenchMarkerFrame.getSingleton().isVisible()); } else if (e.getKeyCode() == KeyEvent.VK_F4) { DSWorkbenchTroopsFrame.getSingleton() .setVisible(!DSWorkbenchTroopsFrame.getSingleton().isVisible()); } else if (e.getKeyCode() == KeyEvent.VK_F5) { DSWorkbenchRankFrame.getSingleton() .setVisible(!DSWorkbenchRankFrame.getSingleton().isVisible()); } else if (e.getKeyCode() == KeyEvent.VK_F6) { DSWorkbenchFormFrame.getSingleton() .setVisible(!DSWorkbenchFormFrame.getSingleton().isVisible()); } else if (e.getKeyCode() == KeyEvent.VK_F7) { if (ServerSettings.getSingleton().isChurch()) { DSWorkbenchChurchFrame.getSingleton() .setVisible(!DSWorkbenchChurchFrame.getSingleton().isVisible()); } } else if (e.getKeyCode() == KeyEvent.VK_F8) { DSWorkbenchConquersFrame.getSingleton() .setVisible(!DSWorkbenchConquersFrame.getSingleton().isVisible()); } else if (e.getKeyCode() == KeyEvent.VK_F9) { DSWorkbenchNotepad.getSingleton() .setVisible(!DSWorkbenchNotepad.getSingleton().isVisible()); } else if (e.getKeyCode() == KeyEvent.VK_F10) { DSWorkbenchTagFrame.getSingleton() .setVisible(!DSWorkbenchTagFrame.getSingleton().isVisible()); } else if (e.getKeyCode() == KeyEvent.VK_F11) { DSWorkbenchStatsFrame.getSingleton() .setVisible(!DSWorkbenchStatsFrame.getSingleton().isVisible()); } else if (e.getKeyCode() == KeyEvent.VK_F12) { DSWorkbenchSettingsDialog.getSingleton().setVisible(true); } else if ((e.getKeyCode() == KeyEvent.VK_1) && e.isControlDown() && e.isAltDown() && !e.isShiftDown()) { //ROI 1 centerROI(0); } else if ((e.getKeyCode() == KeyEvent.VK_2) && e.isControlDown() && e.isAltDown() && !e.isShiftDown()) { //ROI 2 centerROI(1); } else if ((e.getKeyCode() == KeyEvent.VK_3) && e.isControlDown() && e.isAltDown() && !e.isShiftDown()) { //ROI 3 centerROI(2); } else if ((e.getKeyCode() == KeyEvent.VK_4) && e.isControlDown() && e.isAltDown() && !e.isShiftDown()) { //ROI 4 centerROI(3); } else if ((e.getKeyCode() == KeyEvent.VK_5) && e.isControlDown() && e.isAltDown() && !e.isShiftDown()) { //ROI 5 centerROI(4); } else if ((e.getKeyCode() == KeyEvent.VK_6) && e.isControlDown() && e.isAltDown() && !e.isShiftDown()) { //ROI 6 centerROI(5); } else if ((e.getKeyCode() == KeyEvent.VK_7) && e.isControlDown() && e.isAltDown() && !e.isShiftDown()) { //ROI 7 centerROI(6); } else if ((e.getKeyCode() == KeyEvent.VK_8) && e.isControlDown() && e.isAltDown() && !e.isShiftDown()) { //ROI 8 centerROI(7); } else if ((e.getKeyCode() == KeyEvent.VK_9) && e.isControlDown() && e.isAltDown() && !e.isShiftDown()) { //ROI 9 centerROI(8); } else if ((e.getKeyCode() == KeyEvent.VK_0) && e.isControlDown() && e.isAltDown() && !e.isShiftDown()) { //ROI 10 centerROI(9); } else if (e.getKeyCode() == KeyEvent.VK_SPACE) { jMapPanelHolder.requestFocusInWindow(); MapPanel.getSingleton().setSpaceDown(true); } else if (e.getKeyCode() == KeyEvent.VK_SHIFT) { jMapPanelHolder.requestFocusInWindow(); MapPanel.getSingleton().setShiftDown(true); } } else if (event.getID() == KeyEvent.KEY_RELEASED) { KeyEvent e = (KeyEvent) event; if (e.getKeyCode() == KeyEvent.VK_SPACE) { MapPanel.getSingleton().setSpaceDown(false); } else if (e.getKeyCode() == KeyEvent.VK_SHIFT) { MapPanel.getSingleton().setShiftDown(false); } } } }, AWTEvent.KEY_EVENT_MASK); // </editor-fold> // <editor-fold defaultstate="collapsed" desc=" Load UI Icons "> try { jOnlineLabel.setIcon(new ImageIcon("./graphics/icons/online.png")); jEnableClipboardWatchButton.setIcon(new ImageIcon("./graphics/icons/watch_clipboard.png")); jCenterIngameButton .setIcon(new ImageIcon(DSWorkbenchMainFrame.class.getResource("/res/ui/center_ingame.png"))); jRefreshButton.setIcon(new ImageIcon("./graphics/icons/refresh.png")); jCenterCoordinateIngame.setIcon(new ImageIcon("./graphics/icons/center.png")); } catch (Exception e) { logger.error("Failed to load status icon(s)", e); } // </editor-fold> // <editor-fold defaultstate="collapsed" desc=" Check for desktop support "> if (!Desktop.isDesktopSupported()) { jCenterIngameButton.setEnabled(false); jCenterCoordinateIngame.setEnabled(false); } // </editor-fold> // <editor-fold defaultstate="collapsed" desc=" Restore last map position "> try { String x = GlobalOptions.getSelectedProfile().getProperty("last.x"); String y = GlobalOptions.getSelectedProfile().getProperty("last.y"); centerPosition(Double.parseDouble(x), Double.parseDouble(y)); } catch (Exception e) { centerPosition(ServerSettings.getSingleton().getMapDimension().getCenterX(), ServerSettings.getSingleton().getMapDimension().getCenterY()); } // </editor-fold> // <editor-fold defaultstate="collapsed" desc=" Restore other settings "> jShowMapPopup.setSelected(GlobalOptions.getProperties().getBoolean("show.map.popup")); jShowMouseOverInfo.setSelected(GlobalOptions.getProperties().getBoolean("show.mouseover.info")); jIncludeSupport.setSelected(GlobalOptions.getProperties().getBoolean("include.support")); jHighlightTribeVillages.setSelected(GlobalOptions.getProperties().getBoolean("highlight.tribes.villages")); jShowRuler.setSelected(GlobalOptions.getProperties().getBoolean("show.ruler")); jDisplayChurch.setSelected(GlobalOptions.getProperties().getBoolean("show.church")); jDisplayWatchtower.setSelected(GlobalOptions.getProperties().getBoolean("show.watchtower")); jDisplayChurch.setEnabled(ServerSettings.getSingleton().isChurch()); jDisplayWatchtower.setEnabled(ServerSettings.getSingleton().isWatchtower()); ServerSettings.getSingleton().addListener(new ServerSettingsListener() { @Override public void fireServerSettingsChanged() { jDisplayChurch.setEnabled(ServerSettings.getSingleton().isChurch()); jDisplayWatchtower.setEnabled(ServerSettings.getSingleton().isWatchtower()); } }); int r = GlobalOptions.getProperties().getInt("radar.size"); int hour = r / 60; jHourField.setText(Integer.toString(hour)); jMinuteField.setText(Integer.toString(r - hour * 60)); // </editor-fold> // <editor-fold defaultstate="collapsed" desc="Skin Setup"> DefaultComboBoxModel gpModel = new DefaultComboBoxModel(GlobalOptions.getAvailableSkins()); jGraphicPacks.setModel(gpModel); String skin = GlobalOptions.getProperty("default.skin"); if (gpModel.getIndexOf(skin) != -1) { jGraphicPacks.setSelectedItem(skin); } else { jGraphicPacks.setSelectedItem("default"); } //</editor-fold> minZoom = GlobalOptions.getProperties().getDouble("map.zoom.min"); maxZoom = GlobalOptions.getProperties().getDouble("map.zoom.max"); dZoomInOutFactor = GlobalOptions.getProperties().getDouble("map.zoom.in.out.factor"); mNotificationHideThread = new NotificationHideThread(); mNotificationHideThread.start(); SystrayHelper.installSystrayIcon(); //update online state onlineStateChanged(); restoreProperties(); }
From source file:ffx.ui.MainMenu.java
/** * <p>//from ww w . j a v a 2s . co m * Constructor for MainMenu.</p> * * @param f a {@link ffx.ui.MainPanel} object. */ public MainMenu(MainPanel f) { // Create the Tool Bar toolBar = new JToolBar("Toolbar", JToolBar.HORIZONTAL); toolBar.setBorderPainted(true); toolBar.setRollover(true); JButton temp = new JButton(); insets = temp.getInsets(); insets.set(2, 2, 2, 2); mainPanel = f; graphics = mainPanel.getGraphics3D(); locale = mainPanel.getFFXLocale(); loader = getClass().getClassLoader(); blankIcon = new ImageIcon(loader.getResource(icons + "blank.gif")); String value = System.getProperty("structures", "false").trim(); try { includeStructureMenu = Boolean.parseBoolean(value); } catch (Exception e) { includeStructureMenu = false; } /** * Main Menubar */ JMenu fileMenu = addMenu("File", 'F'); JMenu selectionMenu = addMenu("Selection", 'E'); JMenu structureMenu = null; if (includeStructureMenu) { structureMenu = addMenu("Structure", 'S'); } JMenu displayMenu = addMenu("Display", 'D'); JMenu colorMenu = addMenu("Color", 'C'); JMenu optionsMenu = addMenu("Options", 'O'); JMenu pickingMenu = addMenu("Picking", 'P'); JMenu trajectoryMenu = addMenu("Trajectory", 'T'); JMenu exportMenu = addMenu("Export", 'X'); JMenu windowMenu = addMenu("Window", 'W'); JMenu helpMenu = addMenu("Help", 'H'); /** * File Menu - Events Handled by the MainPanel Class. */ addMenuItem(fileMenu, icons + "folder_page", "Open", 'O', KeyEvent.VK_O, mainPanel); addMenuItem(fileMenu, icons + "disk", "SaveAs", 'S', KeyEvent.VK_S, mainPanel); addMenuItem(fileMenu, icons + "cancel", "Close", 'C', -1, mainPanel); addMenuItem(fileMenu, "BLANK", "CloseAll", 'A', -1, mainPanel); fileMenu.addSeparator(); addMenuItem(fileMenu, icons + "drive_web", "DownloadFromPDB", 'D', KeyEvent.VK_D, mainPanel); fileMenu.addSeparator(); addMenuItem(fileMenu, "BLANK", "ChooseKeyFile", 'R', -1, mainPanel); addMenuItem(fileMenu, "BLANK", "ChooseLogFile", 'I', -1, mainPanel); addMenuItem(fileMenu, "BLANK", "LoadRestartData", 'R', -1, mainPanel); if (!SystemUtils.IS_OS_MAC_OSX) { fileMenu.addSeparator(); addMenuItem(fileMenu, "BLANK", "Exit", 'E', KeyEvent.VK_Q, mainPanel); } toolBar.addSeparator(); /** * Selection Menu - Events Handled by the MainPanel and GraphicsCanvas. */ addMenuItem(selectionMenu, icons + "add", "SelectAll", 'A', KeyEvent.VK_A, mainPanel); addMenuItem(selectionMenu, "BLANK", "RestrictToSelections", 'R', -1, graphics); addMenuItem(selectionMenu, icons + "arrow_merge", "MergeSelections", 'M', -1, mainPanel); selectionMenu.addSeparator(); highlightCBMI = addCBMenuItem(selectionMenu, icons + "asterisk_yellow", "HighlightSelections", 'H', KeyEvent.VK_H, mainPanel); addMenuItem(selectionMenu, "BLANK", "SetSelectionColor", 'S', -1, graphics); selectionMenu.addSeparator(); labelAtomsMI = addCBMenuItem(selectionMenu, "BLANK", "LabelSelectedAtoms", 'O', -1, graphics); labelResiduesMI = addCBMenuItem(selectionMenu, "BLANK", "LabelSelectedResidues", 'R', -1, graphics); addMenuItem(selectionMenu, "BLANK", "SetLabelFontSize", 'Z', -1, graphics); addMenuItem(selectionMenu, "BLANK", "SetLabelFontColor", 'C', -1, graphics); highlightCBMI.setSelected(false); labelAtomsMI.setSelected(false); labelResiduesMI.setSelected(false); toolBar.addSeparator(); /** * Structure Menu - Events Handled by the MainPanel. */ if (includeStructureMenu) { // Locate a jar file that has PDB Structures. String file = "ffx/xray/structures/1N7S.pdb"; addMenuItem(structureMenu, "BLANK", file, '.', -1, mainPanel); } /** * Display Menu - Events handled by the GraphicsCanvas. */ addMenuItem(displayMenu, "BLANK", "Wireframe", 'W', -1, graphics); addMenuItem(displayMenu, "BLANK", "Tube", 'T', -1, graphics); addMenuItem(displayMenu, "BLANK", "Spacefill", 'S', -1, graphics); addMenuItem(displayMenu, "BLANK", "BallAndStick", 'B', -1, graphics); addMenuItem(displayMenu, "BLANK", "Invisible", 'I', -1, graphics); addMenuItem(displayMenu, "BLANK", "RMIN", 'R', -1, graphics); displayMenu.addSeparator(); addMenuItem(displayMenu, "BLANK", "ShowHydrogens", 'H', -1, graphics); addMenuItem(displayMenu, "BLANK", "HideHydrogens", 'Y', -1, graphics); displayMenu.addSeparator(); addMenuItem(displayMenu, "BLANK", "Fill", 'F', -1, graphics); addMenuItem(displayMenu, "BLANK", "Points", 'P', -1, graphics); addMenuItem(displayMenu, "BLANK", "Lines", 'I', -1, graphics); displayMenu.addSeparator(); addMenuItem(displayMenu, "BLANK", "Preferences", 'P', -1, graphics); /** * Color Menu - Events handled by the GraphicsCanvas. */ addMenuItem(colorMenu, "BLANK", "Monochrome", 'M', -1, graphics); addMenuItem(colorMenu, "BLANK", "CPK", 'C', -1, graphics); addMenuItem(colorMenu, "BLANK", "Residue", 'R', -1, graphics); addMenuItem(colorMenu, "BLANK", "Structure", 'S', -1, graphics); addMenuItem(colorMenu, "BLANK", "Polymer", 'M', -1, graphics); addMenuItem(colorMenu, "BLANK", "PartialCharge", 'P', -1, graphics); addMenuItem(colorMenu, "BLANK", "UserColor", 'U', -1, graphics); colorMenu.addSeparator(); addMenuItem(colorMenu, "BLANK", "ApplyUserColor", 'A', -1, graphics); addMenuItem(colorMenu, "BLANK", "SetUserColor", 'C', -1, graphics); /** * Options Menu - Events handled by the GraphicsCanvas. */ dragModeButtonGroup = new ButtonGroup(); activeRBMI = addBGMI(dragModeButtonGroup, optionsMenu, "BLANK", "ActiveSystem", 'A', KeyEvent.VK_A, graphics); mouseRBMI = addBGMI(dragModeButtonGroup, optionsMenu, "BLANK", "SystemBelowMouse", 'S', KeyEvent.VK_M, graphics); activeRBMI.setSelected(true); optionsMenu.addSeparator(); JMenu leftMouseMenu = addSubMenu(optionsMenu, "LeftMouseButton", 'M'); leftMouseButtonGroup = new ButtonGroup(); rotateRBMI = addBGMI(leftMouseButtonGroup, leftMouseMenu, "BLANK", "Rotate", 'R', KeyEvent.VK_R, graphics); addBGMI(leftMouseButtonGroup, leftMouseMenu, "BLANK", "Translate", 'T', KeyEvent.VK_T, graphics); addBGMI(leftMouseButtonGroup, leftMouseMenu, "BLANK", "Zoom", 'Z', KeyEvent.VK_Z, graphics); rotateRBMI.setSelected(true); optionsMenu.addSeparator(); addMenuItem(optionsMenu, "BLANK", "RotateAboutCenter", 'C', KeyEvent.VK_C, graphics); addMenuItem(optionsMenu, "BLANK", "RotateAboutPick", 'P', KeyEvent.VK_P, graphics); addMenuItem(optionsMenu, "BLANK", "ResetRotation", 'R', -1, graphics); addMenuItem(optionsMenu, "BLANK", "ResetTranslation", 'T', -1, graphics); addMenuItem(optionsMenu, icons + "arrow_refresh", "ResetRotationAndTranslation", 'E', -1, graphics); optionsMenu.addSeparator(); addMenuItem(optionsMenu, icons + "magnifier_zoom_in", "ZoomIn", 'I', -1, graphics); addMenuItem(optionsMenu, icons + "magnifier_zoom_out", "ZoomOut", 'O', -1, graphics); addMenuItem(optionsMenu, "BLANK", "ResetGlobalZoom", 'Z', -1, graphics); addMenuItem(optionsMenu, "BLANK", "ResetGlobalRotation", 'N', -1, graphics); addMenuItem(optionsMenu, "BLANK", "ResetGlobalTranslation", 'O', -1, graphics); addMenuItem(optionsMenu, icons + "house", "ResetGlobalView", 'V', -1, graphics); optionsMenu.addSeparator(); addMenuItem(optionsMenu, "BLANK", "SetBackgroundColor", 'B', -1, graphics); toolBar.addSeparator(); /** * Picking Menu - Events handled by the GraphicsCanvas. */ levelBG = new ButtonGroup(); pickingCBMI = addCBMenuItem(pickingMenu, icons + "wand", "GraphicsPicking", 'G', KeyEvent.VK_0, graphics); pickingCBMI.setSelected(false); pickingMenu.addSeparator(); atomRBMI = addBGMI(levelBG, pickingMenu, "BLANK", "PickAtom", 'A', KeyEvent.VK_1, graphics); bondRBMI = addBGMI(levelBG, pickingMenu, "BLANK", "PickBond", 'B', KeyEvent.VK_2, graphics); angleRBMI = addBGMI(levelBG, pickingMenu, "BLANK", "PickAngle", 'N', KeyEvent.VK_3, graphics); dihedralRBMI = addBGMI(levelBG, pickingMenu, "BLANK", "PickDihedral", 'D', KeyEvent.VK_4, graphics); residueRBMI = addBGMI(levelBG, pickingMenu, "BLANK", "PickResidue", 'R', KeyEvent.VK_5, graphics); polymerRBMI = addBGMI(levelBG, pickingMenu, "BLANK", "PickPolymer", 'P', KeyEvent.VK_6, graphics); moleculeRBMI = addBGMI(levelBG, pickingMenu, "BLANK", "PickMolecule", 'M', KeyEvent.VK_7, graphics); systemRBMI = addBGMI(levelBG, pickingMenu, "BLANK", "PickSystem", 'S', KeyEvent.VK_8, graphics); pickingMenu.addSeparator(); measureDistanceRBMI = addBGMI(levelBG, pickingMenu, "BLANK", "MeasureDistance", 'I', -1, graphics); measureAngleRBMI = addBGMI(levelBG, pickingMenu, "BLANK", "MeasureAngle", 'L', -1, graphics); measureDihedralRBMI = addBGMI(levelBG, pickingMenu, "BLANK", "MeasureDihedral", 'H', -1, graphics); atomRBMI.setSelected(true); pickingMenu.addSeparator(); addMenuItem(pickingMenu, "BLANK", "SetGraphicsPickingColor", 'S', -1, graphics); toolBar.addSeparator(); /** * Trajectory Menu - Events handled by the MainPanel. */ oscillateCBMI = addCBMenuItem(trajectoryMenu, icons + "control_repeat_blue", "Oscillate", 'O', -1, mainPanel); oscillateCBMI.setSelected(false); addMenuItem(trajectoryMenu, "BLANK", "Frame", 'A', -1, mainPanel); addMenuItem(trajectoryMenu, "BLANK", "Speed", 'E', -1, mainPanel); addMenuItem(trajectoryMenu, "BLANK", "Skip", 'K', -1, mainPanel); trajectoryMenu.addSeparator(); addMenuItem(trajectoryMenu, icons + "control_play_blue", "Play", 'P', -1, mainPanel); addMenuItem(trajectoryMenu, icons + "control_stop_blue", "Stop", 'S', -1, mainPanel); addMenuItem(trajectoryMenu, icons + "control_fastforward_blue", "StepForward", 'F', -1, mainPanel); addMenuItem(trajectoryMenu, icons + "control_rewind_blue", "StepBack", 'B', -1, mainPanel); addMenuItem(trajectoryMenu, icons + "control_start_blue", "Reset", 'R', -1, mainPanel); toolBar.addSeparator(); /** * Export Menu - Events handled by the GraphicsCanvas. */ addMenuItem(exportMenu, icons + "camera", "CaptureGraphics", 'C', KeyEvent.VK_G, graphics); exportMenu.addSeparator(); captureFormatButtonGroup = new ButtonGroup(); addBGMI(captureFormatButtonGroup, exportMenu, "BLANK", "PNG", 'P', -1, graphics).setSelected(true); addBGMI(captureFormatButtonGroup, exportMenu, "BLANK", "JPEG", 'J', -1, graphics); addBGMI(captureFormatButtonGroup, exportMenu, "BLANK", "BMP", 'B', -1, graphics); addBGMI(captureFormatButtonGroup, exportMenu, "BLANK", "WBMP", 'W', -1, graphics); addBGMI(captureFormatButtonGroup, exportMenu, "BLANK", "GIF", 'G', -1, graphics); toolBar.addSeparator(); /** * Window Menu - Events handled by the GraphicsCanvas. */ addMenuItem(windowMenu, icons + "application_home", "ResetPanes", 'R', -1, mainPanel); addMenuItem(windowMenu, icons + "application_osx_terminal", "ResetConsole", 'L', -1, mainPanel); windowMenu.addSeparator(); addMenuItem(windowMenu, icons + "application_side_contract", "ExpandGraphicsWindow", 'E', -1, mainPanel); addMenuItem(windowMenu, icons + "application_side_expand", "ShrinkGraphicsWindow", 'L', -1, mainPanel); windowMenu.addSeparator(); systemsCBMI = addCBMenuItem(windowMenu, "BLANK", "ShowTree", 'T', -1, mainPanel); toolBarCBMI = addCBMenuItem(windowMenu, "BLANK", "ShowToolBar", 'B', -1, mainPanel); globalAxisCBMI = addCBMenuItem(windowMenu, "BLANK", "ShowGlobalAxes", 'C', -1, mainPanel); globalAxisCBMI.setSelected(true); toolBar.addSeparator(); /** * Help Menu - Events handled by the MainPanel. */ Action a = addMenuItem(helpMenu, icons + "help", "HelpContents", 'H', KeyEvent.VK_HELP, mainPanel); /** * Fix the ACCELERATOR_KEY for the Help menu item; no modifiers will be * used. */ a.putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_HELP, 0)); addMenuItem(helpMenu, "BLANK", "About", 'A', -1, mainPanel); }
From source file:eu.apenet.dpt.standalone.gui.DataPreparationToolGUI.java
private void setupTool() { LoggerJAXB.outputJaxpImplementationInfo(); Locale currentLocale = Locale.getDefault(); labels = new ResourceBundlesWrapper(I18N_BASENAMES, currentLocale); retrieveFromDb = new RetrieveFromDb(); apePanel = new APEPanel(labels, getContentPane(), this, retrieveFromDb); Utilities.setXsdList(fillXsdList()); CheckList checkList = new CheckList(); langList = checkList.getLangList();/* w w w .j av a 2s . com*/ levelList = checkList.getLevelList(); dateNormalization = new DateNormalization(); super.setTitle(labels.getString("title")); Image topLeftIcon = Utilities.icon.getImage(); setIconImage(topLeftIcon); doChecks(); if (isFileMissing(Utilities.LOG_DIR)) { new File(Utilities.LOG_DIR).mkdir(); } File tempDir = new File(Utilities.TEMP_DIR); //In case it didn't deleteOnExit at the previous closing of the program, we clean up. if (tempDir.exists()) { LOG.warn("Probably a problem when deleting the temp files at closure, so we clean up"); eraseOldTempFiles(tempDir); try { FileUtils.deleteDirectory(tempDir); } catch (IOException e) { LOG.error("Could not delete the temp directory. Attempt to delete the directory once more: " + (tempDir.delete() ? "Successful." : "Unsuccessful.")); } } tempDir.mkdir(); tempDir.deleteOnExit(); // ListControlaccessTerms listControlaccessTerms = new ListControlaccessTerms("/Users/yoannmoranville/Documents/Work/APE/data/AD78/"); // listControlaccessTerms.countTerms(); // listControlaccessTerms.displayLogsResults(); // CountCLevels countCLevels = new CountCLevels("/Users/yoannmoranville/Work/APEnet/Projects/data/Ready_APEnet/READY/Finland/HeNAF/FA_EAD/"); // CountCLevels countCLevels = new CountCLevels("/Users/yoannmoranville/Work/APEnet/Projects/data/BORA/ALL/"); // countCLevels.setCopyInAppropriateDirs(true); // countCLevels.changeMainagencycodeForSweden(false); // countCLevels.countLevels(); // SeparateFinnishFiles separateFinnishFiles = new SeparateFinnishFiles(new File("/Users/yoannmoranville/Desktop/files_fi"), TEMP_DIR); makeDefaultXsdMenuItems(); makeDefaultXslMenuItems(); getContentPane().add(apePanel); xmlEadListModel = new ProfileListModel(fileInstances, this); xmlEadList = new JList(xmlEadListModel); xmlEadList.setCellRenderer(new IconListCellRenderer(fileInstances)); xmlEadList.setDragEnabled(true); xmlEadList.setTransferHandler(new ListTransferHandler()); xmlEadList.setDropTarget(new DropTarget(xmlEadList, new ListDropTargetListener(xmlEadList, from))); xmlEadListModel.setList(xmlEadList); JMenuBar menuBar = new JMenuBar(); menuBar.add(fileMenu); menuBar.add(optionMenu); menuBar.add(actionMenu); menuBar.add(windowMenu); menuBar.add(helpMenu); fileItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); fileMenu.add(fileItem); closeSelectedItem.setEnabled(false); // closeSelectedItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); closeSelectedItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_D, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); fileMenu.add(closeSelectedItem); saveSelectedItem.setEnabled(false); saveSelectedItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); fileMenu.add(saveSelectedItem); saveMessageReportItem.setEnabled(false); saveMessageReportItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_R, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); fileMenu.add(saveMessageReportItem); // sendFilesWebDAV.setEnabled(false); // fileMenu.add(sendFilesWebDAV); fileMenu.addSeparator(); fileMenu.add(quitItem); optionMenu.add(countryCodeItem); optionMenu.add(repositoryCodeItem); optionMenu.add(digitalObjectTypeItem); optionMenu.add(edmGeneralOptionsItem); optionMenu.add(listDateConversionRulesItem); optionMenu.addSeparator(); optionMenu.add(xsltItem); optionMenu.add(xsdItem); optionMenu.add(defaultXslSelectionSubmenu); optionMenu.add(defaultXsdSelectionSubmenu); optionMenu.addSeparator(); optionMenu.add(checksLoadingFilesItem); optionMenu.add(defaultSaveFolderItem); optionMenu.add(languageMenu); if (Utilities.isDev) { optionMenu.addSeparator(); optionMenu.add(databaseItem); } validateItem.setEnabled(false); validateItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_N, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); actionMenu.add(validateItem); convertItem.setEnabled(false); convertItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_M, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); actionMenu.add(convertItem); actionMenu.addSeparator(); // TODO: Uncomment when edit will be available. // eacCpfItem.add(this.editEacCpfFile); //add the different EAC-CPF options menu eacCpfItem.add(createEacCpf); actionMenu.add(eacCpfItem); createEag2012Item.add(createEag2012FromExistingEag2012); createEag2012Item.add(createEag2012FromScratch); actionMenu.add(createEag2012Item); summaryWindowItem.setEnabled(true); summaryWindowItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_1, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); windowMenu.add(summaryWindowItem); validationWindowItem.setEnabled(true); validationWindowItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_2, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); windowMenu.add(validationWindowItem); conversionWindowItem.setEnabled(true); conversionWindowItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_3, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); windowMenu.add(conversionWindowItem); edmConversionWindowItem.setEnabled(true); edmConversionWindowItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_4, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); windowMenu.add(edmConversionWindowItem); editionWindowItem.setEnabled(true); editionWindowItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_5, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); windowMenu.add(editionWindowItem); helpMenu.add(internetApexItem); helpMenu.addSeparator(); JMenuItem versionItem = new JMenuItem("APE DPT v" + VERSION_NB); versionItem.setEnabled(false); helpMenu.add(versionItem); createLanguageMenu(); fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); fileChooser.setMultiSelectionEnabled(true); getContentPane().add(menuBar, BorderLayout.NORTH); apePanel.setFilename(""); createHgListener = new CreateHGListener(retrieveFromDb, labels, getContentPane(), fileInstances, xmlEadList, this); createHGBtn.addActionListener(createHgListener); createHGBtn.setEnabled(false); analyzeControlaccessListener = new AnalyzeControlaccessListener(labels, getContentPane(), fileInstances); analyzeControlaccessBtn.addActionListener(analyzeControlaccessListener); analyzeControlaccessBtn.setEnabled(false); validateItem.addActionListener(new ConvertAndValidateActionListener(this, apePanel.getApeTabbedPane(), ConvertAndValidateActionListener.VALIDATE)); convertItem.addActionListener(new ConvertAndValidateActionListener(this, apePanel.getApeTabbedPane(), ConvertAndValidateActionListener.CONVERT)); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); getContentPane().add(createWest(), BorderLayout.WEST); // convertAndValidateBtn.addActionListener(new ConvertAndValidateActionListener(this, getContentPane())); // validateSelectionBtn.addActionListener(new ValidateSelectionActionListener(this, getContentPane())); // convertEdmSelectionBtn.addActionListener(new ConvertEdmActionListener(labels, this, apePanel)); nameComponents(); wireUp(); setSize(Toolkit.getDefaultToolkit().getScreenSize()); setMinimumSize(Toolkit.getDefaultToolkit().getScreenSize()); setExtendedState(JFrame.MAXIMIZED_BOTH); }
From source file:com.std.StockPanel.java
public void setHistoricalData() { this.setLayout(new BorderLayout()); nameAndChangePanel.setLayout(new BoxLayout(nameAndChangePanel, BoxLayout.PAGE_AXIS)); nameAndChangePanel.add(nameLbl);/*from w w w .j a v a 2 s. c o m*/ nameAndChangePanel.add(priceChangePercentLbl); data = new Object[30][2]; String[] colnames = { "1", "2" }; GridBagConstraints c = new GridBagConstraints(); dataAndGraph.setLayout(new GridBagLayout()); c.anchor = GridBagConstraints.NORTHWEST; c.fill = GridBagConstraints.BOTH; c.weightx = 1; c.weighty = 0; c.gridheight = 1; c.insets = new Insets(0, 20, 0, 20); dataAndGraph.add(nameAndChangePanel, c); c.weightx = 0; c.weighty = 1; c.insets = new Insets(0, 20, 0, 0); //c.ipady = 20; c.gridx = 0; c.gridy = 1; remainingInfoTable = new StockTable(data, colnames); remainingInfoTable.setShowGrid(false); remainingInfoTable.setTableHeader(null); remainingInfoTable.setBackground(this.getBackground()); remainingInfoTable.setFocusable(false); remainingInfoTable.setColumnSelectionAllowed(false); remainingInfoTable.setRowSelectionAllowed(false); remainingInfoTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); dataAndGraph.add(remainingInfoTable, c); this.add(dataAndGraph, BorderLayout.CENTER); c.anchor = GridBagConstraints.NORTHWEST; c.fill = GridBagConstraints.BOTH; c.weightx = 1; c.weighty = 0; c.gridheight = 2; //c.ipady = 20; c.gridx = 1; c.gridy = 0; dataAndGraph.add(chartPane, c); chartPane.setVisible(false); this.add(dataAndGraph, BorderLayout.CENTER); Test.show_hist_data(currentStock, b); currentStock.calculate_beta(sp500, 1200); nameLbl.setText(currentStock.get_name() + " (" + currentStock.get_symbol() + ")"); nameLbl.setFont(new Font(nameLbl.getName(), Font.BOLD, 24)); priceChangePercentLbl.setText(currentStock.get_price() + " "); String message = currentStock.get_change() + " " + currentStock.get_percent_change(); if (Double.parseDouble(currentStock.get_change()) < 0) priceChangePercentLbl.setText(String.format("<html>%s<font color='red'>%s</font></html>", priceChangePercentLbl.getText(), message)); else priceChangePercentLbl.setText(String.format("<html>%s<font color='green'>%s</font></html>", priceChangePercentLbl.getText(), message)); priceChangePercentLbl.setFont(new Font(priceChangePercentLbl.getName(), Font.PLAIN, 15)); data[0][0] = "Prev Close: " + currentStock.get_prev_close(); data[1][0] = "Open: " + currentStock.get_open_price(); data[2][0] = "Bid: " + currentStock.get_bid(); data[3][0] = "Ask: " + currentStock.get_ask(); data[4][0] = "One Year Target: " + currentStock.get_one_year_target(); data[5][0] = "Ebita: " + currentStock.get_ebitda(); data[0][1] = "Day Range: " + currentStock.get_days_range(); data[1][1] = "52 Week Range: " + currentStock.get_year_range(); data[2][1] = "Volume: " + currentStock.get_volume(); data[3][1] = "Average Daily Volume: " + currentStock.get_avg_daily_volume(); data[4][1] = "Market Cap: " + currentStock.get_market_cap(); data[5][1] = "P/E: " + currentStock.get_pe(); data[6][1] = "EPS: " + currentStock.get_earnings_per_share(); data[7][1] = "Dividend (Yield): " + currentStock.get_dividend_per_share() + "(" + currentStock.get_dividend_yield() + ")"; data[6][0] = "Reveune:" + currentStock.get_revenue(); data[7][0] = "Earnings Estimate: " + currentStock.get_earnings_estimate_current_year(); data[8][0] = "Beta: " + currentStock.get_beta(); data[8][1] = "PEG Ratio: " + currentStock.get_peg_ratio(); data[9][0] = "Short Ratio: " + currentStock.get_short_ratio(); data[11][0] = "50 Day MA: " + currentStock.get_fiftyday_moving_avg(); data[12][0] = "200 Day MA: " + currentStock.get_twohundredday_moving_avg(); if (currentStock.get_change_from_fiftyday_moving_avg() != null && currentStock.get_change_from_fiftyday_moving_avg().contains("-")) { data[13][0] = String.format("<html>%s<font color='red'>%s</font></html>", "Change 50 Day MA: ", currentStock.get_change_from_fiftyday_moving_avg()); data[14][0] = String.format("<html>%s<font color='red'>%s</font></html>", "Percent 50 Day MA: ", currentStock.get_percent_change_from_fiftyday_moving_avg()); } else { data[13][0] = String.format("<html>%s<font color='green'>%s</font></html>", "Change 50 Day MA: ", currentStock.get_change_from_fiftyday_moving_avg()); data[14][0] = String.format("<html>%s<font color='green'>%s</font></html>", "Percent 50 Day MA: ", currentStock.get_percent_change_from_fiftyday_moving_avg()); } if (currentStock.get_change_from_twohundredday_moving_avg() != null && currentStock.get_change_from_twohundredday_moving_avg().contains("-")) { data[15][0] = String.format("<html>%s<font color='red'>%s</font></html>", "Change 200 Day MA: ", currentStock.get_change_from_twohundredday_moving_avg()); data[16][0] = String.format("<html>%s<font color='red'>%s</font></html>", "Percent 200 Day MA: ", currentStock.get_percent_change_from_twohundredday_moving_avg()); } else { data[15][0] = String.format("<html>%s<font color='green'>%s</font></html>", "Change 200 Day MA: ", currentStock.get_change_from_twohundredday_moving_avg()); data[16][0] = String.format("<html>%s<font color='green'>%s</font></html>", "Percent 200 Day MA: ", currentStock.get_percent_change_from_twohundredday_moving_avg()); } data[17][0] = "Year High: " + currentStock.get_year_high(); data[18][0] = "Year Low: " + currentStock.get_year_low(); if (currentStock.get_change_from_year_high() != null && currentStock.get_change_from_year_high().contains("-")) { data[19][0] = String.format("<html>%s<font color='red'>%s</font></html>", "Year High Change: ", currentStock.get_change_from_year_high()); data[20][0] = String.format("<html>%s<font color='red'>%s</font></html>", "Year High Percent: ", currentStock.get_percent_change_from_year_high()); } else { data[19][0] = String.format("<html>%s<font color='green'>%s</font></html>", "Year High Change: ", currentStock.get_change_from_year_high()); data[20][0] = String.format("<html>%s<font color='green'>%s</font></html>", "Year High Percent: ", currentStock.get_percent_change_from_year_high()); } if (currentStock.get_change_from_year_low() != null && currentStock.get_change_from_year_low().contains("-")) { data[21][0] = String.format("<html>%s<font color='red'>%s</font></html>", "Year Low Change: ", currentStock.get_change_from_year_low()); data[22][0] = String.format("<html>%s<font color='red'>%s</font></html>", "Year Low Percent: ", currentStock.get_percent_change_from_year_low()); } else { data[21][0] = String.format("<html>%s<font color='green'>%s</font></html>", "Year Low Change: ", currentStock.get_change_from_year_low()); data[22][0] = String.format("<html>%s<font color='green'>%s</font></html>", "Year Low Percent: ", currentStock.get_percent_change_from_year_low()); } if (currentStock.get_five_day_change()[0] != null && currentStock.get_five_day_change()[0].contains("-")) data[11][1] = String.format("<html>%s<font color='red'>%s</font></html>", "5D Change: ", currentStock.get_five_day_change()[0] + " (" + currentStock.get_five_day_change()[1] + ")"); else data[11][1] = String.format("<html>%s<font color='green'>%s</font></html>", "5D Change: ", currentStock.get_five_day_change()[0] + " (" + currentStock.get_five_day_change()[1] + ")"); if (currentStock.get_one_month_change()[0] != null && currentStock.get_one_month_change()[0].contains("-")) data[12][1] = String.format("<html>%s<font color='red'>%s</font></html>", "1M Change: ", currentStock.get_one_month_change()[0] + " (" + currentStock.get_one_month_change()[1] + ")"); else data[12][1] = String.format("<html>%s<font color='green'>%s</font></html>", "1M Change: ", currentStock.get_one_month_change()[0] + " (" + currentStock.get_one_month_change()[1] + ")"); if (currentStock.get_three_month_change()[0] != null && currentStock.get_three_month_change()[0].contains("-")) data[13][1] = String.format("<html>%s<font color='red'>%s</font></html>", "3M Change: ", currentStock.get_three_month_change()[0] + " (" + currentStock.get_three_month_change()[1] + ")"); else data[13][1] = String.format("<html>%s<font color='green'>%s</font></html>", "3M Change: ", currentStock.get_three_month_change()[0] + " (" + currentStock.get_three_month_change()[1] + ")"); if (currentStock.get_six_month_change()[0] != null && currentStock.get_six_month_change()[0].contains("-")) data[14][1] = String.format("<html>%s<font color='red'>%s</font></html>", "6M Change: ", currentStock.get_six_month_change()[0] + " (" + currentStock.get_six_month_change()[1] + ")"); else data[14][1] = String.format("<html>%s<font color='green'>%s</font></html>", "6M Change: ", currentStock.get_six_month_change()[0] + " (" + currentStock.get_six_month_change()[1] + ")"); if (currentStock.get_ytd_change()[0] != null && currentStock.get_ytd_change()[0].contains("-")) data[15][1] = String.format("<html>%s<font color='red'>%s</font></html>", "YTD Change: ", currentStock.get_ytd_change()[0] + " (" + currentStock.get_ytd_change()[1] + ")"); else data[15][1] = String.format("<html>%s<font color='green'>%s</font></html>", "YTD Change: ", currentStock.get_ytd_change()[0] + " (" + currentStock.get_ytd_change()[1] + ")"); if (currentStock.get_one_year_change()[0] != null && currentStock.get_one_year_change()[0].contains("-")) data[16][1] = String.format("<html>%s<font color='red'>%s</font></html>", "1Y Change: ", currentStock.get_one_year_change()[0] + " (" + currentStock.get_one_year_change()[1] + ")"); else data[16][1] = String.format("<html>%s<font color='green'>%s</font></html>", "1Y Change: ", currentStock.get_one_year_change()[0] + " (" + currentStock.get_one_year_change()[1] + ")"); if (currentStock.get_five_year_change()[0] != null && currentStock.get_five_year_change()[0].contains("-")) data[17][1] = String.format("<html>%s<font color='red'>%s</font></html>", "5Y Change: ", currentStock.get_five_year_change()[0] + " (" + currentStock.get_five_year_change()[1] + ")"); else data[17][1] = String.format("<html>%s<font color='green'>%s</font></html>", "5Y Change: ", currentStock.get_five_year_change()[0] + " (" + currentStock.get_five_year_change()[1] + ")"); if (currentStock.get_ten_year_change()[0] != null && currentStock.get_ten_year_change()[0].contains("-")) data[18][1] = String.format("<html>%s<font color='red'>%s</font></html>", "10Y Change: ", currentStock.get_ten_year_change()[0] + " (" + currentStock.get_ten_year_change()[1] + ")"); else data[18][1] = String.format("<html>%s<font color='green'>%s</font></html>", "10Y Change: ", currentStock.get_ten_year_change()[0] + " (" + currentStock.get_ten_year_change()[1] + ")"); if (currentStock.get_max_year_change()[0] != null && currentStock.get_max_year_change()[0].contains("-")) data[19][1] = String.format("<html>%s<font color='red'>%s</font></html>", "Max Change: ", currentStock.get_max_year_change()[0] + " (" + currentStock.get_max_year_change()[1] + ")"); else data[19][1] = String.format("<html>%s<font color='green'>%s</font></html>", "Max Change: ", currentStock.get_max_year_change()[0] + " (" + currentStock.get_max_year_change()[1] + ")"); data[24][0] = "Earnings Est Next Quarter: " + currentStock.get_earnings_estimate_next_quarter(); data[25][0] = "Earnings Est Current Year: " + currentStock.get_earnings_estimate_current_year(); data[26][0] = "Earnings Est Next Year: " + currentStock.get_earnings_estimate_next_year(); data[24][1] = "P/E Est Current Year: " + currentStock.get_price_eps_estimate_current_year(); data[25][1] = "P/E Est Next Year: " + currentStock.get_price_eps_estimate_next_year(); remainingInfoTable.setFont(new Font(remainingInfoTable.getName(), Font.PLAIN, 15)); remainingInfoTable.packColumn(0, 4); remainingInfoTable.packColumn(1, 4); try { dataAndGraph.remove(chartPane); chartPane = new JTabbedPane(); chartPane.setVisible(true); ChartPanel intradayChart = new IntradayChart(currentStock).getChartPanel(); intradayChart.setPopupMenu(graphMenu); chartPane.addTab("1d", intradayChart); chartPane.setMnemonicAt(0, KeyEvent.VK_1); ChartPanel fivedayChart = new FiveDayChart(currentStock).getChartPanel(); fivedayChart.setPopupMenu(graphMenu); chartPane.addTab("5d", fivedayChart); chartPane.setMnemonicAt(0, KeyEvent.VK_2); ChartPanel onemonthChart = new OneMonthChart(currentStock).getChartPanel(); onemonthChart.setPopupMenu(graphMenu); chartPane.addTab("1m", onemonthChart); chartPane.setMnemonicAt(0, KeyEvent.VK_3); ChartPanel threemonthChart = new ThreeMonthChart(currentStock).getChartPanel(); threemonthChart.setPopupMenu(graphMenu); chartPane.addTab("3m", threemonthChart); chartPane.setMnemonicAt(0, KeyEvent.VK_4); ChartPanel sixmonthChart = new SixMonthChart(currentStock).getChartPanel(); sixmonthChart.setPopupMenu(graphMenu); chartPane.addTab("6m", sixmonthChart); chartPane.setMnemonicAt(0, KeyEvent.VK_5); ChartPanel ytdChart = new YTDChart(currentStock).getChartPanel(); ytdChart.setPopupMenu(graphMenu); chartPane.addTab("ytd", ytdChart); chartPane.setMnemonicAt(0, KeyEvent.VK_6); ChartPanel oneyearChart = new OneYearChart(currentStock).getChartPanel(); oneyearChart.setPopupMenu(graphMenu); chartPane.addTab("1y", oneyearChart); chartPane.setMnemonicAt(0, KeyEvent.VK_7); ChartPanel fiveyearChart = new FiveYearChart(currentStock).getChartPanel(); fiveyearChart.setPopupMenu(graphMenu); chartPane.addTab("5y", fiveyearChart); chartPane.setMnemonicAt(0, KeyEvent.VK_8); ChartPanel tenyearChart = new TenYearChart(currentStock).getChartPanel(); tenyearChart.setPopupMenu(graphMenu); chartPane.addTab("10y", tenyearChart); chartPane.setMnemonicAt(0, KeyEvent.VK_9); ChartPanel maxChart = new MaxChart(currentStock).getChartPanel(); maxChart.setPopupMenu(graphMenu); chartPane.addTab("max", maxChart); chartPane.setMnemonicAt(0, KeyEvent.VK_0); c = new GridBagConstraints(); c.anchor = GridBagConstraints.NORTHWEST; c.fill = GridBagConstraints.BOTH; c.weightx = 1; c.weighty = 0; c.gridheight = 2; //c.ipady = 20; c.gridx = 1; c.gridy = 0; dataAndGraph.add(chartPane, c); } catch (ParseException ex) { Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex); } chartPane.revalidate(); chartPane.repaint(); revalidate(); repaint(); finished = true; }
From source file:es.darkhogg.hazelnutt.EditorFrame.java
private void initializeGui() { setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); setBounds(100, 100, 640, 480);/* w w w .j av a 2 s. com*/ addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent arg0) { actionExit(); } }); fileChooser = new JFileChooser(); //fileChooser.setFileFilter( hlfFileFilter ); hlfFileChooser = new JFileChooser(); hlfFileChooser.setFileFilter(hlfFileFilter); JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenu mnFile = new JMenu("File"); mnFile.setMnemonic('F'); menuBar.add(mnFile); menuLoadRom = new JMenuItem("Load ROM..."); menuLoadRom.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_MASK)); menuLoadRom.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionOpenRom(null); } }); menuLoadRom.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_open.png"))); menuLoadRom.setMnemonic('O'); mnFile.add(menuLoadRom); menuSaveRom = new JMenuItem("Save ROM"); menuSaveRom.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionSaveRom(); } }); menuSaveRom.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_save.png"))); menuSaveRom.setMnemonic('S'); menuSaveRom.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK)); mnFile.add(menuSaveRom); menuSaveRomAs = new JMenuItem("Save ROM As..."); menuSaveRomAs.setMnemonic('a'); menuSaveRomAs.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_MASK)); menuSaveRomAs.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionSaveRomAs(); } }); menuSaveRomAs .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_save_as.png"))); mnFile.add(menuSaveRomAs); mnFile.addSeparator(); menuLoadLevel = new JMenuItem("Load Level..."); menuLoadLevel.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0)); menuLoadLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionLoadLevel(); } }); menuLoadLevel.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_load_level.png"))); menuLoadLevel.setMnemonic('L'); mnFile.add(menuLoadLevel); menuReloadLevel = new JMenuItem("Reload Level"); menuReloadLevel.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F6, 0)); menuReloadLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionReloadLevel(); } }); menuReloadLevel.setMnemonic('R'); menuReloadLevel.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_reload_level.png"))); mnFile.add(menuReloadLevel); menuSaveLevel = new JMenuItem("Save Level"); menuSaveLevel.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F7, 0)); menuSaveLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionSaveLevel(); } }); menuSaveLevel.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_save_level.png"))); menuSaveLevel.setMnemonic('v'); mnFile.add(menuSaveLevel); //* mnFile.addSeparator(); menuImportLevel = new JMenuItem("Import Level..."); menuImportLevel.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0)); menuImportLevel.setMnemonic('i'); menuImportLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionImportLevel(); } }); menuImportLevel .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_import.png"))); mnFile.add(menuImportLevel); menuExportLevel = new JMenuItem("Export Level..."); menuExportLevel.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0)); menuExportLevel.setMnemonic('e'); menuExportLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionExportLevel(); } }); menuExportLevel .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_export.png"))); mnFile.add(menuExportLevel); //*/ mnFile.addSeparator(); menuExit = new JMenuItem("Exit"); menuExit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0)); menuExit.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_exit.png"))); menuExit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { actionExit(); } }); menuRecentFiles = new JMenu("Recent Files..."); mnFile.add(menuRecentFiles); mnFile.addSeparator(); menuExit.setMnemonic('X'); mnFile.add(menuExit); JMenu mnEdit = new JMenu("Edit"); mnEdit.setMnemonic('E'); menuBar.add(mnEdit); menuViewSpawn = new JCheckBoxMenuItem("View Spawn Point"); menuViewSpawn.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1, 0)); menuViewSpawn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(false); } }); menuClearLevel = new JMenuItem("Clear Level"); menuClearLevel.setMnemonic('c'); menuClearLevel.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_MASK)); menuClearLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionClearLevel(); } }); menuClearLevel.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_clear_level.png"))); mnEdit.add(menuClearLevel); mnEdit.addSeparator(); menuViewSpawn .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_spawn.png"))); menuViewSpawn.setMnemonic('S'); menuViewSpawn.setSelected(true); mnEdit.add(menuViewSpawn); menuViewItems = new JCheckBoxMenuItem("View Items"); menuViewItems.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_2, 0)); menuViewItems.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(false); } }); menuViewItems.setSelected(true); menuViewItems .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_items.png"))); menuViewItems.setMnemonic('I'); mnEdit.add(menuViewItems); menuViewDoorItems = new JCheckBoxMenuItem("View Door Items"); menuViewDoorItems.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_3, 0)); menuViewDoorItems.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(false); } }); menuViewDoorItems.setSelected(true); menuViewDoorItems.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_door_items.png"))); menuViewDoorItems.setMnemonic('D'); mnEdit.add(menuViewDoorItems); menuViewEnemies = new JCheckBoxMenuItem("View Enemies"); menuViewEnemies.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_4, 0)); menuViewEnemies.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(false); } }); menuViewEnemies.setSelected(true); menuViewEnemies .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_enemies.png"))); menuViewEnemies.setMnemonic('E'); mnEdit.add(menuViewEnemies); menuViewTypes = new JCheckBoxMenuItem("View Combo Types"); menuViewTypes.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_5, 0)); menuViewTypes.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(false); } }); menuViewTypes.setSelected(true); menuViewTypes.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_combo_infos.png"))); menuViewTypes.setMnemonic('C'); mnEdit.add(menuViewTypes); mnEdit.addSeparator(); scaleMenuItem = new JCheckBoxMenuItem("Scale Level Display"); scaleMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_6, 0)); scaleMenuItem.setMnemonic('l'); scaleMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionScale(false); } }); scaleMenuItem.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_x2.png"))); mnEdit.add(scaleMenuItem); gridMenuItem = new JCheckBoxMenuItem("Display grid"); gridMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_7, 0)); gridMenuItem.setMnemonic('G'); gridMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionGrid(false); } }); gridMenuItem.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_grid.png"))); mnEdit.add(gridMenuItem); //mnEdit.addSeparator(); mntmPreferences = new JMenuItem("Preferences..."); mntmPreferences.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionPreferences(); } }); mntmPreferences.setMnemonic('P'); mntmPreferences.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_preferences.png"))); //mnEdit.add(mntmPreferences); mnHelp = new JMenu("Help"); mnHelp.setMnemonic('H'); menuBar.add(mnHelp); mntmCheckUpdates = new JMenuItem("Check for Updates..."); mntmCheckUpdates.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.CTRL_MASK)); mntmCheckUpdates.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionCheckUpdates(); } }); mntmCheckUpdates.setMnemonic('c'); mntmCheckUpdates .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_update.png"))); mnHelp.add(mntmCheckUpdates); mntmAbout = new JMenuItem("Readme..."); mntmAbout.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0)); mntmAbout.setMnemonic('r'); mntmAbout.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/about.png"))); mntmAbout.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionAbout(); } }); mnHelp.addSeparator(); mnHelp.add(mntmAbout); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); contentPane.setLayout(new BorderLayout(0, 0)); setContentPane(contentPane); JToolBar toolBar = new JToolBar(); toolBar.setRollover(true); toolBar.setFloatable(false); contentPane.add(toolBar, BorderLayout.NORTH); barLoadRom = new JButton(""); barLoadRom.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionOpenRom(null); } }); barLoadRom.setToolTipText("Open"); barLoadRom.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_open.png"))); toolBar.add(barLoadRom); barSaveRom = new JButton(""); barSaveRom.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionSaveRom(); } }); barSaveRom.setToolTipText("Save"); barSaveRom.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_save.png"))); toolBar.add(barSaveRom); toolBar.addSeparator(); barImportLevel = new JButton(""); barImportLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionImportLevel(); } }); barImportLevel.setToolTipText("Import Level"); barImportLevel .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_import.png"))); toolBar.add(barImportLevel); barExportLevel = new JButton(""); barExportLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionExportLevel(); } }); barExportLevel.setToolTipText("Export Level"); barExportLevel .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_export.png"))); toolBar.add(barExportLevel); toolBar.addSeparator(); barLoadLevel = new JButton(""); barLoadLevel.setToolTipText("Load Level"); barLoadLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionLoadLevel(); } }); barLoadLevel.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_load_level.png"))); toolBar.add(barLoadLevel); barReloadLevel = new JButton(""); barReloadLevel.setToolTipText("Reload Current Level"); barReloadLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionReloadLevel(); } }); barReloadLevel.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_reload_level.png"))); toolBar.add(barReloadLevel); barSaveLevel = new JButton(""); barSaveLevel.setToolTipText("Save Level"); barSaveLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionSaveLevel(); } }); barSaveLevel.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_save_level.png"))); toolBar.add(barSaveLevel); toolBar.addSeparator(); barViewItems = new JToggleButton(""); barViewItems.setToolTipText("Toggle View Items"); barViewItems.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(true); } }); barViewSpawn = new JToggleButton(""); barViewSpawn.setToolTipText("Toggle View Spawn"); barViewSpawn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(true); } }); barClearLevel = new JButton(""); barClearLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionClearLevel(); } }); barClearLevel.setToolTipText("Clear Level"); barClearLevel.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_clear_level.png"))); toolBar.add(barClearLevel); toolBar.addSeparator(); barViewSpawn.setSelected(true); barViewSpawn.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_spawn.png"))); toolBar.add(barViewSpawn); barViewItems.setSelected(true); barViewItems.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_items.png"))); toolBar.add(barViewItems); barViewDoorItems = new JToggleButton(""); barViewDoorItems.setToolTipText("Toggle View Door Items"); barViewDoorItems.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(true); } }); barViewDoorItems.setSelected(true); barViewDoorItems.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_door_items.png"))); toolBar.add(barViewDoorItems); barViewEnemies = new JToggleButton(""); barViewEnemies.setToolTipText("toggle View Enemies"); barViewEnemies.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(true); } }); barViewEnemies.setSelected(true); barViewEnemies .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_enemies.png"))); toolBar.add(barViewEnemies); barViewTypes = new JToggleButton(""); barViewTypes.setToolTipText("Toggle view Combo Help"); barViewTypes.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(true); } }); barViewTypes.setSelected(true); barViewTypes.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_combo_infos.png"))); toolBar.add(barViewTypes); barViewSpawn.setSelected(config.getBoolean("Hazelnutt.gui.viewSpawn", true)); barViewItems.setSelected(config.getBoolean("Hazelnutt.gui.viewItems", true)); barViewDoorItems.setSelected(config.getBoolean("Hazelnutt.gui.viewDoorItems", true)); barViewEnemies.setSelected(config.getBoolean("Hazelnutt.gui.viewEnemies", true)); barViewTypes.setSelected(config.getBoolean("Hazelnutt.gui.viewHelp", true)); panel = new JPanel(); contentPane.add(panel, BorderLayout.EAST); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); selectorPanel = new SelectorPanel(); selectorPanel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Combo & Entity Selector", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 70, 213))); panel.add(selectorPanel); propertiesPanel = new PropertiesPanel(null); propertiesPanel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Level Properties", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 70, 213))); panel.add(propertiesPanel); toolBar.addSeparator(); scaleButton = new JToggleButton(""); scaleButton.setToolTipText("Toggle Scale Display"); scaleButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionScale(true); } }); scaleButton.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_x2.png"))); toolBar.add(scaleButton); scaleButton.setSelected(config.getBoolean("Hazelnutt.gui.scaled", false)); gridButton = new JToggleButton(""); gridButton.setToolTipText("Display Grid"); gridButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionGrid(true); } }); gridButton.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_grid.png"))); toolBar.add(gridButton); gridButton.setSelected(config.getBoolean("Hazelnutt.gui.grid", false)); Component horizontalGlue = Box.createHorizontalGlue(); toolBar.add(horizontalGlue); Component verticalGlue = Box.createVerticalGlue(); panel.add(verticalGlue); levelWrapper = new JPanel(); levelWrapper.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Level", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 70, 213))); contentPane.add(levelWrapper, BorderLayout.CENTER); levelWrapper.setLayout(new BorderLayout(0, 0)); scrollPane = new JScrollPane(); scrollPane.setBorder(new EmptyBorder(0, 0, 0, 0)); levelWrapper.add(scrollPane); levelDisplay = new LevelDisplay(); levelDisplay.addEditListener(new EditListener() { @Override public void leftPressed(int x, int y) { SelectionType st = selectorPanel.getSelectionType(); Object so = selectorPanel.getSelectedObject(); if (st == SelectionType.COMBO) { paintComboAt(x, y, ((Byte) so).byteValue()); } else if (st == SelectionType.SPAWN) { selectedLevel.getRomLevel().setSpawn(new IntVector(x, y)); levelHasChanged = true; } else if (st == SelectionType.ITEM) { Item ent = new Item((ItemType) so, x, y); EntityCollection<Item> ents = selectedLevel.getRomLevel().getItems(); for (Iterator<Item> it = ents.iterator(); it.hasNext();) { Item item = it.next(); if (item.getX() == x && item.getY() == y) { it.remove(); } } if (ents.size() <= ents.maxSize()) { ents.add(ent); levelHasChanged = true; } } else if (st == SelectionType.DOOR_ITEM) { Item ent = new Item((ItemType) so, x, y); EntityCollection<Item> ents = selectedLevel.getRomLevel().getDoorItems(); for (Iterator<Item> it = ents.iterator(); it.hasNext();) { Item item = it.next(); if (item.getX() == x && item.getY() == y) { it.remove(); } } if (ents.size() <= ents.maxSize()) { ents.add(ent); levelHasChanged = true; } } else if (st == SelectionType.ENEMY) { Enemy ent = new Enemy((EnemyType) so, x, y); EntityCollection<Enemy> ents = selectedLevel.getRomLevel().getEnemies(); for (Iterator<Enemy> it = ents.iterator(); it.hasNext();) { Enemy enem = it.next(); if (enem.getX() == x && enem.getY() == y) { it.remove(); } } if (ents.size() <= ents.maxSize()) { ents.add(ent); levelHasChanged = true; } } updateTitle(); levelDisplay.repaint(); levelHasChanged = true; } @Override public void centerPressed(int x, int y) { selectorPanel.forceComboSelection(selectedLevel.getRomLevel().getData()[x][y]); } @Override public void rightPressed(int x, int y) { deleteVisibleEntitiesAt(x, y); } @Override public void leftDragged(int x, int y) { if (selectorPanel.getSelectionType() == SelectionType.COMBO) { paintComboAt(x, y, ((Byte) selectorPanel.getSelectedObject()).byteValue()); } } @Override public void centerDragged(int x, int y) { // Nothing to de here } @Override public void rightDragged(int x, int y) { deleteVisibleEntitiesAt(x, y); } // Utility methods /*private void selectComboAt ( int x, int y ) { }/**/ private void paintComboAt(int x, int y, byte value) { selectedLevel.getRomLevel().getData()[x][y] = value; levelHasChanged = true; updateTitle(); levelDisplay.repaint(); } private void deleteVisibleEntitiesAt(int x, int y) { Collection<Item> items = selectedLevel.getRomLevel().getItems(); Collection<Item> doorItems = selectedLevel.getRomLevel().getDoorItems(); Collection<Enemy> enemies = selectedLevel.getRomLevel().getEnemies(); if (barViewItems.isSelected()) { for (Iterator<Item> it = items.iterator(); it.hasNext();) { Item item = it.next(); if (item.getX() == x && item.getY() == y) { it.remove(); levelHasChanged = true; } } } if (barViewDoorItems.isSelected()) { for (Iterator<Item> it = doorItems.iterator(); it.hasNext();) { Item doorItem = it.next(); if (doorItem.getX() == x && doorItem.getY() == y) { it.remove(); levelHasChanged = true; } } } if (barViewEnemies.isSelected()) { for (Iterator<Enemy> it = enemies.iterator(); it.hasNext();) { Enemy enem = it.next(); if (enem.getX() == x && enem.getY() == y) { it.remove(); levelHasChanged = true; } } } updateTitle(); levelDisplay.repaint(); } }); scrollPane.setViewportView(levelDisplay); updateTitle(); actionToggle(true); actionScale(true); actionGrid(true); setIconImage(Toolkit.getDefaultToolkit() .getImage(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/witch_hazel_big.png"))); setRomFeaturesEnabled(false); setLevelFeaturesEnabled(false); if (config.getBoolean("Hazelnutt.gui.maximum", false)) { setExtendedState(getExtendedState() | JFrame.MAXIMIZED_BOTH); } else { int x = config.getInt("Hazelnutt.gui.location.x", Integer.MIN_VALUE); int y = config.getInt("Hazelnutt.gui.location.y", Integer.MIN_VALUE); int w = config.getInt("Hazelnutt.gui.size.width", Integer.MIN_VALUE); int h = config.getInt("Hazelnutt.gui.size.height", Integer.MIN_VALUE); if (x == Integer.MIN_VALUE || x == Integer.MIN_VALUE || w == Integer.MIN_VALUE || h == Integer.MIN_VALUE) { setLocationRelativeTo(null); } else { setLocation(x, y); setSize(w, h); } } propertiesPanel.addApplyListener(new PropertiesPanel.ApplyListener() { @Override public void apply() { levelHasChanged = true; updateTitle(); updateDisplay(); } }); if (config.containsKey("Hazelnutt.gui.lastDirectory")) { File lastDir = new File(config.getString("Hazelnutt.gui.lastDirectory")); if (lastDir.exists() && lastDir.isDirectory()) { //logger.debug( "Resetting the last directory: '" + lastDir + "'" ); fileChooser.setCurrentDirectory(lastDir); } } // Configure the PgUp and PgDn shortcuts InputMap im = contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0), "PgUp"); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0), "PgDn"); ActionMap am = contentPane.getActionMap(); am.put("PgUp", new AbstractAction() { @Override public void actionPerformed(ActionEvent arg0) { actionLevelUp(); } }); am.put("PgDn", new AbstractAction() { @Override public void actionPerformed(ActionEvent arg0) { actionLevelDown(); } }); // Get the recent files recentFiles = new LinkedList<String>(Arrays.asList(config.getStringArray("Hazelnutt.gui.recentFiles"))); updateRecentFiles(); }
From source file:com.nbt.TreeFrame.java
private void createActions() { newAction = new NBTAction("New", "New", "New", KeyEvent.VK_N) { {/* w ww. j a v a 2s. co m*/ putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('N', Event.CTRL_MASK)); } @Override public void actionPerformed(ActionEvent e) { updateTreeTable(new CompoundTag("")); } }; browseAction = new NBTAction("Browse...", "Open", "Browse...", KeyEvent.VK_O) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('O', Event.CTRL_MASK)); } @Override public void actionPerformed(ActionEvent e) { JFileChooser fc = createFileChooser(); switch (fc.showOpenDialog(TreeFrame.this)) { case JFileChooser.APPROVE_OPTION: File file = fc.getSelectedFile(); Preferences prefs = getPreferences(); prefs.put(KEY_FILE, file.getAbsolutePath()); doImport(file); break; } } }; saveAction = new NBTAction("Save", "Save", "Save", KeyEvent.VK_S) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('S', Event.CTRL_MASK)); } @Override public void actionPerformed(ActionEvent e) { String path = textFile.getText(); File file = new File(path); if (file.canWrite()) { doExport(file); } else { saveAsAction.actionPerformed(e); } } }; saveAsAction = new NBTAction("Save As...", "SaveAs", "Save As...", KeyEvent.VK_UNDEFINED) { public void actionPerformed(ActionEvent e) { JFileChooser fc = createFileChooser(); switch (fc.showSaveDialog(TreeFrame.this)) { case JFileChooser.APPROVE_OPTION: File file = fc.getSelectedFile(); Preferences prefs = getPreferences(); prefs.put(KEY_FILE, file.getAbsolutePath()); doExport(file); break; } } }; refreshAction = new NBTAction("Refresh", "Refresh", "Refresh", KeyEvent.VK_F5) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke("F5")); } public void actionPerformed(ActionEvent e) { String path = textFile.getText(); File file = new File(path); if (file.canRead()) doImport(file); else showErrorDialog("The file could not be read."); } }; exitAction = new NBTAction("Exit", "Exit", KeyEvent.VK_ESCAPE) { @Override public void actionPerformed(ActionEvent e) { // TODO: this should check to see if any changes have been made // before exiting System.exit(0); } }; cutAction = new DefaultEditorKit.CutAction() { { String name = "Cut"; putValue(NAME, name); putValue(SHORT_DESCRIPTION, name); putValue(MNEMONIC_KEY, KeyEvent.VK_X); putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('X', Event.CTRL_MASK)); ImageFactory factory = new ImageFactory(); try { putValue(SMALL_ICON, new ImageIcon(factory.readGeneralImage(name, NBTAction.smallIconSize))); } catch (IOException e) { e.printStackTrace(); } try { putValue(LARGE_ICON_KEY, new ImageIcon(factory.readGeneralImage(name, NBTAction.largeIconSize))); } catch (IOException e) { e.printStackTrace(); } } }; copyAction = new DefaultEditorKit.CopyAction() { { String name = "Copy"; putValue(NAME, name); putValue(SHORT_DESCRIPTION, name); putValue(MNEMONIC_KEY, KeyEvent.VK_C); putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('C', Event.CTRL_MASK)); ImageFactory factory = new ImageFactory(); try { putValue(SMALL_ICON, new ImageIcon(factory.readGeneralImage(name, NBTAction.smallIconSize))); } catch (IOException e) { e.printStackTrace(); } try { putValue(LARGE_ICON_KEY, new ImageIcon(factory.readGeneralImage(name, NBTAction.largeIconSize))); } catch (IOException e) { e.printStackTrace(); } } }; pasteAction = new DefaultEditorKit.CutAction() { { String name = "Paste"; putValue(NAME, name); putValue(SHORT_DESCRIPTION, name); putValue(MNEMONIC_KEY, KeyEvent.VK_V); putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('V', Event.CTRL_MASK)); ImageFactory factory = new ImageFactory(); try { putValue(SMALL_ICON, new ImageIcon(factory.readGeneralImage(name, NBTAction.smallIconSize))); } catch (IOException e) { e.printStackTrace(); } try { putValue(LARGE_ICON_KEY, new ImageIcon(factory.readGeneralImage(name, NBTAction.largeIconSize))); } catch (IOException e) { e.printStackTrace(); } } }; deleteAction = new NBTAction("Delete", "Delete", "Delete", KeyEvent.VK_DELETE) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke("DELETE")); } public void actionPerformed(ActionEvent e) { int row = treeTable.getSelectedRow(); TreePath path = treeTable.getPathForRow(row); Object last = path.getLastPathComponent(); if (last instanceof NBTFileBranch) { NBTFileBranch branch = (NBTFileBranch) last; File file = branch.getFile(); String name = file.getName(); String message = "Are you sure you want to delete " + name + "?"; String title = "Continue?"; int option = JOptionPane.showConfirmDialog(TreeFrame.this, message, title, JOptionPane.OK_CANCEL_OPTION); switch (option) { case JOptionPane.CANCEL_OPTION: return; } if (!FileUtils.deleteQuietly(file)) { showErrorDialog(name + " could not be deleted."); return; } } TreePath parentPath = path.getParentPath(); Object parentLast = parentPath.getLastPathComponent(); NBTTreeTableModel model = treeTable.getTreeTableModel(); int index = model.getIndexOfChild(parentLast, last); if (parentLast instanceof Mutable<?>) { Mutable<?> mutable = (Mutable<?>) parentLast; if (last instanceof ByteWrapper) { ByteWrapper wrapper = (ByteWrapper) last; index = wrapper.getIndex(); } mutable.remove(index); } else { System.err.println(last.getClass()); return; } updateTreeTable(); treeTable.expandPath(parentPath); scrollTo(parentLast); treeTable.setRowSelectionInterval(row, row); } }; openAction = new NBTAction("Open...", "Open...", KeyEvent.VK_T) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('T', Event.CTRL_MASK)); final int diamondPickaxe = 278; SpriteRecord record = NBTTreeTable.register.getRecord(diamondPickaxe); BufferedImage image = record.getImage(); setSmallIcon(image); int width = 24, height = 24; Dimension size = new Dimension(width, height); Map<RenderingHints.Key, ?> hints = Thumbnail.createRenderingHints(Thumbnail.QUALITY); BufferedImage largeImage = Thumbnail.createThumbnail(image, size, hints); setLargeIcon(largeImage); } public void actionPerformed(ActionEvent e) { TreePath path = treeTable.getPath(); if (path == null) return; Object last = path.getLastPathComponent(); if (last instanceof Region) { Region region = (Region) last; createAndShowTileCanvas(new TileCanvas.TileWorld(region)); return; } else if (last instanceof World) { World world = (World) last; createAndShowTileCanvas(world); return; } if (last instanceof NBTFileBranch) { NBTFileBranch fileBranch = (NBTFileBranch) last; File file = fileBranch.getFile(); try { open(file); } catch (IOException ex) { ex.printStackTrace(); showErrorDialog(ex.getMessage()); } } } private void open(File file) throws IOException { if (Desktop.isDesktopSupported()) { Desktop desktop = Desktop.getDesktop(); if (desktop.isSupported(Desktop.Action.OPEN)) { desktop.open(file); } } } }; addByteAction = new NBTAction("Add Byte", NBTConstants.TYPE_BYTE, "Add Byte", KeyEvent.VK_1) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('1', Event.CTRL_MASK)); } public void actionPerformed(ActionEvent e) { addTag(new ByteTag("new byte", (byte) 0)); } }; addShortAction = new NBTAction("Add Short", NBTConstants.TYPE_SHORT, "Add Short", KeyEvent.VK_2) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('2', Event.CTRL_MASK)); } public void actionPerformed(ActionEvent e) { addTag(new ShortTag("new short", (short) 0)); } }; addIntAction = new NBTAction("Add Integer", NBTConstants.TYPE_INT, "Add Integer", KeyEvent.VK_3) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('3', Event.CTRL_MASK)); } public void actionPerformed(ActionEvent e) { addTag(new IntTag("new int", 0)); } }; addLongAction = new NBTAction("Add Long", NBTConstants.TYPE_LONG, "Add Long", KeyEvent.VK_4) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('4', Event.CTRL_MASK)); } public void actionPerformed(ActionEvent e) { addTag(new LongTag("new long", 0)); } }; addFloatAction = new NBTAction("Add Float", NBTConstants.TYPE_FLOAT, "Add Float", KeyEvent.VK_5) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('5', Event.CTRL_MASK)); } public void actionPerformed(ActionEvent e) { addTag(new FloatTag("new float", 0)); } }; addDoubleAction = new NBTAction("Add Double", NBTConstants.TYPE_DOUBLE, "Add Double", KeyEvent.VK_6) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('6', Event.CTRL_MASK)); } public void actionPerformed(ActionEvent e) { addTag(new DoubleTag("new double", 0)); } }; addByteArrayAction = new NBTAction("Add Byte Array", NBTConstants.TYPE_BYTE_ARRAY, "Add Byte Array", KeyEvent.VK_7) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('7', Event.CTRL_MASK)); } public void actionPerformed(ActionEvent e) { addTag(new ByteArrayTag("new byte array")); } }; addStringAction = new NBTAction("Add String", NBTConstants.TYPE_STRING, "Add String", KeyEvent.VK_8) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('8', Event.CTRL_MASK)); } public void actionPerformed(ActionEvent e) { addTag(new StringTag("new string", "...")); } }; addListAction = new NBTAction("Add List Tag", NBTConstants.TYPE_LIST, "Add List Tag", KeyEvent.VK_9) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('9', Event.CTRL_MASK)); } public void actionPerformed(ActionEvent e) { Class<? extends Tag> type = queryType(); if (type != null) addTag(new ListTag("new list", null, type)); } private Class<? extends Tag> queryType() { Object[] items = { NBTConstants.TYPE_BYTE, NBTConstants.TYPE_SHORT, NBTConstants.TYPE_INT, NBTConstants.TYPE_LONG, NBTConstants.TYPE_FLOAT, NBTConstants.TYPE_DOUBLE, NBTConstants.TYPE_BYTE_ARRAY, NBTConstants.TYPE_STRING, NBTConstants.TYPE_LIST, NBTConstants.TYPE_COMPOUND }; JComboBox comboBox = new JComboBox(new DefaultComboBoxModel(items)); comboBox.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (value instanceof Integer) { Integer i = (Integer) value; Class<? extends Tag> c = NBTUtils.getTypeClass(i); String name = NBTUtils.getTypeName(c); setText(name); } return this; } }); Object[] message = { new JLabel("Please select a type."), comboBox }; String title = "Title goes here"; int result = JOptionPane.showOptionDialog(TreeFrame.this, message, title, JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); switch (result) { case JOptionPane.OK_OPTION: ComboBoxModel model = comboBox.getModel(); Object item = model.getSelectedItem(); if (item instanceof Integer) { Integer i = (Integer) item; return NBTUtils.getTypeClass(i); } } return null; } }; addCompoundAction = new NBTAction("Add Compound Tag", NBTConstants.TYPE_COMPOUND, "Add Compound Tag", KeyEvent.VK_0) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('0', Event.CTRL_MASK)); } public void actionPerformed(ActionEvent e) { addTag(new CompoundTag()); } }; String name = "About " + TITLE; helpAction = new NBTAction(name, "Help", name, KeyEvent.VK_F1) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke("F1")); } public void actionPerformed(ActionEvent e) { Object[] message = { new JLabel(TITLE + " " + VERSION), new JLabel("\u00A9 Copyright Taggart Spilman 2011. All rights reserved."), new Hyperlink("<html><a href=\"#\">NamedBinaryTag.com</a></html>", "http://www.namedbinarytag.com"), new Hyperlink("<html><a href=\"#\">Contact</a></html>", "mailto:tagadvance@gmail.com"), new JLabel(" "), new Hyperlink("<html><a href=\"#\">JNBT was written by Graham Edgecombe</a></html>", "http://jnbt.sf.net"), new Hyperlink("<html><a href=\"#\">Available open-source under the BSD license</a></html>", "http://jnbt.sourceforge.net/LICENSE.TXT"), new JLabel(" "), new JLabel("This product includes software developed by"), new Hyperlink("<html><a href=\"#\">The Apache Software Foundation</a>.</html>", "http://www.apache.org"), new JLabel(" "), new JLabel("Default texture pack:"), new Hyperlink("<html><a href=\"#\">SOLID COLOUR. SOLID STYLE.</a></html>", "http://www.minecraftforum.net/topic/72253-solid-colour-solid-style/"), new JLabel("Bundled with the permission of Trigger_Proximity."), }; String title = "About"; JOptionPane.showMessageDialog(TreeFrame.this, message, title, JOptionPane.INFORMATION_MESSAGE); } }; }
From source file:com.gele.tools.wow.wdbearmanager.WDBearManager.java
public void init(String[] args) { // copy ARGs//from w ww.j a v a 2 s . com this.parseCommandLine(args); // Usefull for debugging this.myLogger.debug("java.version: " + System.getProperty("java.version")); this.myLogger.debug("java.vendor: " + System.getProperty("java.vendor")); this.myLogger.debug("java.vendor.url: " + System.getProperty("java.vendor.url")); this.myLogger.debug("os.name: " + System.getProperty("os.name")); this.myLogger.debug("os.arch: " + System.getProperty("os.arch")); this.myLogger.debug("os.version: " + System.getProperty("os.version")); if (this.paramDBconfig.length() != 0) { this.WDB_DB_CONFIG_FILE = this.paramDBconfig; } WDBearManager_API myAPI = new WDBearManager_API(this.WDB_DB_CONFIG_FILE); // Create all tables // -> Needed for the updata script <- // -> Otherwise it may crash with an empty database try { myAPI.getCountOfTable("creaturecache"); myAPI.getCountOfTable("gameobjectcache"); myAPI.getCountOfTable("itemcache"); myAPI.getCountOfTable("itemnamecache"); myAPI.getCountOfTable("itemtextchaxhe"); myAPI.getCountOfTable("npccache"); myAPI.getCountOfTable("pagetextcache"); myAPI.getCountOfTable("questcache"); } catch (Exception ex) { // ignore ex.printStackTrace(); System.exit(0); } // Check, if database must be re-newed DBUpdater myDBU = new DBUpdater(); myDBU.checkForUpdate(myAPI); WDBearManager_I myWoWWDBearManager_API = myAPI; // // print out some statistics // if (this.useGUI == false) { boolean paramSpec = false; // ASSERT DTO_Interface myDTO = null; if (this.paramWdbfile.length() != 0) { paramSpec = true; // Open WDB try { this.items = myWoWWDBearManager_API.readWDBfile(this.paramWdbfile); } catch (Exception ex) { this.myLogger.error("Error reading the WDB file"); return; } // first dto -> to identify the data Iterator itWDBS = this.items.iterator(); if (itWDBS.hasNext()) { myDTO = (DTO_Interface) itWDBS.next(); } } // Create CSV? if (this.paramCSVFolder.length() != 0) { if (myDTO == null) { // NO WDB specified -> exit this.myLogger.error("Error: You did not specify -" + this.PARAM_WDBFILE + "\n"); usage(this.options); return; } File csvFile = new File(this.paramCSVFolder, myDTO.getTableName() + ".csv"); if (this.useVerbose) { this.myLogger.info("Creating CSV file: " + csvFile.getAbsolutePath()); } try { WriteCSV.writeCSV(new File(this.paramCSVFolder), this.items); this.myLogger.info("CSV file written: " + csvFile.getAbsolutePath()); } catch (Exception ex) { ex.printStackTrace(); this.myLogger.error("Error writing the CSV file"); return; } } // Create TXT? if (this.paramTXTFolder.length() != 0) { if (myDTO == null) { // NO WDB specified -> exit this.myLogger.error("Error: You did not specify -" + this.PARAM_WDBFILE + "\n"); usage(this.options); return; } if (this.useVerbose) { String table = myDTO.getTableName(); File txtFile = new File(this.paramTXTFolder, table + ".txt"); this.myLogger.info("Creating TXT file: " + txtFile.getAbsolutePath()); } try { WriteTXT.writeTXT(new File(this.paramTXTFolder), this.items); } catch (Exception ex) { //ex.printStackTrace(); this.myLogger.error("Error writing the TXT file: " + ex.getMessage()); return; } } // Store inside SQL database? if (this.writeSQL == true) { paramSpec = true; if (myDTO == null) { // NO WDB specified -> exit this.myLogger.error("Error: You did not specify -" + this.PARAM_WDBFILE + "\n"); usage(this.options); return; } if (this.useVerbose) { this.myLogger.info("Storing data inside SQL database"); } SQLManager myWriteSQL = null; try { myWriteSQL = new SQLManager(this.WDB_DB_CONFIG_FILE); ObjectsWritten myOWr = myWriteSQL.insertOrUpdateToSQLDB(this.items, this.doUpdate); this.myLogger.info("Operation successfull"); if (this.useVerbose) { this.myLogger.info("DB statistics"); this.myLogger.info("INSERT: " + myOWr.getNumInsert()); this.myLogger.info("UPDATE: " + myOWr.getNumUpdate()); this.myLogger.info("Error INSERT: " + myOWr.getNumErrorInsert()); this.myLogger.info("Error UPDATE: " + myOWr.getNumErrorUpdate()); if (this.doUpdate == false) { this.myLogger.info("Objects skipped: " + myOWr.getNumSkipped()); System.out.println("If you want to overwrite/update objects, use 'update' param"); } this.myLogger.info(WDBearManager.VERSION_INFO); } } catch (Exception ex) { ex.printStackTrace(); this.myLogger.error("Error importing to database"); this.myLogger.error(ex.getMessage()); return; } } // writeSQL // Patch *.SCP with contents of database if (this.paramSCPname.length() != 0) { if (this.paramPatchSCP.length() == 0) { this.myLogger.error("Error: You did not specify -" + WDBearManager.PATCH_SCP + "\n"); usage(this.options); return; } paramSpec = true; this.myLogger.info("Patch scp file with the contents of the database"); try { SCPWritten mySCPW = myWoWWDBearManager_API.patchSCP(this.paramSCPname, this.paramPatchSCP, this.patchUTF8, this.paramLocale); if (this.useVerbose) { this.myLogger.info("Merge statistics"); System.out.println("Entries in database: " + mySCPW.getNumInDB()); this.myLogger.info("Merged with SCP: " + mySCPW.getNumPatched()); this.myLogger.info("Patched IDs: " + mySCPW.getPatchedIDs()); } this.myLogger.info("Patched file: " + this.paramSCPname + "_patch"); } catch (WDBMgr_IOException ex) { this.myLogger.error("The destination SCP file could not be created"); this.myLogger.error(ex.getMessage()); return; } catch (WDBMgr_NoDataAvailableException ex) { this.myLogger.info("Merging impossible"); this.myLogger.info("There are no entries inside the database"); } catch (Exception ex) { this.myLogger.error("Error while merging quests.scp with database"); this.myLogger.error(ex.getMessage()); return; } } // PatchSCP // Call jython script? if (this.paramScript.length() != 0) { paramSpec = true; this.myLogger.info("Calling Jython script"); this.myLogger.info("---"); PythonInterpreter interp = new PythonInterpreter(); interp.set("wdbmgrapi", myWoWWDBearManager_API); // set parameters Set setKeys = this.paramJython.keySet(); Iterator itKeys = setKeys.iterator(); String jyParam = ""; while (itKeys.hasNext()) { jyParam = (String) itKeys.next(); interp.set(jyParam, (String) this.paramJython.get(jyParam)); } interp.execfile(this.paramScript); this.myLogger.info("---"); System.out.println("Jython script executed, " + WDBearManager.VERSION_INFO); return; } // paramScript if (paramSpec == false) { usage(this.options); return; } // Exit return; } // Command Line Version // // GUI // PlasticLookAndFeel.setMyCurrentTheme(new DesertBlue()); try { UIManager.put("ClassLoader", LookUtils.class.getClassLoader()); UIManager.setLookAndFeel(new Plastic3DLookAndFeel()); } catch (Exception e) { } // try { // com.incors.plaf.kunststoff.KunststoffLookAndFeel kunststoffLnF = new com.incors.plaf.kunststoff.KunststoffLookAndFeel(); // KunststoffLookAndFeel // .setCurrentTheme(new com.incors.plaf.kunststoff.KunststoffTheme()); // UIManager.setLookAndFeel(kunststoffLnF); // } catch (javax.swing.UnsupportedLookAndFeelException ex) { // // handle exception or not, whatever you prefer // } // this line needs to be implemented in order to make JWS work properly UIManager.getLookAndFeelDefaults().put("ClassLoader", getClass().getClassLoader()); this.setTitle(WDBearManager.VERSION_INFO); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.getContentPane().setLayout(new BorderLayout()); // construct GUI to display the stuff // Menu // Where the GUI is created: JMenuBar menuBar; JMenu menu; //, submenu; JMenuItem menuItem; //JRadioButtonMenuItem rbMenuItem; //JCheckBoxMenuItem cbMenuItem; // Create the menu bar. menuBar = new JMenuBar(); // Build the first menu. menu = new JMenu("File"); menu.setMnemonic(KeyEvent.VK_A); menu.getAccessibleContext().setAccessibleDescription("Process WDB files"); menuBar.add(menu); // Exit menuItem = new JMenuItem(MENU_EXIT, KeyEvent.VK_T); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, ActionEvent.ALT_MASK)); menuItem.getAccessibleContext().setAccessibleDescription("Exit program"); menuItem.addActionListener(this); menu.add(menuItem); // Build the first menu. menu = new JMenu("About"); menu.setMnemonic(KeyEvent.VK_A); menu.getAccessibleContext().setAccessibleDescription("Whassup?"); menuBar.add(menu); // Help menuItem = new JMenuItem(MENU_HELP, KeyEvent.VK_H); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_H, ActionEvent.ALT_MASK)); menuItem.getAccessibleContext().setAccessibleDescription("Help me..."); menuItem.addActionListener(this); menu.add(menuItem); // JavaDocs menuItem = new JMenuItem(MENU_JDOCS, KeyEvent.VK_J); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_J, ActionEvent.ALT_MASK)); menuItem.getAccessibleContext().setAccessibleDescription("Show API docs..."); menuItem.addActionListener(this); menu.add(menuItem); // separator menu.addSeparator(); // CheckForUpdate menuItem = new JMenuItem(MENU_CHECKUPDATE, KeyEvent.VK_U); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_U, ActionEvent.ALT_MASK)); menuItem.getAccessibleContext().setAccessibleDescription("Check for update..."); menuItem.addActionListener(this); menu.add(menuItem); // separator menu.addSeparator(); // ABOUT menuItem = new JMenuItem(MENU_ABOUT, KeyEvent.VK_T); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, ActionEvent.ALT_MASK)); menuItem.getAccessibleContext().setAccessibleDescription("Ueber..."); menuItem.addActionListener(this); menu.add(menuItem); this.setJMenuBar(menuBar); JPanel mainPanel = new JPanel(); mainPanel.setLayout(new GridLayout(0, 1)); JTabbedPane tabbedPane = new JTabbedPane(); ImageIcon wowIcon = createImageIcon("images/fromdisk.gif"); JComponent panel1 = new WDB_Panel(myWoWWDBearManager_API); tabbedPane.addTab("WDB-Module", wowIcon, panel1, "Handle WDB files"); tabbedPane.setMnemonicAt(0, KeyEvent.VK_1); ImageIcon panelIcon = createImageIcon("images/hsql.gif"); JComponent panel2 = null; try { panel2 = new SQL_Panel(myWoWWDBearManager_API); } catch (Throwable ex) { System.err.println("Error while instantiating SQL Panel: "); System.err.println(ex.getMessage()); ex.printStackTrace(); System.exit(0); } tabbedPane.addTab("DB-Module", panelIcon, panel2, "Handle database"); tabbedPane.setMnemonicAt(1, KeyEvent.VK_2); panelIcon = createImageIcon("images/pythonpoweredsmall.gif"); JComponent panel3 = new Python_Panel(myWoWWDBearManager_API); tabbedPane.addTab("Scripts", panelIcon, panel3, "Scripting"); tabbedPane.setMnemonicAt(2, KeyEvent.VK_3); // maybe user PLUGIN availabe // -> check for folders below "plugins" File filUserPanels = new File("plugins"); // 1) find user plugins (scan for directories) // 2) scan for <name>.properties, where <name> is the name of the directory // 3) load the properties file and get the plugin running String[] strUserPlugins = filUserPanels.list(new FilenameFilter() { public boolean accept(File dir, String name) { return (new File(dir, name).isDirectory()); } }); if (strUserPlugins != null) { ArrayList urlJars = new ArrayList(); //URL[] urlJars = new URL[strUserPlugins.length]; String strCurrJar = ""; String strPlugins[] = new String[strUserPlugins.length]; try { for (int i = 0; i < strUserPlugins.length; i++) { File baseFile = new File("plugins", strUserPlugins[i]); File filProperties = new File(baseFile, strUserPlugins[i] + ".properties"); if (filProperties.exists()) { // set plugin folder and .properties name strPlugins[i] = strUserPlugins[i]; this.myLogger.info("Found 'plugin' : " + baseFile.getAbsolutePath()); this.myLogger.info(" Trying to load .jar file"); // Scan for JAR files and include them //System.out.println(baseFile.getAbsolutePath()); String[] strJars = baseFile.list(new FilenameFilter() { public boolean accept(File dir, String name) { return name.endsWith(".jar"); } }); for (int j = 0; j < strJars.length; j++) { File filJAR = new File(baseFile, strJars[j]); strCurrJar = filJAR.getAbsolutePath(); this.myLogger.info("Loading external 'plugin' JAR: " + strCurrJar); URL jarfile = new URL("jar", "", "file:" + strCurrJar + "!/"); urlJars.add(jarfile); } } else { // print warning - a directory inside plugins, but there is no plugin this.myLogger.warn("Found directory inside plugins folder, but no .properties file"); this.myLogger.warn(" Name of directory: " + strUserPlugins[i]); this.myLogger.warn(" Please review the directory!"); } } // for... all user plugins } catch (Exception ex) { this.myLogger.error("Plugin: Error loading " + strCurrJar); this.myLogger.error("Please check your 'plugin' folder"); } URLClassLoader cl = null; try { // File file = new File("plugins", strUserJars[i]); // this.myLogger.info("Lade externes JAR: " + file.getAbsolutePath()); // URL jarfile = new URL("jar", "", "file:" + file.getAbsolutePath() + "!/"); URL[] loadURLs = new URL[urlJars.toArray().length]; for (int j = 0; j < urlJars.toArray().length; j++) { loadURLs[j] = (URL) urlJars.get(j); } cl = URLClassLoader.newInstance(loadURLs); Thread.currentThread().setContextClassLoader(cl); // String lcStr = "Test"; // Class loadedClass = cl.loadClass(lcStr); // this.myLogger.info("Smooth..."); } catch (Exception ex) { ex.printStackTrace(); } // 2) load properties and instantiate the plugin // String[] strPlugins = filUserPanels.list(new FilenameFilter() { // public boolean accept(File dir, String name) { // return (name.endsWith("_plugin.properties")); // } // }); String strPluginName = ""; String strPluginClass = ""; String strPluginImage = ""; WDBearPlugin pluginPanel = null; for (int i = 0; i < strPlugins.length; i++) { //this.myLogger.info(strPlugins[i]); Properties prpPlugin = null; try { prpPlugin = ReadPropertiesFile.readProperties( new File("plugins", strPlugins[i] + "/" + strPlugins[i]).getAbsolutePath() + ".properties"); } catch (Exception ex) { this.myLogger.error("Error with plugin: " + strPlugins[i]); this.myLogger.error("Could not load properties file"); continue; } if ((strPluginClass = prpPlugin.getProperty(this.PLUGIN_CLASS)) == null) { this.myLogger.error("Error with plugin: " + strPlugins[i]); this.myLogger.error("Property '" + this.PLUGIN_CLASS + "' not found"); continue; } if ((strPluginName = prpPlugin.getProperty(this.PLUGIN_NAME)) == null) { this.myLogger.error("Error with plugin: " + strPlugins[i]); this.myLogger.error("Property '" + this.PLUGIN_NAME + "' not found"); continue; } if ((strPluginImage = prpPlugin.getProperty(this.PLUGIN_IMAGE)) == null) { this.myLogger.error("Error with plugin: " + strPlugins[i]); this.myLogger.error("Property '" + this.PLUGIN_IMAGE + "' not found"); continue; } File filPlgImg = new File("plugins", strPlugins[i] + "/" + strPluginImage); panelIcon = createImageIcon(filPlgImg.getAbsolutePath()); if (panelIcon == null) { this.myLogger.error("Error with plugin: " + strPlugins[i]); this.myLogger.error("Could not read image '" + strPluginImage + "'"); continue; } try { pluginPanel = (WDBearPlugin) (cl.loadClass(strPluginClass).newInstance()); pluginPanel.runPlugin(myAPI); } catch (Exception ex) { this.myLogger.error("Error with plugin: " + strPlugins[i]); this.myLogger.error("Could not instantiate '" + strPluginClass + "'"); ex.printStackTrace(); continue; } tabbedPane.addTab(strPluginName, panelIcon, pluginPanel, strPluginName); } // Plugins } // plugins folder found mainPanel.add(tabbedPane); this.getContentPane().add(mainPanel, BorderLayout.CENTER); this.setSize(1024, 768); //this.pack(); this.show(); }
From source file:de.lazyzero.kkMulticopterFlashTool.KKMulticopterFlashTool.java
private void initGUI() { mainPanel = new JPanel(); // create the CellContraints CellConstraints cc = new CellConstraints(); // create the Layout for Panel this String panelColumns = "fill:pref:grow"; String panelRows = "3dlu,pref,3dlu,pref,3dlu,pref:grow"; FormLayout panelLayout = new FormLayout(panelColumns, panelRows); mainPanel.setLayout(panelLayout);// w ww. j a v a 2 s . c o m programmingPanel = ceateProgrammingPanel(); eepromPanel = createEEpromPanel(); tabbedPane.add(programmingPanel); programmerPanel = new ProgrammerPanel(this, programmers); controllerPanel = new ControllerPanel(this, avrs); mainPanel.add(programmerPanel, cc.xy(1, 2)); mainPanel.add(controllerPanel, cc.xy(1, 4)); mainPanel.add(tabbedPane, cc.xy(1, 6)); logger.log(Level.INFO, "Set the port from the properties [usb]: " + settings.getProperty("port", "usb")); programmerPanel.setPort(settings.getProperty("port", "usb")); programmerPanel.setRate(settings.getProperty("rate", "19200")); programmerPanel.setDefaultRate(new Boolean(settings.getProperty("defaultRate", "true"))); programmerPanel.setProgrammer(settings.getProperty("programmer", "usbasp")); controllerPanel.setController(settings.getProperty("controller", "Blackboard")); // testPanel = new TestPanel(); // tabbedPane.addTab(_("programmingPanel.title"), programmingPanel); tabbedPane.setBorder(new LineBorder(Color.WHITE)); tabbedPane.setMnemonicAt(0, KeyEvent.VK_1); tabbedPane.addTab(_("eepromPanel.title"), eepromPanel); tabbedPane.setMnemonicAt(1, KeyEvent.VK_2); tabbedPane.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent event) { JTabbedPane sourceTabbedPane = (JTabbedPane) event.getSource(); if (sourceTabbedPane.getSelectedComponent().equals(eepromPanel)) { logger.info("changed to eepromPanel"); eepromResetPanel.firePropertyChange(ControllerPanel.CONTROLLER_CHANGED, 0, 1); } else if (sourceTabbedPane.getSelectedComponent().equals(programmingPanel)) { logger.info("changed to programmingPanel"); } } }); mainframe = new JFrame(_("title") + " " + VERSION + (isBeta ? " beta " + betaVersion : "") + " - " + mode); // mainframe.setPreferredSize(preferredSize); // mainframe.setSize(preferredSize); // mainframe.add(tabbedPane); mainframe.add(mainPanel); mainframe.setJMenuBar((new kkMenu(this, firmwareReader)).getBar()); mainframe.setIconImage(Icons.getImage(Icons.app, 16)); mainframe.pack(); mainframe.setLocationRelativeTo(getRootPane()); mainframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); firmwarePanel.firePropertyChange(ControllerPanel.CONTROLLER_CHANGED, 0, 1); }