Search in sources :

Example 21 with JSeparator

use of javax.swing.JSeparator 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 22 with JSeparator

use of javax.swing.JSeparator in project adempiere by adempiere.

the class VPanel method addGroup.

//	addField
/**
	 *	Add Group
	 *  @param fieldGroup field group
	 *  @param fieldGroupType 
	 *  @return true if group added
	 */
private boolean addGroup(String fieldGroup, String fieldGroupType) {
    //	First time - add top
    if (m_oldFieldGroup == null) {
        m_oldFieldGroup = "";
        m_oldFieldGroupType = "";
    }
    if (fieldGroup == null || fieldGroup.length() == 0 || fieldGroup.equals(m_oldFieldGroup))
        return false;
    //[ 1757088 ]
    if (m_tablist.get(fieldGroup) != null) {
        return false;
    }
    //[ 1757088 ]
    if (fieldGroupType.equals(X_AD_FieldGroup.FIELDGROUPTYPE_Tab)) {
        CPanel m_tab = new CPanel();
        m_tab.setBackground(AdempierePLAF.getFormBackground());
        String tpConstraints = defaultLayoutConstraints;
        MigLayout layout = new MigLayout(tpConstraints);
        layout.addLayoutCallback(callback);
        m_tab.setLayout(layout);
        m_tab.setName(fieldGroup);
        CPanel dummy = new CPanel();
        dummy.setLayout(new BorderLayout());
        dummy.add(m_tab, BorderLayout.NORTH);
        dummy.setName(m_tab.getName());
        dummy.setBorder(BorderFactory.createEmptyBorder(10, 12, 0, 12));
        this.add(dummy);
        m_tablist.put(fieldGroup, m_tab);
    } else if (fieldGroupType.equals(X_AD_FieldGroup.FIELDGROUPTYPE_Collapse)) {
        CollapsiblePanel collapsibleSection = new CollapsiblePanel(fieldGroup);
        JXCollapsiblePane m_tab = collapsibleSection.getCollapsiblePane();
        m_tab.setAnimated(false);
        m_tab.getContentPane().setBackground(AdempierePLAF.getFormBackground());
        String cpConstraints = defaultLayoutConstraints;
        // 0 inset left and right as this is a nested panel
        // 0 inset top because of the struts added below
        cpConstraints += ", ins 0 0 n 0";
        MigLayout layout = new MigLayout(cpConstraints);
        layout.addLayoutCallback(callback);
        collapsibleSection.setName(fieldGroup);
        m_main.add(collapsibleSection, "newline, spanx, growx");
        m_tab.setLayout(layout);
        /* for compatibility with old layout, force collapsible field groups
			 *  to have a minimum of two columns by inserting invisible components
			 */
        Component strut1 = Box.createVerticalStrut(1);
        strut1.setName("vstrut1" + fieldGroup);
        Component strut2 = Box.createVerticalStrut(1);
        strut2.setName("vstrut2" + fieldGroup);
        m_tab.add(new CLabel(""), "gap 0 0 0 0");
        m_tab.add(strut1, "pushx, growx, gap 0 0 0 0");
        m_tab.add(new CLabel(""), "");
        m_tab.add(strut2, "pushx, growx, gap 0 0 0 0, wrap");
        m_tablist.put(fieldGroup, collapsibleSection);
    } else // Label or null
    {
        CLabel label = new CLabel(fieldGroup, CLabel.LEADING);
        label.setFont(AdempierePLAF.getFont_Label().deriveFont(Font.BOLDITALIC, AdempierePLAF.getFont_Label().getSize2D()));
        //	BR [ 359 ]
        //	Show label completely
        m_main.add(label, "newline, alignx leading, spanx, growx");
        m_main.add(new JSeparator(), "newline, spanx, growx");
    //	reset
    }
    m_oldFieldGroup = fieldGroup;
    m_oldFieldGroupType = fieldGroupType;
    return true;
}
Also used : CLabel(org.compiere.swing.CLabel) BorderLayout(java.awt.BorderLayout) MigLayout(net.miginfocom.swing.MigLayout) JXCollapsiblePane(org.jdesktop.swingx.JXCollapsiblePane) CPanel(org.compiere.swing.CPanel) Component(java.awt.Component) CollapsiblePanel(org.compiere.swing.CollapsiblePanel) JSeparator(javax.swing.JSeparator)

Example 23 with JSeparator

use of javax.swing.JSeparator in project jgnash by ccavanaugh.

the class InvestmentTransactionPanel method layoutMainPanel.

private void layoutMainPanel() {
    initComponents();
    FormLayout layout = new FormLayout("d, 4dlu, m:g, 4dlu, m", "f:d, $ugap, f:d");
    CellConstraints cc = new CellConstraints();
    setBorder(new CompoundBorder(new ShadowBorder(), Borders.TABBED_DIALOG));
    setLayout(layout);
    add(cardPanel, cc.xyw(1, 1, 5));
    add(new JSeparator(), cc.xyw(1, 2, 5));
    add(new JLabel(rb.getString("Label.Action")), cc.xy(1, 3));
    add(actionCombo, cc.xy(3, 3));
    add(StaticUIMethods.buildOKCancelBar(enterButton, cancelButton), cc.xy(5, 3));
}
Also used : FormLayout(com.jgoodies.forms.layout.FormLayout) ShadowBorder(jgnash.ui.components.ShadowBorder) JLabel(javax.swing.JLabel) CompoundBorder(javax.swing.border.CompoundBorder) JSeparator(javax.swing.JSeparator) CellConstraints(com.jgoodies.forms.layout.CellConstraints)

