/*
* HTMLEditorRemovingMenus2.java
*
*/
import javax.swing.JMenu;
import javax.swing.JMenuBar;
/**
*
* @author Vassil Boyadjiev
*/
public class HTMLEditorRemovingMenus2 extends javax.swing.JFrame {
/** Creates new form HTMLEditorRemovingMenus2 */
public HTMLEditorRemovingMenus2() {
initComponents();
//Example showing removing of menus and menu items
//We get the main menu bar and then we can freely customize its aspect according to swing specs.
//You can see the javadoc documentation for major details on customizing menus
//packages javax.swing.JMenu, javax.swing.JMenuBar, javax.swing.JMenuItem
//Using the approach described below you can customize even the text, icons on the menus and the menu items.
//We want to remove the Edit menu
JMenuBar mainMenu=hTMLEditor1.getJMenuBar();
JMenu editMenu=mainMenu.getMenu(1); //gets the Edit menu -- it is located at index 1
mainMenu.remove(editMenu);//removes the Edit menu
//We want to remove also the Window menu -- since we have removed the edit the indexes are shifted with one
JMenu tableMenu=mainMenu.getMenu(6); //gets the Window menu -- now it is located at index 6
mainMenu.remove(tableMenu); //removes the Window menu
//We want to remove the Open Location menu item from the File menu
JMenu fileMenu=mainMenu.getMenu(0); //gets the File menu -- now it is located at index 0
fileMenu.remove(2); //removes the Open Location menu item located at index 2
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
private void initComponents() {//GEN-BEGIN:initComponents
hTMLEditor1 = new sferyx.administration.editors.HTMLEditor();
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
exitForm(evt);
}
});
getContentPane().add(hTMLEditor1, java.awt.BorderLayout.CENTER);
pack();
}//GEN-END:initComponents
/** Exit the Application */
private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
System.exit(0);
}//GEN-LAST:event_exitForm
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
new HTMLEditorRemovingMenus2().show();
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private sferyx.administration.editors.HTMLEditor hTMLEditor1;
// End of variables declaration//GEN-END:variables
}