Search in sources :

Example 6 with JMenuBar

use of javax.swing.JMenuBar in project jdk8u_jdk by JetBrains.

the class DimensionEncapsulation method run.

@Override
public void run() {
    runTest(new Panel());
    runTest(new Button());
    runTest(new Checkbox());
    runTest(new Canvas());
    runTest(new Choice());
    runTest(new Label());
    runTest(new Scrollbar());
    runTest(new TextArea());
    runTest(new TextField());
    runTest(new Dialog(new JFrame()));
    runTest(new Frame());
    runTest(new Window(new JFrame()));
    runTest(new FileDialog(new JFrame()));
    runTest(new List());
    runTest(new ScrollPane());
    runTest(new JFrame());
    runTest(new JDialog(new JFrame()));
    runTest(new JWindow(new JFrame()));
    runTest(new JLabel("hi"));
    runTest(new JMenu());
    runTest(new JTree());
    runTest(new JTable());
    runTest(new JMenuItem());
    runTest(new JCheckBoxMenuItem());
    runTest(new JToggleButton());
    runTest(new JSpinner());
    runTest(new JSlider());
    runTest(Box.createVerticalBox());
    runTest(Box.createHorizontalBox());
    runTest(new JTextField());
    runTest(new JTextArea());
    runTest(new JTextPane());
    runTest(new JPasswordField());
    runTest(new JFormattedTextField());
    runTest(new JEditorPane());
    runTest(new JButton());
    runTest(new JColorChooser());
    runTest(new JFileChooser());
    runTest(new JCheckBox());
    runTest(new JInternalFrame());
    runTest(new JDesktopPane());
    runTest(new JTableHeader());
    runTest(new JLayeredPane());
    runTest(new JRootPane());
    runTest(new JMenuBar());
    runTest(new JOptionPane());
    runTest(new JRadioButton());
    runTest(new JRadioButtonMenuItem());
    runTest(new JPopupMenu());
    //runTest(new JScrollBar()); --> don't test defines max and min in
    // terms of preferred
    runTest(new JScrollPane());
    runTest(new JViewport());
    runTest(new JSplitPane());
    runTest(new JTabbedPane());
    runTest(new JToolBar());
    runTest(new JSeparator());
    runTest(new JProgressBar());
    if (!failures.isEmpty()) {
        System.out.println("These classes failed");
        for (final Component failure : failures) {
            System.out.println(failure.getClass());
        }
        throw new RuntimeException("Test failed");
    }
}
Also used : JDesktopPane(javax.swing.JDesktopPane) Choice(java.awt.Choice) JTextArea(javax.swing.JTextArea) TextArea(java.awt.TextArea) JTextArea(javax.swing.JTextArea) Label(java.awt.Label) JLabel(javax.swing.JLabel) JTableHeader(javax.swing.table.JTableHeader) JToggleButton(javax.swing.JToggleButton) JToggleButton(javax.swing.JToggleButton) Button(java.awt.Button) JRadioButton(javax.swing.JRadioButton) JButton(javax.swing.JButton) JFrame(javax.swing.JFrame) Checkbox(java.awt.Checkbox) JDialog(javax.swing.JDialog) FileDialog(java.awt.FileDialog) Dialog(java.awt.Dialog) JTextField(javax.swing.JTextField) TextField(java.awt.TextField) JFormattedTextField(javax.swing.JFormattedTextField) JSlider(javax.swing.JSlider) ArrayList(java.util.ArrayList) List(java.awt.List) Canvas(java.awt.Canvas) JWindow(javax.swing.JWindow) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) JOptionPane(javax.swing.JOptionPane) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) JCheckBox(javax.swing.JCheckBox) JTree(javax.swing.JTree) JFileChooser(javax.swing.JFileChooser) JPasswordField(javax.swing.JPasswordField) ScrollPane(java.awt.ScrollPane) JScrollPane(javax.swing.JScrollPane) JTable(javax.swing.JTable) JSpinner(javax.swing.JSpinner) JSplitPane(javax.swing.JSplitPane) JColorChooser(javax.swing.JColorChooser) JInternalFrame(javax.swing.JInternalFrame) JDialog(javax.swing.JDialog) JFrame(javax.swing.JFrame) Frame(java.awt.Frame) JInternalFrame(javax.swing.JInternalFrame) JRadioButton(javax.swing.JRadioButton) JLayeredPane(javax.swing.JLayeredPane) JTabbedPane(javax.swing.JTabbedPane) JButton(javax.swing.JButton) JProgressBar(javax.swing.JProgressBar) JTextField(javax.swing.JTextField) JSeparator(javax.swing.JSeparator) JTextPane(javax.swing.JTextPane) JMenuItem(javax.swing.JMenuItem) Component(java.awt.Component) Scrollbar(java.awt.Scrollbar) Window(java.awt.Window) JWindow(javax.swing.JWindow) JScrollPane(javax.swing.JScrollPane) JViewport(javax.swing.JViewport) JFormattedTextField(javax.swing.JFormattedTextField) JLabel(javax.swing.JLabel) JToolBar(javax.swing.JToolBar) JPopupMenu(javax.swing.JPopupMenu) Panel(java.awt.Panel) JEditorPane(javax.swing.JEditorPane) JRootPane(javax.swing.JRootPane) FileDialog(java.awt.FileDialog) JMenu(javax.swing.JMenu) JMenuBar(javax.swing.JMenuBar)

Example 7 with JMenuBar

use of javax.swing.JMenuBar in project DistributedFractalNetwork by Budder21.

the class Display method menus.

private JMenuBar menus() {
    ToolTipManager.sharedInstance().setInitialDelay(0);
    JMenuBar bar = new JMenuBar();
    JMenu view = new JMenu("View");
    JMenuItem serverLog = new JMenuItem("Server Log");
    serverLog.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            JFrame f = new JFrame("Server Log");
            JTextArea textArea = new JTextArea(35, 55);
            JScrollPane scroll = new JScrollPane(textArea);
            textArea.setText(log.getLog());
            scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
            scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
            f.setLayout(new BorderLayout());
            f.add(scroll, BorderLayout.CENTER);
            JButton b = new JButton("Save");
            b.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    JFileChooser fileChooser = new JFileChooser();
                    FileNameExtensionFilter filter = new FileNameExtensionFilter("TEXT FILES", "txt", "text");
                    fileChooser.setFileFilter(filter);
                    fileChooser.setCurrentDirectory(new File("fractals/logs"));
                    fileChooser.showSaveDialog(null);
                    String dir = fileChooser.getSelectedFile().getPath();
                    if (!dir.substring(dir.lastIndexOf(".") + 1).equals("txt"))
                        dir = dir.substring(0, dir.lastIndexOf(".")) + ".txt";
                    System.out.println("\n\n" + dir + "\n\n");
                    try {
                        PrintWriter out = new PrintWriter(dir);
                        Scanner s = new Scanner(textArea.getText());
                        while (s.hasNextLine()) out.println(s.nextLine());
                        out.flush();
                        out.close();
                    } catch (FileNotFoundException e1) {
                        log.addError(e1);
                    }
                }
            });
            JPanel tempPanel = new JPanel();
            tempPanel.add(b);
            f.add(tempPanel, BorderLayout.SOUTH);
            f.pack();
            f.setLocationRelativeTo(null);
            f.setResizable(true);
            f.setVisible(true);
        }
    });
    serverLog.setToolTipText("Displays the log of the current server.");
    view.add(serverLog);
    bar.add(view);
    return bar;
}
Also used : JScrollPane(javax.swing.JScrollPane) Scanner(java.util.Scanner) JPanel(javax.swing.JPanel) JTextArea(javax.swing.JTextArea) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) FileNotFoundException(java.io.FileNotFoundException) FileNameExtensionFilter(javax.swing.filechooser.FileNameExtensionFilter) ActionListener(java.awt.event.ActionListener) BorderLayout(java.awt.BorderLayout) JFileChooser(javax.swing.JFileChooser) JFrame(javax.swing.JFrame) JMenuItem(javax.swing.JMenuItem) File(java.io.File) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu) PrintWriter(java.io.PrintWriter)

Example 8 with JMenuBar

use of javax.swing.JMenuBar in project ChatGameFontificator by GlitchCog.

the class ControlWindow method initMenus.

/**
     * Builds the menus from the static arrays
     */
private void initMenus() {
    JMenuBar menuBar = new JMenuBar();
    final String[] mainMenuText = { "File", "Presets", "View", "Message", "Help" };
    final int[] mainMnomonics = { KeyEvent.VK_F, KeyEvent.VK_P, KeyEvent.VK_V, KeyEvent.VK_M, KeyEvent.VK_H };
    JMenu[] menus = new JMenu[mainMenuText.length];
    for (int i = 0; i < mainMenuText.length; i++) {
        menus[i] = new JMenu(mainMenuText[i]);
        menus[i].setMnemonic(mainMnomonics[i]);
    }
    /* File Menu Item Text */
    final String strFileOpen = "Open Configuration";
    final String strFileSave = "Save Configuration";
    final String strFileRestore = "Restore Default Configuration";
    final String strScreenshot = "Screenshot";
    final String strFileExit = "Exit";
    // @formatter:off
    final MenuComponent[] fileComponents = new MenuComponent[] { new MenuComponent(strFileOpen, KeyEvent.VK_O, KeyStroke.getKeyStroke(KeyEvent.VK_O, Event.CTRL_MASK)), new MenuComponent(strFileSave, KeyEvent.VK_S, KeyStroke.getKeyStroke(KeyEvent.VK_S, Event.CTRL_MASK)), new MenuComponent(strFileRestore, KeyEvent.VK_R, null), new MenuComponent(strScreenshot, KeyEvent.VK_C, KeyStroke.getKeyStroke(KeyEvent.VK_F8, 0)), new MenuComponent(strFileExit, KeyEvent.VK_X, KeyStroke.getKeyStroke(KeyEvent.VK_Q, Event.CTRL_MASK)) };
    // @formatter:on
    /* View Menu Item Text */
    final String strAntiAlias = "Anti-Aliased";
    final String strViewTop = "Always On Top";
    final String strRememberPos = "Remember Chat Window Position";
    final String strViewHide = "Hide Control Window";
    final MenuComponent[] viewComponents = new MenuComponent[] { new MenuComponent(strAntiAlias, KeyEvent.VK_A, null, true), null, new MenuComponent(strViewTop, KeyEvent.VK_T, null, true), new MenuComponent(strRememberPos, KeyEvent.VK_P, null, true), new MenuComponent(strViewHide, KeyEvent.VK_H, KeyStroke.getKeyStroke(KeyEvent.VK_H, Event.CTRL_MASK)) };
    /* Message Menu Item Text */
    final String strMsgMsg = "Message Management";
    final MenuComponent[] messageComponents = new MenuComponent[] { new MenuComponent(strMsgMsg, KeyEvent.VK_M, KeyStroke.getKeyStroke(KeyEvent.VK_M, Event.CTRL_MASK)) };
    /* Help Menu Item Text */
    final String strHelpHelp = "Help";
    final String strHelpDebug = "Debug Mode";
    final String strHelpAbout = "About";
    final MenuComponent[] helpComponents = new MenuComponent[] { new MenuComponent(strHelpHelp, KeyEvent.VK_R, null), new MenuComponent(strHelpDebug, KeyEvent.VK_D, null, true), null, new MenuComponent(strHelpAbout, KeyEvent.VK_A, null) };
    /* All menu components, with a placeholder for the Presets menu */
    final MenuComponent[][] allMenuComponents = new MenuComponent[][] { fileComponents, new MenuComponent[] {}, viewComponents, messageComponents, helpComponents };
    ActionListener mal = new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            JMenuItem mi = (JMenuItem) e.getSource();
            if (strFileOpen.equals(mi.getText())) {
                open();
            } else if (strFileSave.equals(mi.getText())) {
                saveConfig();
            } else if (strFileRestore.equals(mi.getText())) {
                restoreDefaults(true);
                controlTabs.refreshUiFromConfig(fProps);
            } else if (strScreenshot.equals(mi.getText())) {
                saveScreenshot();
            } else if (strFileExit.equals(mi.getText())) {
                attemptToExit();
            } else if (strAntiAlias.equals(mi.getText())) {
                JCheckBoxMenuItem checkBox = (JCheckBoxMenuItem) e.getSource();
                controlTabs.setAntiAlias(checkBox.isSelected());
                chatWindow.getChatPanel().repaint();
            } else if (strViewTop.equals(mi.getText())) {
                JCheckBoxMenuItem checkBox = (JCheckBoxMenuItem) e.getSource();
                ((JFrame) getParent()).setAlwaysOnTop(checkBox.isSelected());
                controlTabs.setAlwaysOnTopConfig(checkBox.isSelected());
            } else if (strRememberPos.equals(mi.getText())) {
                JCheckBoxMenuItem checkBox = (JCheckBoxMenuItem) e.getSource();
                controlTabs.setRememberChatWindowPosition(checkBox.isSelected());
                if (checkBox.isSelected()) {
                    final int sx = (int) chatWindow.getLocationOnScreen().getX();
                    final int sy = (int) chatWindow.getLocationOnScreen().getY();
                    fProps.getChatConfig().setChatWindowPositionX(sx);
                    fProps.getChatConfig().setChatWindowPositionY(sy);
                }
            } else if (strViewHide.equals(mi.getText())) {
                setVisible(false);
            } else if (strMsgMsg.equals(mi.getText())) {
                messageDialog.showDialog();
            } else if (strHelpHelp.equals(mi.getText())) {
                help.setVisible(true);
            } else if (strHelpDebug.equals(mi.getText())) {
                toggleDebugTab();
            } else if (strHelpAbout.equals(mi.getText())) {
                showAboutPane();
            }
        }
    };
    /* Set all menu items but presets */
    JMenuItem item = null;
    for (int i = 0; i < allMenuComponents.length; i++) {
        for (int j = 0; j < allMenuComponents[i].length; j++) {
            MenuComponent mc = allMenuComponents[i][j];
            if (mc == null) {
                menus[i].add(new JSeparator());
            } else {
                item = mc.checkbox ? new JCheckBoxMenuItem(mc.label) : new JMenuItem(mc.label);
                item.addActionListener(mal);
                item.setMnemonic(mc.mnemonic);
                if (mc.accelerator != null) {
                    item.setAccelerator(mc.accelerator);
                }
                menus[i].add(item);
            }
        }
        menuBar.add(menus[i]);
    }
    /* Presets Breath of Fire */
    final String[] strBof1 = new String[] { "Breath of Fire", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "bof1.cgf" };
    final String[] strBof2 = new String[] { "Breath of Fire 2", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "bof2.cgf" };
    /* Presets Chrono */
    final String[] strChrono = new String[] { "Chrono Trigger", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "ct.cgf" };
    final String[] strChronoCross = new String[] { "Chrono Cross", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "cc.cgf" };
    /* Presets Dragon Warrior */
    final String[] strDw1 = new String[] { "Dragon Warrior", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "dw1.cgf" };
    final String[] strDw2 = new String[] { "Dragon Warrior II", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "dw2.cgf" };
    final String[] strDq1_2 = new String[] { "Dragon Quest I.II (SFC)", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "dq1_2_sfc.cgf" };
    final String[] strDw3 = new String[] { "Dragon Warrior III", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "dw3.cgf" };
    final String[] strDw3Gbc = new String[] { "Dragon Warrior III (GBC)", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "dw3gbc.cgf" };
    final String[] strDq3 = new String[] { "Dragon Quest III (SFC)", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "dq3_sfc.cgf" };
    final String[] strDw4 = new String[] { "Dragon Warrior IV", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "dw4.cgf" };
    final String[] strDqhrs = new String[] { "Dragon Quest Heroes: Rocket Slime", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "dqhrs.cgf" };
    /* Presets EarthBound */
    final String[] strEb0 = new String[] { "Earthbound Zero", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "eb0.cgf" };
    final String[] strEbPlain = new String[] { "Earthbound Plain", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "eb_plain.cgf" };
    final String[] strEbMint = new String[] { "Earthbound Mint", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "eb_mint.cgf" };
    final String[] strEbStrawberry = new String[] { "Earthbound Strawberry", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "eb_strawberry.cgf" };
    final String[] strEbBanana = new String[] { "Earthbound Banana", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "eb_banana.cgf" };
    final String[] strEbPeanut = new String[] { "Earthbound Peanut", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "eb_peanut.cgf" };
    final String[] strEbSaturn = new String[] { "Earthbound Mr. Saturn", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "eb_saturn.cgf" };
    final String[] strM3 = new String[] { "Mother 3", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "m3.cgf" };
    /* Presets Final Fantasy */
    final String[] strFinalFantasy1 = new String[] { "Final Fantasy", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "ff1.cgf" };
    final String[] strFinalFantasy4 = new String[] { "Final Fantasy IV", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "ff4.cgf" };
    final String[] strFinalFantasy6 = new String[] { "Final Fantasy VI", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "ff6.cgf" };
    final String[] strFinalFantasy7 = new String[] { "Final Fantasy VII", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "ff7.cgf" };
    final String[] strFinalFantasy9 = new String[] { "Final Fantasy IX", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "ff9.cgf" };
    /* Presets Mario */
    final String[] strMario1 = new String[] { "Super Mario Bros.", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "smb1.cgf" };
    final String[] strMario1Underworld = new String[] { "Super Mario Bros. Underworld", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "smb1_underworld.cgf" };
    final String[] strMario2 = new String[] { "Super Mario Bros. 2", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "smb2.cgf" };
    final String[] strMario3hud = new String[] { "Super Mario Bros. 3 HUD", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "smb3_hud.cgf" };
    final String[] strMario3letter = new String[] { "Super Mario Bros. 3 Letter", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "smb3_letter.cgf" };
    final String[] strMarioWorld = new String[] { "Super Mario World", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "smw.cgf" };
    final String[] strYoshisIsland = new String[] { "Super Mario World 2: Yoshi's Island", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "yi.cgf" };
    final String[] strMarioRpg = new String[] { "Super Mario RPG", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "smrpg.cgf" };
    /* Presets Metroid */
    final String[] strMetroid = new String[] { "Metroid", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "metroid.cgf" };
    final String[] strMetroidBoss = new String[] { "Metroid Mother Brain", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "metroidboss.cgf" };
    final String[] strMetroid2 = new String[] { "Metroid II", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "metroid2.cgf" };
    final String[] strSuperMetroid = new String[] { "Super Metroid", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "smetroid.cgf" };
    final String[] strMetroidFusion = new String[] { "Metroid Fusion", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "metroid_fusion.cgf" };
    final String[] strMetroidZero = new String[] { "Metroid Zero Mission", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "metroid_zm.cgf" };
    /* Presets Phantasy Star */
    final String[] strPhanStar1 = new String[] { "Phantasy Star", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "ps1.cgf" };
    final String[] strPhanStar2 = new String[] { "Phantasy Star II", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "ps2.cgf" };
    /* Presets Pokemon */
    final String[] strPkmnRb = new String[] { "Pokemon Red/Blue", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "pkmnrb.cgf" };
    final String[] strPkmnFrlg = new String[] { "Pokemon Fire Red/Leaf Green", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "pkmnfrlg.cgf" };
    /* Presets Ys */
    final String[] strYs1fc = new String[] { "Ys (FC)", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "ys1_fc.cgf" };
    final String[] strYs3fc = new String[] { "Ys III (FC)", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "ys3_fc.cgf" };
    final String[] strYs3snes = new String[] { "Ys III (SNES)", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "ys3_snes.cgf" };
    /* Presets Zelda */
    final String[] strLozBush = new String[] { "The Legend of Zelda Bushes", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "zelda1_bush.cgf" };
    final String[] strLozRock = new String[] { "The Legend of Zelda Moutains", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "zelda1_rock.cgf" };
    final String[] strLozDungeon = new String[] { "The Legend of Zelda Dungeon", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "zelda1_dungeon.cgf" };
    final String[] strZelda2 = new String[] { "Zelda II: The Adventures of Link", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "zelda2.cgf" };
    final String[] strLozLa = new String[] { "The Legend of Zelda: Link's Awakening", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "zelda_la.cgf" };
    final String[] strZelda3 = new String[] { "The Legend of Zelda: A Link to the Past", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "zelda3.cgf" };
    final String[] strZeldaWw = new String[] { "The Legend of Zelda: The Wind Waker", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "zelda_ww.cgf" };
    final String[] strZeldaMinish = new String[] { "The Legend of Zelda: The Minish Cap", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "zelda_minish.cgf" };
    /* Ungrouped Presets */
    final String[] strClash = new String[] { "Clash at Demonhead", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "cad.cgf" };
    final String[] strCrystalis = new String[] { "Crystalis", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "crystalis.cgf" };
    final String[] strFreedomPlanet = new String[] { "Freedom Planet", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "freep.cgf" };
    final String[] strGoldenSun = new String[] { "Golden Sun", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "gsun.cgf" };
    final String[] strHarvestMoonFmt = new String[] { "Harvest Moon: Friends of Mineral Town", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "hm_fmt.cgf" };
    final String[] strRiverCityRansom = new String[] { "River City Ransom", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "rcr.cgf" };
    final String[] strRygarNes = new String[] { "Rygar (NES)", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "rygar_nes.cgf" };
    final String[] strSecretOfEvermore = new String[] { "Secret of Evermore", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "soe.cgf" };
    final String[] strShantae = new String[] { "Shantae", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "shantae.cgf" };
    final String[] strShiningForce = new String[] { "Shining Force", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "shiningforce.cgf" };
    final String[] strShovel = new String[] { "Shovel Knight", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "sk.cgf" };
    final String[] strStardew = new String[] { "Stardew Valley", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "sdv.cgf" };
    final String[] strSuikoden = new String[] { "Suikoden", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "suiko.cgf" };
    final String[] strTalesOfSymphonia = new String[] { "Tales of Symphonia", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "tos.cgf" };
    final String[] strWarioLand4 = new String[] { "Wario Land 4", ConfigFont.INTERNAL_FILE_PREFIX + PRESET_DIRECTORY + "wl4.cgf" };
    // @formatter:off
    final String[][] allPresets = new String[][] { strBof1, strBof2, strChrono, strChronoCross, strDw1, strDw2, strDq1_2, strDw3, strDw3Gbc, strDq3, strDw4, strDqhrs, strEb0, strEbPlain, strEbMint, strEbStrawberry, strEbBanana, strEbPeanut, strEbSaturn, strM3, strFinalFantasy1, strFinalFantasy4, strFinalFantasy6, strFinalFantasy7, strFinalFantasy9, strMario1, strMario1Underworld, strMario2, strMario3hud, strMario3letter, strMarioWorld, strYoshisIsland, strMarioRpg, strMetroid, strMetroidBoss, strMetroid2, strSuperMetroid, strMetroidFusion, strMetroidZero, strPhanStar1, strPhanStar2, strPkmnRb, strPkmnFrlg, strYs1fc, strYs3fc, strYs3snes, strLozBush, strLozRock, strLozDungeon, strZelda2, strLozLa, strZelda3, strZeldaWw, strZeldaMinish, strClash, strCrystalis, strFreedomPlanet, strGoldenSun, strHarvestMoonFmt, strRiverCityRansom, strRygarNes, strSecretOfEvermore, strShantae, strShiningForce, strShovel, strStardew, strSuikoden, strTalesOfSymphonia, strWarioLand4 };
    // @formatter:on
    ActionListener presetListener = new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            String sourceText = ((JMenuItem) e.getSource()).getText();
            for (int i = 0; i < allPresets.length; i++) {
                if (allPresets[i][0].equals(sourceText)) {
                    loadPreset(allPresets[i][0], allPresets[i][1]);
                    break;
                }
            }
        }
    };
    // Put all the presets into this map to convert them into the submenu items
    final Map<String, String[]> presetMapSubmenuToItem = new LinkedHashMap<String, String[]>();
    presetMapSubmenuToItem.put("Breath of Fire", new String[] { strBof1[0], strBof2[0] });
    presetMapSubmenuToItem.put("Chrono", new String[] { strChrono[0], strChronoCross[0] });
    presetMapSubmenuToItem.put("Dragon Warrior", new String[] { strDw1[0], strDw2[0], strDq1_2[0], strDw3[0], strDw3Gbc[0], strDq3[0], strDw4[0], strDqhrs[0] });
    presetMapSubmenuToItem.put("Earthbound", new String[] { strEb0[0], strEbPlain[0], strEbMint[0], strEbStrawberry[0], strEbBanana[0], strEbPeanut[0], strEbSaturn[0], strM3[0] });
    presetMapSubmenuToItem.put("Final Fantasy", new String[] { strFinalFantasy1[0], strFinalFantasy4[0], strFinalFantasy6[0], strFinalFantasy7[0], strFinalFantasy9[0] });
    presetMapSubmenuToItem.put("Mario", new String[] { strMario1[0], strMario1Underworld[0], strMario2[0], strMario3hud[0], strMario3letter[0], strMarioWorld[0], strYoshisIsland[0], strMarioRpg[0] });
    presetMapSubmenuToItem.put("Metroid", new String[] { strMetroid[0], strMetroidBoss[0], strMetroid2[0], strSuperMetroid[0], strMetroidFusion[0], strMetroidZero[0] });
    presetMapSubmenuToItem.put("Phantasy Star", new String[] { strPhanStar1[0], strPhanStar2[0] });
    presetMapSubmenuToItem.put("Pokemon", new String[] { strPkmnRb[0], strPkmnFrlg[0] });
    presetMapSubmenuToItem.put("Ys", new String[] { strYs1fc[0], strYs3fc[0], strYs3snes[0] });
    presetMapSubmenuToItem.put("Zelda", new String[] { strLozBush[0], strLozRock[0], strLozDungeon[0], strZelda2[0], strLozLa[0], strZelda3[0], strZeldaWw[0], strZeldaMinish[0] });
    presetMapSubmenuToItem.put(null, new String[] { strClash[0], strCrystalis[0], strFreedomPlanet[0], strGoldenSun[0], strHarvestMoonFmt[0], strRiverCityRansom[0], strRygarNes[0], strSecretOfEvermore[0], strShantae[0], strShiningForce[0], strShovel[0], strStardew[0], strSuikoden[0], strTalesOfSymphonia[0], strWarioLand4[0] });
    for (String submenuKey : presetMapSubmenuToItem.keySet()) {
        String[] submenuItems = presetMapSubmenuToItem.get(submenuKey);
        if (submenuKey != null) {
            JMenu submenu = new JMenu(submenuKey);
            for (String itemStr : submenuItems) {
                JMenuItem submenuItem = new JMenuItem(itemStr);
                submenuItem.addActionListener(presetListener);
                submenu.add(submenuItem);
            }
            menus[1].add(submenu);
        } else {
            for (String submenuRootItemStr : submenuItems) {
                JMenuItem submenuRootItem = new JMenuItem(submenuRootItemStr);
                submenuRootItem.addActionListener(presetListener);
                menus[1].add(submenuRootItem);
            }
        }
    }
    for (int i = 0; i < menus.length; i++) {
        menuBar.add(menus[i]);
    }
    // add the whole menu bar
    setJMenuBar(menuBar);
}
Also used : ActionEvent(java.awt.event.ActionEvent) MenuComponent(com.glitchcog.fontificator.gui.component.MenuComponent) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) JSeparator(javax.swing.JSeparator) LinkedHashMap(java.util.LinkedHashMap) ActionListener(java.awt.event.ActionListener) JFrame(javax.swing.JFrame) JMenuItem(javax.swing.JMenuItem) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Example 9 with JMenuBar

use of javax.swing.JMenuBar in project joda-time by JodaOrg.

the class DateTimeBrowser method go.

// usage
/*
     * go This method reads the file, creates the table to display,
     * the window to display it in, and displays the window.
     * @param fileName the name of the file to read.
     * @param tryLines An estimate of the number of lines in
     * the file.
     */
private void go(String[] args) {
    mainArgs = args;
    // let user override if needed
    setDefaultTimeZone();
    // setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    //
    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);
    addMenus(menuBar);
    /*
         * Add a fast close listener
         */
    addWindowListener(new WindowAdapter() {

        public void windowClosing(WindowEvent e) {
            setVisible(false);
            dispose();
            System.exit(0);
        }
    });
    //
    // Load current file, prime tables and JFrame.
    //
    currFile = new LoadedFile(mainArgs[0]);
    TableView tView = getDefaultTableView();
    resetDefaults(tView);
    //
    // Set max size at start, and display the window.
    //
    Dimension screenMax = Toolkit.getDefaultToolkit().getScreenSize();
    setSize(screenMax);
    setVisible(true);
}
Also used : WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter) Dimension(java.awt.Dimension) JMenuBar(javax.swing.JMenuBar)

Example 10 with JMenuBar

use of javax.swing.JMenuBar in project jadx by skylot.