Example 24 with JSeparator

use of javax.swing.JSeparator in project jgnash by ccavanaugh.

the class RecurringPanel method initComponents.

private void initComponents() {
    JPanel toolPanel = new JPanel(new BorderLayout());
    JToolBar toolBar = new JToolBar();
    toolBar.setFloatable(false);
    toolBar.setRollover(true);
    newButton = new RollOverButton(rb.getString("Button.New"), IconUtils.getIcon("/jgnash/resource/document-new.png"));
    modifyButton = new RollOverButton(rb.getString("Button.Modify"), IconUtils.getIcon("/jgnash/resource/document-properties.png"));
    deleteButton = new RollOverButton(rb.getString("Button.Delete"), IconUtils.getIcon("/jgnash/resource/edit-delete.png"));
    remindersButton = new RollOverButton(rb.getString("Button.CheckReminders"), IconUtils.getIcon("/jgnash/resource/view-refresh.png"));
    reminderTable = new FormattedJTable();
    reminderTable.setAutoCreateRowSorter(true);
    reminderTable.setFillsViewportHeight(true);
    reminderTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    reminderTable.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(final KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_DELETE) {
                deleteReminder();
            }
        }
    });
    reminderTable.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(final MouseEvent e) {
            if (e.getClickCount() == 2) {
                showModifyDialog();
            }
        }
    });
    setLayout(new BorderLayout());
    toolBar.add(newButton);
    toolBar.add(modifyButton);
    toolBar.add(deleteButton);
    toolBar.addSeparator();
    toolBar.add(remindersButton);
    toolPanel.add(toolBar, BorderLayout.NORTH);
    toolPanel.add(new JSeparator(), BorderLayout.CENTER);
    add(toolPanel, java.awt.BorderLayout.NORTH);
    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBorder(new EmptyBorder(new Insets(0, 0, 0, 0)));
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setAutoscrolls(true);
    scrollPane.setViewportView(reminderTable);
    add(scrollPane, java.awt.BorderLayout.CENTER);
    deleteButton.addActionListener(this);
    modifyButton.addActionListener(this);
    newButton.addActionListener(this);
    remindersButton.addActionListener(this);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) RollOverButton(jgnash.ui.components.RollOverButton) MouseEvent(java.awt.event.MouseEvent) Insets(java.awt.Insets) KeyAdapter(java.awt.event.KeyAdapter) MouseAdapter(java.awt.event.MouseAdapter) JToolBar(javax.swing.JToolBar) JSeparator(javax.swing.JSeparator) FormattedJTable(jgnash.ui.components.FormattedJTable) KeyEvent(java.awt.event.KeyEvent) BorderLayout(java.awt.BorderLayout) EmptyBorder(javax.swing.border.EmptyBorder)

Example 25 with JSeparator

use of javax.swing.JSeparator in project JMRI by JMRI.

the class SerialPacketGenFrame method initComponents.

@Override
public void initComponents() throws Exception {
    // the following code sets the frame's initial state
    jLabel1.setText("Command:");
    jLabel1.setVisible(true);
    sendButton.setText("Send");
    sendButton.setVisible(true);
    sendButton.setToolTipText("Send packet");
    packetTextField.setText("");
    packetTextField.setToolTipText("Enter command as hexadecimal bytes separated by a space");
    packetTextField.setMaximumSize(new Dimension(packetTextField.getMaximumSize().width, packetTextField.getPreferredSize().height));
    setTitle("Send TMCC command");
    getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
    getContentPane().add(jLabel1);
    getContentPane().add(packetTextField);
    getContentPane().add(sendButton);
    sendButton.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            sendButtonActionPerformed(e);
        }
    });
    getContentPane().add(new JSeparator(JSeparator.HORIZONTAL));
    // pack for display
    pack();
}
Also used : BoxLayout(javax.swing.BoxLayout) Dimension(java.awt.Dimension) JSeparator(javax.swing.JSeparator)

Aggregations

JSeparator (javax.swing.JSeparator)147 JPanel (javax.swing.JPanel)74 JLabel (javax.swing.JLabel)65 ActionEvent (java.awt.event.ActionEvent)44 BoxLayout (javax.swing.BoxLayout)44 JButton (javax.swing.JButton)44 JMenuItem (javax.swing.JMenuItem)38 JMenu (javax.swing.JMenu)32 GridBagConstraints (java.awt.GridBagConstraints)31 Insets (java.awt.Insets)30 ActionListener (java.awt.event.ActionListener)30 Dimension (java.awt.Dimension)24 FlowLayout (java.awt.FlowLayout)24 JScrollPane (javax.swing.JScrollPane)24 GridBagLayout (java.awt.GridBagLayout)22 JPopupMenu (javax.swing.JPopupMenu)19 BorderLayout (java.awt.BorderLayout)16 JTextField (javax.swing.JTextField)16 JCheckBox (javax.swing.JCheckBox)13 AbstractAction (javax.swing.AbstractAction)12