/** * 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 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 new form frmMenuTeste */ public frmMenu() { // "pegue o conteúdo do painel" - adiciona o jDesktopPane ao JFrame (janela principal getContentPane().add(jdPane); // adiciona os menus à barra de menus (jmPrincipal) jmPrincipal.add(jmOperacao); jmPrincipal.add(jmFaturamento); jmPrincipal.add(jmBancoDeDados); // adiciona os itens aos respectivos menus jmOperacao.add(jmPedido); jmOperacao.add(jmReceberPedidosPendentes); jmOperacao.add(jmRealizarEntrega); jmFaturamento.add(jmEfetuarPagamento); jmBancoDeDados.add(jmCadCliente); jmBancoDeDados.add(jmCadProduto); // "ajusta" a barra de menu dentro da janela principal setJMenuBar(jmPrincipal); // adiciona actionlistener aos itens do menu para que os eventos sejam tratados jmPedido.addActionListener(this); jmReceberPedidosPendentes.addActionListener(this); jmRealizarEntrega.addActionListener(this); jmEfetuarPagamento.addActionListener(this); jmCadCliente.addActionListener(this); jmCadProduto.addActionListener(this); setSize(800, 600); setLocationRelativeTo(null); setResizable(false); setVisible(true); // initComponents(); }
/* 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); }
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)); }
private void initMenuBar() { JMenuBar mb = new JMenuBar(); setJMenuBar(mb); JMenu file = new JMenu("Файл"); JMenuItem exit = file.add("Выход"); mb.add(file); JMenu about = new JMenu("About"); JMenuItem us = about.add("About us"); mb.add(about); exit.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { MainFrame.this.dispatchEvent( new WindowEvent(MainFrame.this, WindowEvent.WINDOW_CLOSING)); } }); us.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(MainFrame.this, "Автор: Завгаров Булат"); } }); }
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 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); }
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); }
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); }
public ConexionServidorCMD() { super("Cliente"); // Establece titulo al Frame campoTexto = new JTextField(); // crea el campo para texto campoTexto.setEditable(false); // No permite que sea editable el campo de texto add(campoTexto, BorderLayout.NORTH); // Coloca el campo de texto en la parte superior areaTexto = new JTextArea(); // Crear displayArea areaTexto.setEditable(false); add(new JScrollPane(areaTexto), BorderLayout.CENTER); areaTexto.setBackground(Color.orange); // Pone de color cyan al displayArea areaTexto.setForeground(Color.BLACK); // pinta azul la letra en el displayArea campoTexto.setForeground(Color.BLACK); // pinta toja la letra del mensaje a enviar // Crea menu Archivo y submenu Salir, ademas agrega el submenu al menu JMenu menuArchivo = new JMenu("Archivo"); JMenuItem salir = new JMenuItem("Salir"); menuArchivo.add(salir); // Agrega el submenu Salir al menu menuArchivo JMenuBar barra = new JMenuBar(); // Crea la barra de menus setJMenuBar(barra); // Agrega barra de menus a la aplicacion barra.add(menuArchivo); // agrega menuArchivo a la barra de menus // Accion que se realiza cuando se presiona el submenu Salir salir.addActionListener( new ActionListener() { // clase interna anonima public void actionPerformed(ActionEvent e) { System.exit(0); // Sale de la aplicacion } }); setSize(300, 320); // Establecer tamano a ventana setVisible(true); // Pone visible la ventana }
private void initializeGUI() { JMenuBar menuBar = new JMenuBar(); JMenu fileMenuGroup = new JMenu("File"); JMenuItem fileExit = new JMenuItem("Exit"); fileExit.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { fileExit(); } }); setLayout( new FormLayout( "5px, 1px:grow, 1px:grow, 1px:grow, 1px:grow, 1px:grow, 5px", "25px, 1px:grow, 1px:grow, 5px")); fileMenuGroup.add(fileExit); menuBar.add(fileMenuGroup); add(menuBar, CC.xywh(2, 1, 5, 1)); pack(); Dimension size = new Dimension( VisualizationBase.WINDOW_SIZE.width + 17, VisualizationBase.WINDOW_SIZE.height + 94); setSize(size); }
private void initUI() { JMenuBar menubar = new JMenuBar(); ImageIcon icon = new ImageIcon("exit.png"); JMenu file = new JMenu("File"); file.setMnemonic(KeyEvent.VK_F); JMenuItem eMenuItem = new JMenuItem("Exit", icon); eMenuItem.setMnemonic(KeyEvent.VK_E); eMenuItem.setToolTipText("Exit application"); eMenuItem.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent event) { System.exit(0); } }); file.add(eMenuItem); menubar.add(file); setJMenuBar(menubar); setTitle("Simple menu"); setSize(300, 200); setLocationRelativeTo(null); setDefaultCloseOperation(EXIT_ON_CLOSE); }
protected JMenuBar createMenuBar() { myMenuBar = new SystemMenuBar(); myMenuBar.setFocusable(false); myMenuBar.setBorderPainted(true); myMenuBar.add(createMenu()); return myMenuBar; }
/** 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); }
/** * 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); }
/* * 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(); }
public JMenuBar makeMenuBar() { JMenuBar bar = new JMenuBar(); bar.add(makeFileMenu()); bar.add(makeToolsMenu()); bar.add(makeHelpMenu()); return bar; }
/* * 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; }
/** * This method initializes jJMenuBar * * @return JMenuBar */ private JMenuBar getJJMenuBar() { if (jJMenuBar == null) { jJMenuBar = new JMenuBar(); jJMenuBar.add(getGameMenu()); jJMenuBar.add(getJMenu()); } return jJMenuBar; }
/** 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); }
public ConnectionForm() { setContentPane(contentPane); setModal(true); getRootPane().setDefaultButton(buttonOK); JMenuBar menuBar = new JMenuBar(); menuBar.setVisible(true); JMenu menu = new JMenu("Menu"); menu.setVisible(true); JMenuItem statementItem = new JMenuItem("SQL Insert"); statementItem.setVisible(true); statementItem.addActionListener(new SQLImportActionListener()); statementItem.setEnabled(false); JMenuItem importItem = new JMenuItem("Files Import"); importItem.setEnabled(false); importItem.setVisible(true); menu.add(statementItem); menu.add(importItem); menuBar.add(menu); setJMenuBar(menuBar); buttonOK.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser fileChooser = new JFileChooser(); fileChooser.setCurrentDirectory(new File(System.getProperty("user.home"))); int result = fileChooser.showOpenDialog(getParent()); } }); dbField.addMouseListener(new DBFileMouseListener(getParent())); filesField.addMouseListener(new SQLFilesMouseListener(getParent())); // call onCancel() when cross is clicked setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { onCancel(); } }); // call onCancel() on ESCAPE contentPane.registerKeyboardAction( new ActionListener() { public void actionPerformed(ActionEvent e) { onCancel(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); }
void createMenuBar(JMenu... menues) { JMenuBar menuBar = new JMenuBar(); for (JMenu menu : menues) { menuBar.add(menu); } setJMenuBar(menuBar); }
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); }