the class MainWindow method initMenuAndToolbar.

private void initMenuAndToolbar() {
    Action openAction = new AbstractAction(NLS.str("file.open"), ICON_OPEN) {

        @Override
        public void actionPerformed(ActionEvent e) {
            openFile();
        }
    };
    openAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("file.open"));
    openAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_O, KeyEvent.CTRL_DOWN_MASK));
    Action saveAllAction = new AbstractAction(NLS.str("file.save_all"), ICON_SAVE_ALL) {

        @Override
        public void actionPerformed(ActionEvent e) {
            saveAll(false);
        }
    };
    saveAllAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("file.save_all"));
    saveAllAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_DOWN_MASK));
    Action exportAction = new AbstractAction(NLS.str("file.export_gradle"), ICON_EXPORT) {

        @Override
        public void actionPerformed(ActionEvent e) {
            saveAll(true);
        }
    };
    exportAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("file.export_gradle"));
    exportAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_E, KeyEvent.CTRL_DOWN_MASK));
    JMenu recentFiles = new JMenu(NLS.str("menu.recent_files"));
    recentFiles.addMenuListener(new RecentFilesMenuListener(recentFiles));
    Action prefsAction = new AbstractAction(NLS.str("menu.preferences"), ICON_PREF) {

        @Override
        public void actionPerformed(ActionEvent e) {
            new JadxSettingsWindow(MainWindow.this, settings).setVisible(true);
        }
    };
    prefsAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("menu.preferences"));
    prefsAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_P, KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK));
    Action exitAction = new AbstractAction(NLS.str("file.exit"), ICON_CLOSE) {

        @Override
        public void actionPerformed(ActionEvent e) {
            dispose();
        }
    };
    isFlattenPackage = settings.isFlattenPackage();
    flatPkgMenuItem = new JCheckBoxMenuItem(NLS.str("menu.flatten"), ICON_FLAT_PKG);
    flatPkgMenuItem.setState(isFlattenPackage);
    Action syncAction = new AbstractAction(NLS.str("menu.sync"), ICON_SYNC) {

        @Override
        public void actionPerformed(ActionEvent e) {
            syncWithEditor();
        }
    };
    syncAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("menu.sync"));
    syncAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_T, KeyEvent.CTRL_DOWN_MASK));
    Action textSearchAction = new AbstractAction(NLS.str("menu.text_search"), ICON_SEARCH) {

        @Override
        public void actionPerformed(ActionEvent e) {
            new SearchDialog(MainWindow.this, EnumSet.of(SearchOptions.CODE)).setVisible(true);
        }
    };
    textSearchAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("menu.text_search"));
    textSearchAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_F, KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK));
    Action clsSearchAction = new AbstractAction(NLS.str("menu.class_search"), ICON_FIND) {

        @Override
        public void actionPerformed(ActionEvent e) {
            new SearchDialog(MainWindow.this, EnumSet.of(SearchOptions.CLASS)).setVisible(true);
        }
    };
    clsSearchAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("menu.class_search"));
    clsSearchAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_DOWN_MASK));
    Action deobfAction = new AbstractAction(NLS.str("preferences.deobfuscation"), ICON_DEOBF) {

        @Override
        public void actionPerformed(ActionEvent e) {
            toggleDeobfuscation();
        }
    };
    deobfAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("preferences.deobfuscation"));
    deobfAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_D, KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK));
    deobfToggleBtn = new JToggleButton(deobfAction);
    deobfToggleBtn.setSelected(settings.isDeobfuscationOn());
    deobfToggleBtn.setText("");
    deobfMenuItem = new JCheckBoxMenuItem(deobfAction);
    deobfMenuItem.setState(settings.isDeobfuscationOn());
    Action logAction = new AbstractAction(NLS.str("menu.log"), ICON_LOG) {

        @Override
        public void actionPerformed(ActionEvent e) {
            new LogViewer(settings).setVisible(true);
        }
    };
    logAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("menu.log"));
    logAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_L, KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK));
    Action aboutAction = new AbstractAction(NLS.str("menu.about")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            new AboutDialog().setVisible(true);
        }
    };
    Action backAction = new AbstractAction(NLS.str("nav.back"), ICON_BACK) {

        @Override
        public void actionPerformed(ActionEvent e) {
            tabbedPane.navBack();
        }
    };
    backAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("nav.back"));
    backAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_LEFT, KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK));
    Action forwardAction = new AbstractAction(NLS.str("nav.forward"), ICON_FORWARD) {

        @Override
        public void actionPerformed(ActionEvent e) {
            tabbedPane.navForward();
        }
    };
    forwardAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("nav.forward"));
    forwardAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_RIGHT, KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK));
    JMenu file = new JMenu(NLS.str("menu.file"));
    file.setMnemonic(KeyEvent.VK_F);
    file.add(openAction);
    file.add(saveAllAction);
    file.add(exportAction);
    file.addSeparator();
    file.add(recentFiles);
    file.addSeparator();
    file.add(prefsAction);
    file.addSeparator();
    file.add(exitAction);
    JMenu view = new JMenu(NLS.str("menu.view"));
    view.setMnemonic(KeyEvent.VK_V);
    view.add(flatPkgMenuItem);
    view.add(syncAction);
    JMenu nav = new JMenu(NLS.str("menu.navigation"));
    nav.setMnemonic(KeyEvent.VK_N);
    nav.add(textSearchAction);
    nav.add(clsSearchAction);
    nav.addSeparator();
    nav.add(backAction);
    nav.add(forwardAction);
    JMenu tools = new JMenu(NLS.str("menu.tools"));
    tools.setMnemonic(KeyEvent.VK_T);
    tools.add(deobfMenuItem);
    tools.add(logAction);
    JMenu help = new JMenu(NLS.str("menu.help"));
    help.setMnemonic(KeyEvent.VK_H);
    help.add(aboutAction);
    JMenuBar menuBar = new JMenuBar();
    menuBar.add(file);
    menuBar.add(view);
    menuBar.add(nav);
    menuBar.add(tools);
    menuBar.add(help);
    setJMenuBar(menuBar);
    flatPkgButton = new JToggleButton(ICON_FLAT_PKG);
    flatPkgButton.setSelected(isFlattenPackage);
    ActionListener flatPkgAction = new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            toggleFlattenPackage();
        }
    };
    flatPkgMenuItem.addActionListener(flatPkgAction);
    flatPkgButton.addActionListener(flatPkgAction);
    flatPkgButton.setToolTipText(NLS.str("menu.flatten"));
    updateLink = new Link("", JadxUpdate.JADX_RELEASES_URL);
    updateLink.setVisible(false);
    JToolBar toolbar = new JToolBar();
    toolbar.setFloatable(false);
    toolbar.add(openAction);
    toolbar.add(saveAllAction);
    toolbar.add(exportAction);
    toolbar.addSeparator();
    toolbar.add(syncAction);
    toolbar.add(flatPkgButton);
    toolbar.addSeparator();
    toolbar.add(textSearchAction);
    toolbar.add(clsSearchAction);
    toolbar.addSeparator();
    toolbar.add(backAction);
    toolbar.add(forwardAction);
    toolbar.addSeparator();
    toolbar.add(deobfToggleBtn);
    toolbar.addSeparator();
    toolbar.add(logAction);
    toolbar.addSeparator();
    toolbar.add(prefsAction);
    toolbar.addSeparator();
    toolbar.add(Box.createHorizontalGlue());
    toolbar.add(updateLink);
    mainPanel.add(toolbar, BorderLayout.NORTH);
}
Also used : AbstractAction(javax.swing.AbstractAction) Action(javax.swing.Action) ActionEvent(java.awt.event.ActionEvent) JadxSettingsWindow(jadx.gui.settings.JadxSettingsWindow) JToolBar(javax.swing.JToolBar) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) JToggleButton(javax.swing.JToggleButton) ActionListener(java.awt.event.ActionListener) AbstractAction(javax.swing.AbstractAction) JMenu(javax.swing.JMenu) JMenuBar(javax.swing.JMenuBar) Link(jadx.gui.utils.Link)

Aggregations

JMenuBar (javax.swing.JMenuBar)119 JMenu (javax.swing.JMenu)83 JMenuItem (javax.swing.JMenuItem)45 ActionEvent (java.awt.event.ActionEvent)36 ActionListener (java.awt.event.ActionListener)30 JPanel (javax.swing.JPanel)28 BoxLayout (javax.swing.BoxLayout)25 Dimension (java.awt.Dimension)23 JFrame (javax.swing.JFrame)17 JScrollPane (javax.swing.JScrollPane)15 JLabel (javax.swing.JLabel)14 JButton (javax.swing.JButton)13 JmriJFrame (jmri.util.JmriJFrame)12 GridBagLayout (java.awt.GridBagLayout)11 BorderLayout (java.awt.BorderLayout)10 JSeparator (javax.swing.JSeparator)10 AbstractAction (javax.swing.AbstractAction)9 FlowLayout (java.awt.FlowLayout)6 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)6 JPopupMenu (javax.swing.JPopupMenu)6