/** * Aware-P Epanet application entry point * * @param args * @throws UnsupportedLookAndFeelException */ public static void main(String[] args) throws UnsupportedLookAndFeelException { if (Utilities.isMac()) { System.setProperty("apple.laf.useScreenMenuBar", "true"); System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Aware-P Epanet"); Application app = Application.getApplication(); app.setDockIconImage( Toolkit.getDefaultToolkit().getImage(EpanetUI.class.getResource("/uiresources/ae.png"))); JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); menuBar.add(fileMenu); openAction = new JMenuItem("Open"); saveAction = new JMenuItem("Save"); runAction = new JMenuItem("Run"); fileMenu.add(openAction); fileMenu.add(saveAction); fileMenu.add(runAction); app.setDefaultMenuBar(menuBar); } UIManager.setLookAndFeel(new Plastic3DLookAndFeel()); new EpanetUI(); }
public void createMenu() { // Creates file menu and items JMenu fileMenu = new JMenu(messages.getString("GUIRendWorkspace.file")); fileMenu.setMnemonic('F'); JMenuItem newItem = new JMenuItem(messages.getString("GUIRendWorkspace.fileNew")); newItem.setMnemonic('N'); newItem.addActionListener(new newComponent()); JMenuItem saveItem = new JMenuItem(messages.getString("GUIRendWorkspace.fileSave")); saveItem.setMnemonic('S'); JMenuItem loadItem = new JMenuItem(messages.getString("GUIRendWorkspace.fileLoad")); loadItem.setMnemonic('L'); JMenuItem sourceItem = new JMenuItem(messages.getString("GUIRendWorkspace.fileSource")); sourceItem.setMnemonic('O'); JMenuItem aboutItem = new JMenuItem(messages.getString("GUIRendWorkspace.fileAbout")); aboutItem.setMnemonic('A'); fileMenu.add(newItem); fileMenu.add(sourceItem); fileMenu.add(aboutItem); JMenu windowMenu = new JMenu(messages.getString("GUIRendWorkspace.window")); windowMenu.setMnemonic('W'); JMenuItem showWindowItem = new JMenuItem(messages.getString("GUIRendWorkspace.windowShow")); JMenuItem hideWindowItem = new JMenuItem(messages.getString("GUIRendWorkspace.windowHide")); windowMenu.add(showWindowItem); windowMenu.add(hideWindowItem); // Creates the menu bar JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); menuBar.add(fileMenu); }
/* constructor * Create a frame with JTextArea and a menubar * with a "File" dropdown menu. * * @param title: the title for the frame * @param whichFile: to indicate which load or save buuton */ public OpenFileDir(String title, String whichFile) { super(title); fileNo = whichFile; Container content_pane = getContentPane(); // Create a user interface. content_pane.setLayout(new BorderLayout()); // Use the helper method makeMenuItem // for making the menu items and registering // their listener. JMenu m = new JMenu("File"); // Modify task names to something relevant to // the particular program. m.add(fMenuLoad = makeMenuItem("Load")); m.add(fMenuSave = makeMenuItem("Save")); m.add(fMenuClose = makeMenuItem("Quit")); JMenuBar mb = new JMenuBar(); mb.add(m); setJMenuBar(mb); setSize(400, 200); } /* end of the constructor */
private void buildMenu() { fooMenu = new JMenu("File"); fooMenu.setMnemonic('F'); JMenuItem aboutItem = new JMenuItem("About..."); aboutItem.setMnemonic('A'); aboutItem.setEnabled(true); aboutItem.setIcon(new ImageIcon(this.getClass().getResource("/comment.png"))); aboutItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { JLabel imageLabel = new JLabel(new ImageIcon(this.getClass().getResource("/solve_all_problems.gif"))); JOptionPane.showMessageDialog(null, imageLabel, "About", JOptionPane.PLAIN_MESSAGE); } }); JMenuItem exitItem = new JMenuItem("Exit"); exitItem.setMnemonic('x'); exitItem.setEnabled(true); exitItem.setIcon(new ImageIcon(this.getClass().getResource("/delete.png"))); exitItem.addActionListener(this); fooMenu.add(aboutItem); fooMenu.addSeparator(); fooMenu.add(exitItem); JMenuBar menuBar = new JMenuBar(); menuBar.add(fooMenu); setJMenuBar(menuBar); }
protected JMenuBar createMenuBar() { myMenuBar = new SystemMenuBar(); myMenuBar.setFocusable(false); myMenuBar.setBorderPainted(true); myMenuBar.add(createMenu()); return myMenuBar; }
public DemoControls(Gradient demo) { super(demo.name); this.demo = demo; JMenuBar inMenuBar = new JMenuBar(); add(inMenuBar); JMenuBar outMenuBar = new JMenuBar(); add(outMenuBar); Font font = new Font("serif", Font.PLAIN, 10); imenu = (JMenu) inMenuBar.add(new JMenu("Inner Color")); imenu.setFont(font); imenu.setIcon(new ColoredSquare(demo.innerC)); omenu = (JMenu) outMenuBar.add(new JMenu("Outer Color")); omenu.setFont(font); omenu.setIcon(new ColoredSquare(demo.outerC)); for (int i = 0; i < colors.length; i++) { squares[i] = new ColoredSquare(colors[i]); innerMI[i] = imenu.add(new JMenuItem(colorName[i])); innerMI[i].setFont(font); innerMI[i].setIcon(squares[i]); innerMI[i].addActionListener(this); outerMI[i] = omenu.add(new JMenuItem(colorName[i])); outerMI[i].setFont(font); outerMI[i].setIcon(squares[i]); outerMI[i].addActionListener(this); } }
private static void constructMenu() { final JFrame lFrame = (JFrame) viewModel.get("window.frame"); final JMenuBar lMenuBar = new JMenuBar(); lFrame.setJMenuBar(lMenuBar); viewModel.put("menu", lMenuBar); final JMenu lFileMenu = new JMenu("File"); lFileMenu.setMnemonic(KeyEvent.VK_F); viewModel.put("menu.file", lFileMenu); lMenuBar.add(lFileMenu); final JMenuItem lExitItem = new JMenuItem((Action) viewModel.get("action.exit")); viewModel.put("menu.file.exit", lExitItem); lFileMenu.add(lExitItem); final JMenuItem lHelpMenu = new JMenu("Help"); lHelpMenu.setMnemonic(KeyEvent.VK_H); viewModel.put("menu.help", lHelpMenu); lMenuBar.add(lHelpMenu); final JMenuItem lHelpTopicsItem = new JMenuItem((Action) viewModel.get("action.help")); viewModel.put("menu.help.topics", lHelpTopicsItem); lHelpMenu.add(lHelpTopicsItem); final JMenuItem lAboutItem = new JMenuItem((Action) viewModel.get("action.about")); viewModel.put("menu.help.about", lAboutItem); lHelpMenu.add(lAboutItem); }
public JMenuBar getPanelMenuBar() { if (panelMenuBar == null) { JMenuItem menuItem; ICFLibAnyObj container = getSwingContainer(); panelMenuBar = new JMenuBar(); menuAdd = new JMenu("Add"); actionAddTextCol = new ActionAddTextCol(); if (container instanceof ICFDbTestTableObj) { menuItem = new JMenuItem(actionAddTextCol); menuAdd.add(menuItem); } actionAddTextType = new ActionAddTextType(); if (container instanceof ICFDbTestSchemaDefObj) { menuItem = new JMenuItem(actionAddTextType); menuAdd.add(menuItem); } if (getSwingContainer() != null) { panelMenuBar.add(menuAdd); } menuSelected = new JMenu("Selected"); menuSelected.setEnabled(false); actionViewSelected = new ViewSelectedActionTextDef(); menuItem = new JMenuItem(actionViewSelected); menuSelected.add(menuItem); actionEditSelected = new EditSelectedActionTextDef(); menuItem = new JMenuItem(actionEditSelected); menuSelected.add(menuItem); actionDeleteSelected = new DeleteSelectedActionTextDef(); menuItem = new JMenuItem(actionDeleteSelected); menuSelected.add(menuItem); panelMenuBar.add(menuSelected); } return (panelMenuBar); }
public JMenuBar getPanelMenuBar() { if (panelMenuBar == null) { JMenuItem menuItem; ICFLibAnyObj container = getSwingContainer(); panelMenuBar = new JMenuBar(); menuAdd = new JMenu("Add"); actionAddSecGroupMember = new ActionAddSecGroupMember(); if (container instanceof ICFSecuritySecGroupObj) { menuItem = new JMenuItem(actionAddSecGroupMember); menuAdd.add(menuItem); } if (getSwingContainer() != null) { panelMenuBar.add(menuAdd); } menuSelected = new JMenu("Selected"); menuSelected.setEnabled(false); actionViewSelected = new ViewSelectedActionSecGroupMember(); menuItem = new JMenuItem(actionViewSelected); menuSelected.add(menuItem); actionEditSelected = new EditSelectedActionSecGroupMember(); menuItem = new JMenuItem(actionEditSelected); menuSelected.add(menuItem); actionDeleteSelected = new DeleteSelectedActionSecGroupMember(); menuItem = new JMenuItem(actionDeleteSelected); menuSelected.add(menuItem); panelMenuBar.add(menuSelected); } return (panelMenuBar); }
/* * This is the constructor for our ChoiceFrame */ public ChoiceFrameExtras(String name) { // The keyword super simply sends name to the constructor of // JFrame. super(name); // Construct the text sampleField = new JLabel(new String("Big Java")); // Add the text to the main panel getContentPane().add(sampleField, BorderLayout.CENTER); // Call the method below to add all the components and menu // to the frame createControlPane(); // Create and set the menu bar JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); // Call the methods to add two menus (file and font) to the menu bar menuBar.add(createFileMenu()); menuBar.add(createFontMenu()); createColorDialog(); // Call the method to re-draw the label setSampleFont(); }
/** Intialize me */ private void init() { myTables = new ArrayList(); tableTabbedPane = new JTabbedPane(); tableTabbedPane.setPreferredSize(new Dimension(450, 200)); JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); menuBar.add(fileMenu); fileMenu.add(GuiUtils.makeMenuItem("New Row", this, "addNewRow")); fileMenu.addSeparator(); fileMenu.add(GuiUtils.makeMenuItem("Open", this, "doOpen")); fileMenu.add(GuiUtils.makeMenuItem("Import", this, "doImport")); fileMenu.addSeparator(); fileMenu.add(GuiUtils.makeMenuItem("Export to File", this, "doSaveAs")); fileMenu.add(GuiUtils.makeMenuItem("Export to Plugin", this, "exportToPlugin")); fileMenu.add( GuiUtils.makeMenuItem("Export Selected to Plugin", this, "exportSelectedToPlugin")); fileMenu.addSeparator(); fileMenu.add(GuiUtils.makeMenuItem("Close", this, "doClose")); JMenu helpMenu = new JMenu("Help"); menuBar.add(helpMenu); helpMenu.add(GuiUtils.makeMenuItem("Parameter Defaults Help", this, "showHelp")); JComponent bottom = GuiUtils.wrap(GuiUtils.makeButton("Close", this, "doClose")); contents = GuiUtils.topCenterBottom(menuBar, GuiUtils.inset(tableTabbedPane, 2), bottom); setMenuBar(menuBar); loadResources(resources); }
public MainPanel() { super(new BorderLayout()); panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); panel.add( makePanel( "Look&Feel Default", new JButton( new AbstractAction("showMessageDialog1") { @Override public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(panel, "showMessageDialog1"); } }))); panel.add( makePanel( "notice2.wav", new JButton( new AbstractAction("showMessageDialog2") { @Override public void actionPerformed(ActionEvent e) { UIManager.put( "AuditoryCues.playList", UIManager.get("AuditoryCues.noAuditoryCues")); loadAndPlayAudio("notice2.wav"); JOptionPane.showMessageDialog(panel, "showMessageDialog2"); UIManager.put("AuditoryCues.playList", OPTION_PANE_AUDITORY_CUES); } }))); JMenuBar mb = new JMenuBar(); mb.add(LookAndFeelUtil.createLookAndFeelMenu()); add(mb, BorderLayout.NORTH); add(panel); setPreferredSize(new Dimension(320, 240)); }
public TestSwingExample1() { super("ActionExample"); setChannel(currentChannel); // enable/disable the Actions as appropriate channelLabel.setHorizontalAlignment(JLabel.CENTER); channelLabel.setFont(new Font("Serif", Font.PLAIN, 32)); getContentPane().add(channelLabel, BorderLayout.NORTH); JPanel buttonPanel = new JPanel(new GridLayout(2, 2, 16, 6)); buttonPanel.setBorder(BorderFactory.createEmptyBorder(6, 16, 16, 16)); getContentPane().add(buttonPanel, BorderLayout.CENTER); buttonPanel.add(new JButton(upAction)); buttonPanel.add(new JButton(gotoFavoriteAction)); buttonPanel.add(new JButton(downAction)); buttonPanel.add(new JButton(setFavoriteAction)); JMenuBar mb = new JMenuBar(); JMenu menu = new JMenu("Channel"); menu.add(new JMenuItem(upAction)); menu.add(new JMenuItem(downAction)); menu.addSeparator(); menu.add(new JMenuItem(gotoFavoriteAction)); menu.add(new JMenuItem(setFavoriteAction)); mb.add(menu); setJMenuBar(mb); }
/** * Creates a Simple Neon Hex Frame Application * @throws IOException */ public Main() throws IOException { super("Hex"); setIconImage(Toolkit.getDefaultToolkit().getImage("images\\s1.png")); // Add in a menu JMenuBar menuBar = new JMenuBar(); JMenu gameMenu = new JMenu("Game"); gameMenu.setMnemonic('G'); newMenuItem = new JMenuItem("New Game"); newMenuItem.addActionListener(this); quitMenuItem = new JMenuItem("Exit"); quitMenuItem.addActionListener(this); gameMenu.add(newMenuItem); gameMenu.addSeparator(); gameMenu.add(quitMenuItem); menuBar.add(gameMenu); JMenu helpMenu = new JMenu("Help"); helpMenu.setMnemonic('H'); aboutMenuItem = new JMenuItem("About..."); aboutMenuItem.addActionListener(this); helpMenu.add(aboutMenuItem); menuBar.add(helpMenu); setJMenuBar(menuBar); // Set up the layout // Centre the frame in the middle (almost) of the screen setLayout(new BorderLayout()); tableArea = new Board(); add(tableArea, BorderLayout.CENTER); Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); setLocation((screen.width - Board.WIDTH) / 2, (screen.height - Board.HEIGHT) / 2 - 52); setResizable(false); }
public JMenuBar getPanelMenuBar() { if (panelMenuBar == null) { JMenuItem menuItem; ICFLibAnyObj container = getSwingContainer(); panelMenuBar = new JMenuBar(); menuAdd = new JMenu("Add"); actionAddMajorVersion = new ActionAddMajorVersion(); if (container instanceof ICFInternetRealProjectObj) { menuItem = new JMenuItem(actionAddMajorVersion); menuAdd.add(menuItem); } actionAddMinorVersion = new ActionAddMinorVersion(); if (container instanceof ICFInternetMajorVersionObj) { menuItem = new JMenuItem(actionAddMinorVersion); menuAdd.add(menuItem); } if (getSwingContainer() != null) { panelMenuBar.add(menuAdd); } menuSelected = new JMenu("Selected"); menuSelected.setEnabled(false); actionViewSelected = new ViewSelectedActionVersion(); menuItem = new JMenuItem(actionViewSelected); menuSelected.add(menuItem); actionEditSelected = new EditSelectedActionVersion(); menuItem = new JMenuItem(actionEditSelected); menuSelected.add(menuItem); actionDeleteSelected = new DeleteSelectedActionVersion(); menuItem = new JMenuItem(actionDeleteSelected); menuSelected.add(menuItem); panelMenuBar.add(menuSelected); } return (panelMenuBar); }
/* * Frame Constructor */ public EvalGUI() { // map image Image img = null; try { img = ImageIO.read(new File("map2.png")); } catch (IOException e) { } img = img.getScaledInstance(300, 300, Image.SCALE_SMOOTH); JLabel small_img = new JLabel(new ImageIcon(img)); getContentPane().setLayout(new BorderLayout()); Right_Panel.add(Statistics_Panel, BorderLayout.CENTER); Statistics_Panel.add(dist_title); Statistics_Panel.add(totaldistance); Statistics_Panel.add(dist_curr_obj); Statistics_Panel.add(dist_charge); Statistics_Panel.add(clean_title); Statistics_Panel.add(space_covered); Statistics_Panel.add(room_covered); Statistics_Panel.add(charge_visits); Statistics_Panel.add(battery_title); Statistics_Panel.add(batt_remaining); Statistics_Panel.add(coverage_title); Statistics_Panel.add(nr_coverage_divisions); Statistics_Panel.add(vert_hor_div); Statistics_Panel.add(rob_coord); Statistics_Panel.add(time_elapsed); Statistics_Panel.add(time_completion); Right_Panel.add(small_img, BorderLayout.SOUTH); add(Right_Panel, BorderLayout.EAST); add(Map_Panel, BorderLayout.WEST); // menu items menubar.add(file); menubar.add(options); menubar.add(exit); file.add(newmap); options.add(measure); options.add(speed); exit.add(exit_); setJMenuBar(menubar); // frame operations setVisible(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(860, 650); setTitle("EvaluationGUI"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // pack(); }
/** Create menus */ private JMenuBar createMenus() { JMenuItem mi; // ***** create the menubar **** menuBar = new JMenuBar(); // ***** create File menu fileMenu = (JMenu) menuBar.add(new JMenu("File")); fileMenu.setMnemonic('F'); createMenuItem(fileMenu, "Print", 'P', "", new PrintAction(this)); createMenuItem(fileMenu, "Close", 'C', "", new CloseAction(this)); fileMenu.add(new JSeparator()); createMenuItem(fileMenu, "Exit", 'E', "", new ExitAction()); // ***** create laf switcher menu lafMenu = (JMenu) menuBar.add(new JMenu("Look & Feel")); lafMenu.setMnemonic('L'); mi = createLafMenuItem(lafMenu, "Java Look & Feel", 'J', "", metal); mi.setSelected(true); // this is the default l&f metalMenuItem = mi; createLafMenuItem(lafMenu, "Macintosh Look & Feel", 'M', "", mac); createLafMenuItem(lafMenu, "Motif Look & Feel", 'F', "", motif); createLafMenuItem(lafMenu, "Windows Look & Feel", 'W', "", windows); // ***** create themes menu themesMenu = (JMenu) menuBar.add(new JMenu("Themes")); themesMenu.setMnemonic('T'); mi = createThemesMenuItem(themesMenu, "Default", 'D', "", new DefaultMetalTheme()); mi.setSelected(true); // This is the default theme createThemesMenuItem(themesMenu, "Aqua", 'A', "", new AquaTheme()); createThemesMenuItem(themesMenu, "Charcoal", 'C', "", new CharcoalTheme()); createThemesMenuItem(themesMenu, "High Contrast", 'H', "", new ContrastTheme()); createThemesMenuItem(themesMenu, "Emerald", 'E', "", new EmeraldTheme()); createThemesMenuItem(themesMenu, "Ruby", 'R', "", new RubyTheme()); createThemesMenuItem(themesMenu, "Presentation", 'P', "", new DemoMetalTheme()); createThemesMenuItem(themesMenu, "Sandstone", 'S', "", new KhakiMetalTheme()); createThemesMenuItem(themesMenu, "Big High Contrast", 'I', "", new BigContrastMetalTheme()); createThemesMenuItem(themesMenu, "Blue", 'B', "", new BlueTheme()); createThemesMenuItem(themesMenu, "Cougaar", 'O', "", new CougaarTheme()); createThemesMenuItem( themesMenu, "Cougaar Presentation", 'O', "", new CougaarPresentationTheme()); return menuBar; }
/** Creates the menu bar */ private JMenuBar createMenuBar() { JMenuBar menuBar = new JMenuBar(); menuBar.add(createTabbedPanelMenu()); menuBar.add(createTitledTabMenu()); menuBar.add(createThemeMenu()); menuBar.add(createHoverMenu()); return menuBar; }
public DistributedTextEditor() { area1.setFont(new Font("Monospaced", Font.PLAIN, 12)); area2.setFont(new Font("Monospaced", Font.PLAIN, 12)); ((AbstractDocument) area1.getDocument()).setDocumentFilter(dec); area2.setEditable(false); Container content = getContentPane(); content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS)); JScrollPane scroll1 = new JScrollPane( area1, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); content.add(scroll1, BorderLayout.CENTER); JScrollPane scroll2 = new JScrollPane( area2, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); content.add(scroll2, BorderLayout.CENTER); content.add(ipaddress, BorderLayout.CENTER); content.add(portNumber, BorderLayout.CENTER); JMenuBar JMB = new JMenuBar(); setJMenuBar(JMB); JMenu file = new JMenu("File"); JMenu edit = new JMenu("Edit"); JMB.add(file); JMB.add(edit); file.add(Listen); file.add(Connect); file.add(Disconnect); file.addSeparator(); file.add(Save); file.add(SaveAs); file.add(Quit); edit.add(Copy); edit.add(Paste); edit.getItem(0).setText("Copy"); edit.getItem(1).setText("Paste"); Save.setEnabled(false); SaveAs.setEnabled(false); Disconnect.setEnabled(false); setDefaultCloseOperation(EXIT_ON_CLOSE); pack(); area1.addKeyListener(k1); area1.addMouseListener(m1); setTitle("Disconnected"); setVisible(true); area1.insert("Welcome to Hjortehandlerne's distributed text editor. \n", 0); this.addWindowListener(w1); }
/** * Create the menubar for the app. By default this pulls the definition of the menu from the * associated resource file. */ protected JMenuBar createMenubar() { JMenuBar mb = new JMenuBar(); for (String menuKey : getMenuBarKeys()) { JMenu m = createMenu(menuKey); if (m != null) { mb.add(m); } } return mb; }
void createMenuBar(JMenu... menues) { JMenuBar menuBar = new JMenuBar(); for (JMenu menu : menues) { menuBar.add(menu); } setJMenuBar(menuBar); }
public CFInternetSwingVersionListJPanel( ICFInternetSwingSchema argSchema, ICFLibAnyObj argContainer, ICFInternetVersionObj argFocus, Collection<ICFInternetVersionObj> argDataCollection, ICFJRefreshCallback refreshCallback, boolean sortByChain) { super(); final String S_ProcName = "construct-schema-focus"; if (argSchema == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 1, "argSchema"); } // argFocus is optional; focus may be set later during execution as // conditions of the runtime change. swingSchema = argSchema; swingFocus = argFocus; swingContainer = argContainer; swingRefreshCallback = refreshCallback; swingSortByChain = sortByChain; setSwingDataCollection(argDataCollection); dataTable = new JTable(getDataModel(), getDataColumnModel(), getDataListSelectionModel()); dataTable.addMouseListener(getDataListMouseAdapter()); dataTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); dataTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); dataTable.setUpdateSelectionOnSort(true); dataTable.setRowHeight(25); getDataListSelectionModel().addListSelectionListener(getDataListSelectionListener()); dataScrollPane = new JScrollPane( dataTable, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); dataScrollPane.setColumnHeader( new JViewport() { @Override public Dimension getPreferredSize() { Dimension sz = super.getPreferredSize(); sz.height = 25; return (sz); } }); dataTable.setFillsViewportHeight(true); // Do initial layout setSize(1024, 480); JMenuBar menuBar = getPanelMenuBar(); add(menuBar); menuBar.setBounds(0, 0, 1024, 25); add(dataScrollPane); dataScrollPane.setBounds(0, 25, 1024, 455); adjustListMenuBar(); doLayout(); swingIsInitializing = false; }
/** * Constructor creates graphic components and adds them to the JPanel this class inherits from. */ public SlidePuzzleGUI(String solver) { // default settings for internal attributes: unsolved 15 puzzle nPuzzle = 15; solved = false; this.solver = solver; // create graphics // create menu bar with pull down menu for puzzle configuration // this needs a menu and a menu item in it menuBar = new JMenuBar(); menuBar.setBorder(new BevelBorder(BevelBorder.RAISED)); // create a menu and add it to the menu bar. JMenu menu = new JMenu("Menu"); menu.setMnemonic(KeyEvent.VK_M); // create menu item JMenuItem eMenuItem = new JMenuItem("Configuration"); eMenuItem.setMnemonic(KeyEvent.VK_C); eMenuItem.setToolTipText("Set Puzzle Configuration"); eMenuItem.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent event) { createFrame(); // create configuration frame } }); menu.add(eMenuItem); menuBar.add(menu); // create button to solve puzzle in a step by step manner // The listener is too lengthy for an anonymous class, // code for the listener resides in internal NewGameAction class. JButton newGameButton = new JButton("Solve"); ActionListener gameAction = new NewGameAction(); newGameButton.addActionListener(gameAction); // create control panel that holds the solve button JPanel controlPanel = new JPanel(); controlPanel.setLayout(new FlowLayout()); controlPanel.add(newGameButton); // create graphics panel initalPuzzleGraphics = new GraphicsPanel(nPuzzle, PanelType.INITIALPANEL); intermediatePuzzleGraphics = new GraphicsPanel(nPuzzle, PanelType.INTERMEDIATEPANEL); finalPuzzleGraphics = new GraphicsPanel(nPuzzle, PanelType.GOALPANEL); // create and configure a solver constructPuzzleSolver(); // the panel uses a borderlayout // the menubar goes on top setLayout(new BorderLayout()); add(menuBar, BorderLayout.NORTH); add(controlPanel, BorderLayout.SOUTH); add(initalPuzzleGraphics, BorderLayout.WEST); add(intermediatePuzzleGraphics, BorderLayout.CENTER); add(finalPuzzleGraphics, BorderLayout.EAST); }
void makeMenu() { JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu(strings.getString("menu.file")); menuBar.add(fileMenu); JMenuItem menuItem; menuItem = new JMenuItem(strings.getString("menu.file.new")); menuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ev) { onNewFileClicked(); } }); fileMenu.add(menuItem); menuItem = new JMenuItem(strings.getString("menu.file.open")); menuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ev) { onOpenFileClicked(); } }); fileMenu.add(menuItem); menuItem = new JMenuItem(strings.getString("menu.file.save")); menuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ev) { onSaveFileClicked(); } }); fileMenu.add(menuItem); menuItem = new JMenuItem(strings.getString("menu.file.save_as")); menuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ev) { onSaveAsFileClicked(); } }); fileMenu.add(menuItem); menuItem = new JMenuItem(strings.getString("menu.file.exit")); menuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ev) { closeWindow(); } }); fileMenu.add(menuItem); setJMenuBar(menuBar); }
private void creerMenu() { menuBar = new JMenuBar(); menuOption.add(menuNouvellePartie); menuOption.add(menuScore); menuBar.add(menuOption); menuBar.add(pause); menuBar.add(hint); setJMenuBar(menuBar); }
public IvusFrame(World world) { OrbitView view = (world != null) ? new OrbitView(world) : new OrbitView(); view.setAxesOrientation(AxesOrientation.XRIGHT_YOUT_ZDOWN); ViewCanvas canvas = new ViewCanvas(view); canvas.setView(view); ModeManager mm = new ModeManager(); mm.add(canvas); OrbitViewMode ovm = new OrbitViewMode(mm); SelectDragMode sdm = new SelectDragMode(mm); JPopupMenu.setDefaultLightWeightPopupEnabled(false); ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false); JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic('F'); Action exitAction = new AbstractAction("Exit") { private static final long serialVersionUID = 1L; public void actionPerformed(ActionEvent event) { System.exit(0); } }; JMenuItem exitItem = fileMenu.add(exitAction); exitItem.setMnemonic('x'); JMenu modeMenu = new JMenu("Mode"); modeMenu.setMnemonic('M'); JMenuItem ovmItem = new ModeMenuItem(ovm); modeMenu.add(ovmItem); JMenuItem sdmItem = new ModeMenuItem(sdm); modeMenu.add(sdmItem); JMenuBar menuBar = new JMenuBar(); menuBar.add(fileMenu); menuBar.add(modeMenu); JToolBar toolBar = new JToolBar(SwingConstants.VERTICAL); toolBar.setRollover(true); JToggleButton ovmButton = new ModeToggleButton(ovm); toolBar.add(ovmButton); JToggleButton sdmButton = new ModeToggleButton(sdm); toolBar.add(sdmButton); ovm.setActive(true); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setSize(new Dimension(SIZE, SIZE)); this.add(canvas, BorderLayout.CENTER); this.add(toolBar, BorderLayout.WEST); this.setJMenuBar(menuBar); }
// create the menu bar (changed to private) private static JMenuBar createMenuBar() { JMenuBar menuBar = new JMenuBar(); JMenu menu = new JMenu("File"); menuBar.add(menu); JMenuItem menuItem1 = new JMenuItem(" Save... "); menuItem1.addActionListener(std); menuItem1.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); menu.add(menuItem1); return menuBar; }
/** Removes the menu represented by the node */ private void removeVisualMenu(RADMenuItemComponent comp) { Object o = getBeanInstance(); Object m = comp.getBeanInstance(); Object dto = getDesignTimeMenus(getFormManager()).getDesignTime(o); Object dtm = getDesignTimeMenus(getFormManager()).getDesignTime(m); switch (getMenuItemType()) { case T_MENUBAR: ((MenuBar) o).remove((Menu) m); ((JMenuBar) dto).remove((JMenu) dtm); ((JMenuBar) dto).validate(); break; case T_MENU: if (comp.getMenuItemType() == T_SEPARATOR) { ((Menu) o).remove(subComponents.indexOf(comp)); ((JMenu) dto).remove(subComponents.indexOf(comp)); } else { ((Menu) o).remove((MenuItem) m); ((JMenu) dto).remove((JMenuItem) dtm); } break; case T_POPUPMENU: if (comp.getMenuItemType() == T_SEPARATOR) { ((Menu) o).remove(subComponents.indexOf(comp)); // PENDING - dont know how to get reference to JPopupMenu.Separator // so it is not supported by getDesignTimeMenu () !! // ((JPopupMenu)dto).remove((JPopupMenu.Separator)dtm); } else { ((Menu) o).remove((MenuItem) m); ((JPopupMenu) dto).remove((JMenuItem) dtm); } break; case T_JMENUBAR: ((JMenuBar) o).remove((JMenu) m); ((JMenuBar) o).validate(); break; case T_JMENU: if (comp.getMenuItemType() == T_JSEPARATOR) { ((JMenu) o).remove(subComponents.indexOf(comp)); } else { ((JMenu) o).remove((JMenuItem) m); } break; case T_JPOPUPMENU: if (comp.getMenuItemType() == T_JSEPARATOR) { // XXX(-tdt) ((JPopupMenu)o).remove((JPopupMenu.Separator)m); ((JPopupMenu) o).remove(subComponents.indexOf(comp)); } else { ((JPopupMenu) o).remove((JMenuItem) m); } break; } }
public void go() { frame = new JFrame("Quiz Card Player"); JPanel mainPanel = new JPanel(); Font bigFont = new Font("sanserif", Font.BOLD, 24); display = new JTextArea(10, 20); display.setFont(bigFont); display.setLineWrap(true); display.setEditable(false); JScrollPane qScroller = new JScrollPane(display); qScroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); qScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); nextButton = new JButton("Show Questions"); nextButton.addActionListener(new NextCardListener()); mainPanel.add(qScroller); mainPanel.add(nextButton); JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); JMenuItem loadMenuItem = new JMenuItem("Load Card Set"); loadMenuItem.addActionListener(new OpenMenuListener()); fileMenu.add(loadMenuItem); menuBar.add(fileMenu); frame.setJMenuBar(menuBar); frame.getContentPane().add(BorderLayout.CENTER, mainPanel); frame.setSize(640, 500); frame.setVisible(true); }
public void go() { // build gui frame = new JFrame("Quiz Card Buider"); JPanel mainPanel = new JPanel(); Font bigFont = new Font("sanserif", Font.BOLD, 24); question = new JTextArea(6, 20); question.setLineWrap(true); question.setWrapStyleWord(true); question.setFont(bigFont); JScrollPane qScroller = new JScrollPane(question); qScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); qScroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); answer = new JTextArea(6, 20); answer.setLineWrap(true); answer.setWrapStyleWord(true); answer.setFont(bigFont); JScrollPane aScroller = new JScrollPane(question); aScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); aScroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); JButton nextButton = new JButton("Next Card"); cardList = new ArrayList<QuizCard>(); JLabel qLabel = new JLabel("Question"); JLabel aLabel = new JLabel("Answer"); mainPanel.add(qLabel); mainPanel.add(qScroller); mainPanel.add(aLabel); mainPanel.add(aScroller); mainPanel.add(nextButton); nextButton.addActionListener(new NextCardListener()); JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); JMenuItem newMenuItem = new JMenuItem("New"); JMenuItem saveMenuItem = new JMenuItem("Save"); newMenuItem.addActionListener(new NewMenuListener()); saveMenuItem.addActionListener(new SaveMenuListener()); fileMenu.add(newMenuItem); fileMenu.add(saveMenuItem); menuBar.add(fileMenu); frame.setJMenuBar(menuBar); frame.getContentPane().add(BorderLayout.CENTER, mainPanel); frame.setSize(500, 600); frame.setVisible(true); // frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }