Ejemplo n.º 1
0
 /** Sets up the components in this frame. */
 private void setupComponents() {
   myDrawPanel.addMouseListener(new DrawPanelMouseListener());
   myFrame.add(myDrawPanel, BorderLayout.CENTER);
   myFrame.setJMenuBar(myMenuBar);
   myFrame.setIconImage(new ImageIcon("./images//paint.png").getImage());
   createFileMenu();
   createOptionMenu();
   final Action[] actions = {
     new PencilAction(myDrawPanel, new PencilTool()),
     new LineAction(myDrawPanel, new LineTool()),
     new RectangleAction(myDrawPanel, new RectangleTool()),
     new EllipseAction(myDrawPanel, new EllipseTool())
   };
   myDrawPanel.addPropertyChangeListener(this);
   final JMenu toolMenu = new JMenu("Tools");
   toolMenu.setMnemonic(KeyEvent.VK_T);
   final JToolBar toolBar = new JToolBar();
   for (final Action current : actions) {
     toolMenu.add(createToolMenuButton(current));
     toolBar.add(createToolBarButton(current));
     myDrawPanel.setTool(new PencilTool());
   }
   myMenuBar.add(toolMenu);
   createHelpMenu();
   createColorMenuItem();
   myFrame.add(toolBar, BorderLayout.SOUTH);
 }
Ejemplo n.º 2
0
  public void go() throws IOException {
    // DefaultRouteTable route = new DefaultRouteTable();
    // System.out.println(route.routeInfo());
    // route.routeInfo();
    totalSize = Toolkit.getDefaultToolkit().getScreenSize(); // getting screen size
    int width = totalSize.width;
    int height = totalSize.height;
    frame = new JFrame(); // creating frame
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent we) {
            FileInput data = null;
            try {
              data = new FileInput("input.txt");
            } catch (Exception e) {

            }
            String[][] origRoutes =
                convertArrayListTo2DArray(data.routeArrayList(data.routesToken), 1);
            String[][] routesList = Main.convertArrayListTo2DArray(routesInfo, 1);
            Main.changesCheck(origRoutes, routesList);
          }
        });
    frame.setTitle("Air Route Planner");
    frame.add(Panels());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize((width * 3 / 4), (height * 3 / 4));
    frame.setJMenuBar(menuBar());
    frame.setResizable(false);
    frame.setVisible(true);
    frame.setLocationRelativeTo(null);
  }
Ejemplo n.º 3
0
  public Bomberman() {
    /**
     * add(new Board()); setTitle("Bomberman"); setDefaultCloseOperation(EXIT_ON_CLOSE);
     * setSize(600, 550); setLocationRelativeTo(null); setVisible(true);
     */
    JFrame f = new JFrame("Bomberman");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setBounds(50, 50, 500, 545);

    JMenuBar mb = new JMenuBar();
    JMenu m1 = new JMenu("Datei");
    mb.add(m1);
    JMenuItem start = new JMenuItem("Neues Spiel");
    m1.add(start);
    start.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
            new Bomberman(); // Bugfix nötig
          }
        });
    JMenuItem end = new JMenuItem("Beenden");
    m1.add(end);

    end.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
            System.exit(1);
          }
        });

    f.setJMenuBar(mb);
    f.setLocationRelativeTo(null);
    f.getContentPane().add(new Board());
    f.setVisible(true);
  }
Ejemplo n.º 4
0
  /**
   * Initialize() sets up the main frame for the application. It sets the size for the program and
   * adds any buttons to the frame that are required.
   *
   * <p>Use this function to add buttons to the inital screen.
   */
  public void initialize() {
    frame = new JFrame();
    frame.setBounds(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);

    layout = new BorderLayout();
    frame.setLayout(layout);

    editor = new JPanel();

    menu = new JMenuBar();

    file = new JMenu("File");

    newBoard = new JMenuItem("New Board");
    newBoard.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent arg0) {}
        });
    file.add(newBoard);

    menu.add(file);

    frame.setJMenuBar(menu);
  }
Ejemplo n.º 5
0
  public GUITable() throws Exception {
    main_frame = new JFrame("Card Games");
    main_frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    main_frame.setPreferredSize(new Dimension(357, 323));
    main_frame.setResizable(false);
    main_menu = new TableMenu();
    main_frame.setJMenuBar(main_menu);

    Container cp = main_frame.getContentPane();
    cp.setLayout(new CardLayout());
    JLabel base = new JLabel("Use the game menu to start a game");
    base.setHorizontalAlignment(SwingConstants.CENTER);
    base.setVerticalAlignment(SwingConstants.CENTER);
    cp.add(base, "Base");
    base.setSize(cp.getSize());

    main_frame.pack();
    main_frame.setVisible(true);

    game_gui = null;
    games = new Hashtable<String, TableUI>();
    this.host = GUIPlayer.getCurrentPlayer();
    if (this.host == null) {
      main_menu.showNewUserDialog(main_frame);
      this.host = GUIPlayer.getCurrentPlayer();
      if (this.host != null) main_menu.enableGameMenus();
    } else main_menu.enableGameMenus();
  }
Ejemplo n.º 6
0
 /** Lay out the elements for the main window */
 protected void buildFrame() {
   GridBagConstraints c = new GridBagConstraints();
   GridBagLayout layout = new GridBagLayout();
   frame = new JFrame();
   menuBar = frame.getJMenuBar();
   if (menuBar == null) {
     menuBar = new JMenuBar();
     frame.setJMenuBar(menuBar);
   }
   basicListener = new BasicListener();
   JMenu menu = new JMenu("File");
   JMenuItem readDirectory = new JMenuItem("Read Directory");
   readDirectory.addActionListener(basicListener);
   readDirectory.setActionCommand("READALL");
   menu.add(readDirectory);
   JMenuItem exitProgram = new JMenuItem("ExitProgram");
   exitProgram.addActionListener(basicListener);
   exitProgram.setActionCommand("EXIT");
   menu.add(exitProgram);
   menuBar.add(menu);
   JPanel panel = new JPanel();
   c.fill = GridBagConstraints.BOTH;
   c.gridwidth = GridBagConstraints.REMAINDER;
   c.weightx = 3.0f;
   panel.setLayout(layout);
   extraButtonItems(panel, layout);
   c.weighty = 2.0f;
   layout.setConstraints(panel, c);
   frame.add(panel);
   frame.setSize(400, 400);
   frame.setVisible(true);
 }
Ejemplo n.º 7
0
  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);
  }
Ejemplo n.º 8
0
  private void createMenu(JFrame frame) {
    menuBar = new JMenuBar();

    // First menu: "File"
    fileMenu = new JMenu("File");
    menuBar.add(fileMenu);

    newMenuItem = new JMenuItem("New...", KeyEvent.VK_N);
    newMenuItem.addActionListener(this);
    fileMenu.add(newMenuItem);

    saveMenuItem = new JMenuItem("Save...", KeyEvent.VK_S);
    saveMenuItem.addActionListener(this);
    fileMenu.add(saveMenuItem);

    openMenuItem = new JMenuItem("Open...", KeyEvent.VK_O);
    openMenuItem.addActionListener(this);
    fileMenu.add(openMenuItem);

    fileMenu.addSeparator();

    exitMenuItem = new JMenuItem("Exit...", KeyEvent.VK_X);
    exitMenuItem.addActionListener(this);
    fileMenu.add(exitMenuItem);

    // Add menubar to frame
    frame.setJMenuBar(menuBar);
  }
  /** Method to create the menu bar, menus, and menu items */
  private void setUpMenuBar() {
    // create menu
    menuBar = new JMenuBar();
    zoomMenu = new JMenu("Zoom");
    twentyFive = new JMenuItem("25%");
    fifty = new JMenuItem("50%");
    seventyFive = new JMenuItem("75%");
    hundred = new JMenuItem("100%");
    hundred.setEnabled(false);
    hundredFifty = new JMenuItem("150%");
    twoHundred = new JMenuItem("200%");
    fiveHundred = new JMenuItem("500%");

    // add the action listeners
    twentyFive.addActionListener(this);
    fifty.addActionListener(this);
    seventyFive.addActionListener(this);
    hundred.addActionListener(this);
    hundredFifty.addActionListener(this);
    twoHundred.addActionListener(this);
    fiveHundred.addActionListener(this);

    // add the menu items to the menus
    zoomMenu.add(twentyFive);
    zoomMenu.add(fifty);
    zoomMenu.add(seventyFive);
    zoomMenu.add(hundred);
    zoomMenu.add(hundredFifty);
    zoomMenu.add(twoHundred);
    zoomMenu.add(fiveHundred);
    menuBar.add(zoomMenu);

    // set the menu bar to this menu
    pictureFrame.setJMenuBar(menuBar);
  }
Ejemplo n.º 10
0
  protected final void initMenu() {
    mainFrame.setJMenuBar(menuBar);

    menuBar.add(fileMenu);

    fileOpen.addActionListener(new FileAddListener());
    fileMenu.add(fileOpen);

    fileClose.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            System.exit(0);
          }
        });
    fileMenu.add(fileClose);

    // used for language selection, for future add-on
    /*
    menuBar.add(languageMenu);
    eng.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    setTextByLocale(new Locale("en", "us"));
    }
    });
    languageMenu.add(eng);
    chn.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    setTextByLocale(new Locale("zh", "cn"));
    }
    });
    languageMenu.add(chn);
    */
  }
Ejemplo n.º 11
0
  public static void main(String[] args) throws Exception {
    try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
      e.printStackTrace();
    }

    UIManager.put("PopupMenuUI", "DropShadow.CustomPopupMenuUI");

    JFrame frame = new JFrame(DropShadowDemo.class.getSimpleName());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JMenuBar mb = new JMenuBar();
    frame.setJMenuBar(mb);
    JMenu menu = new JMenu("File");
    mb.add(menu);
    menu.add(new JMenuItem("Open"));
    menu.add(new JMenuItem("Save"));
    menu.add(new JMenuItem("Close"));
    menu.add(new JMenuItem("Exit"));
    menu = new JMenu("Edit");
    mb.add(menu);
    menu.add(new JMenuItem("Cut"));
    menu.add(new JMenuItem("Copy"));
    menu.add(new JMenuItem("Paste"));
    frame.getContentPane().setLayout(new BorderLayout());
    frame.getContentPane().add("North", new JButton("Button"));
    frame.getContentPane().add("Center", new JLabel("a label"));
    frame.getContentPane().add("South", new JCheckBox("checkbox"));
    frame.pack();
    frame.setSize(200, 150);
    frame.setLocationRelativeTo(null);
    frame.show();
  }
Ejemplo n.º 12
0
  /** Display the picture in a window on the screen. */
  public void show() {

    // create the GUI for viewing the image if needed
    if (frame == null) {
      frame = new JFrame();

      JMenuBar menuBar = new JMenuBar();
      JMenu menu = new JMenu("File");
      menuBar.add(menu);
      JMenuItem menuItem1 = new JMenuItem(" Save...   ");
      menuItem1.addActionListener(this);
      menuItem1.setAccelerator(
          KeyStroke.getKeyStroke(
              KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
      menu.add(menuItem1);
      frame.setJMenuBar(menuBar);

      frame.setContentPane(getJLabel());
      // f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
      frame.setTitle(filename);
      frame.setResizable(false);
      frame.pack();
      frame.setVisible(true);
    }

    // draw
    frame.repaint();
  }
Ejemplo n.º 13
0
  public void doIt() {
    mJFrame = new JFrame(mWindowName);
    mJFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Create the menu bar.
    mJMenuBarMain = new JMenuBar();
    mJMenuBarMain.setOpaque(true);
    mJMenuBarMain.setBackground(mMenuColor);
    mJMenuBarMain.setPreferredSize(new Dimension(X_WINDOW_SIZE, Y_MENU_SIZE));

    // Create main component
    mJMain = new JLabel();
    mJMain.setOpaque(true);
    mJMain.setBackground(mMainColor);
    mJMain.setPreferredSize(new Dimension(X_WINDOW_SIZE * 5, Y_WINDOW_SIZE * 150));

    JScrollPane scrollPane = new JScrollPane(mJMain);
    scrollPane.setPreferredSize(new Dimension(X_WINDOW_SIZE + 20, Y_WINDOW_SIZE + 20));

    // Set the menu bar and add the label to the content pane.
    mJFrame.setJMenuBar(mJMenuBarMain);
    mJFrame.getContentPane().add(scrollPane, BorderLayout.CENTER);
    mJFrame.setLocation(10, 10);

    // Display the window.
    mJFrame.pack();
    mJFrame.setVisible(true);
  }
Ejemplo n.º 14
0
  // setUpMenu
  private void setUpMenu(JFrame window) {
    JMenuBar menubar = new JMenuBar();
    JMenu game = new JMenu("Game");
    JMenuItem newGame = new JMenuItem("NewGame");
    JMenuItem restart = new JMenuItem("Restart");
    JMenuItem forfeit = new JMenuItem("Forfeit");
    JMenuItem undo = new JMenuItem("Undo");
    JMenuItem score = new JMenuItem("Score");
    JMenuItem customerPiece = new JMenuItem("CustomerPiece");

    newGame.addActionListener(this);
    restart.addActionListener(this);
    forfeit.addActionListener(this);
    undo.addActionListener(this);
    score.addActionListener(this);
    customerPiece.addActionListener(this);
    game.add(newGame);
    game.add(restart);
    game.add(forfeit);
    game.add(undo);
    game.add(score);
    game.add(customerPiece);
    menubar.add(game);
    window.setJMenuBar(menubar);
  }
Ejemplo n.º 15
0
  /**
   * Method for setting up the menu bar and adding it to the main frame.
   *
   * @param frame the frame where to add the menu bar
   */
  private void addMenuBar(JFrame frame) {

    JMenuBar menuBar = new JMenuBar();
    frame.setJMenuBar(menuBar);

    // Menus
    file = new JMenu(lang.getText("ui.mainview.menu.file"));
    edit = new JMenu(lang.getText("ui.mainview.menu.edit"));
    help = new JMenu(lang.getText("ui.mainview.menu.help"));
    JMenuItem chooseLanguage = new JMenuItem(controller.getLanguageAction());

    // Sub menus
    JMenuItem about = new JMenuItem(controller.getAboutAction());
    JMenuItem addTodo = new JMenuItem(controller.getAddAction());
    JMenuItem editTodo = new JMenuItem(controller.getEditAction());
    JMenuItem deleteTodo = new JMenuItem(controller.getDeleteAction());
    JMenuItem setTodo = new JMenuItem(controller.getDoneAction());
    JMenuItem showGraph = new JMenuItem(controller.getShowGraphAction());

    // Set up menu bar
    menuBar.add(file);
    menuBar.add(edit);
    menuBar.add(help);
    file.add(chooseLanguage);
    file.add(showGraph);
    help.add(about);
    edit.add(addTodo);
    edit.add(editTodo);
    edit.add(deleteTodo);
    edit.add(setTodo);
  }
Ejemplo n.º 16
0
  public static void main(String[] args) {

    try {
      // myFrame.add(newSubPanel);

      JTabbedPane tabbedPane = new JTabbedPane();
      isSmall = true;
      // tabbedPane.add(new JButton("asd"));
      JMenuBar menuBar = new JMenuBar();
      // menuBar.add(tabbedPane);
      menuBar.setBackground(Color.white);
      menuBar.setVisible(true);
      menuBar.add(new ResolutionButton());
      menuBar.add(new NextPanelbutton(false));
      menuBar.add(new NextPanelbutton(true));
      // menuBar.setPreferredSize(new Dimension(1024, 20));
      UpploaderView u = new UpploaderView();
      tabbedPane.addTab("Channel", u);
      tabbedPane.addTab("Videos", newSubPanel);
      //	menuBar.add(tabbedPane);
      // tabbedPane.setTabComponentAt(0,menuBar);

      // myFrame.add(u);
      // myFrame.add(tabbedPane);
      //	myFrame.setLayout(new FlowLayout());
      // Toolkit toolkit = Toolkit.getDefaultToolkit();
      // System.out.println(toolkit.getScreenSize().width+"x"+toolkit.getScreenSize().height);
      myFrame.setSize(1024, 600);
      myFrame.setJMenuBar(menuBar);
      myFrame.addWindowListener(new WindowClose());
      myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      myFrame.setVisible(true);
      Dimension panelDim = myFrame.getRootPane().getSize();
      // myFrame.add(newSubPanel);
      for (int i = 0; i < 3; i++) {
        if (i == 0) {
          newSubs = new DoublePanelStack(new NewSubVideoPanel(panelDim));
          myFrame.add(newSubs.getCurrentPanel());
          myFrame.validate();
          myFrame.repaint();
        }
        if (StatCol.newsubsStartIndex < StatCol.MAXNEWSUBVIDEOS)
          newSubs.add(new NewSubVideoPanel(panelDim));
      }
      // u.init();
      // sub2 = new NewSubVideoPanel(newSubPanel.init(),panelDim);
      myFrame.validate();
      // myFrame.pack();

    } catch (AuthenticationException e) {
      e.printStackTrace();
    } catch (MalformedURLException e) {
      e.printStackTrace();
    } catch (ServiceException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
Ejemplo n.º 17
0
  private void initMenu() {

    menuBar = new JMenuBar();
    frmVisualizadord.setJMenuBar(menuBar);

    mnArchivo = new JMenu("Archivo");
    menuBar.add(mnArchivo);

    mntmCargarArchivo = new JMenuItem("Cargar Archivo");
    mntmCargarArchivo.setIcon(new ImageIcon(Visualizador3D.class.getResource("/icon/open.png")));
    mntmCargarArchivo.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_MASK));
    mntmCargarArchivo.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            abrirArchivo();
          }
        });
    mnArchivo.add(mntmCargarArchivo);

    mntmGuardarComo = new JMenuItem("Guardar Como");
    mntmGuardarComo.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            guardarImagenComo();
          }
        });
    mntmGuardarComo.setIcon(new ImageIcon(Visualizador3D.class.getResource("/icon/save.png")));
    mntmGuardarComo.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK));
    mnArchivo.add(mntmGuardarComo);

    separator = new JSeparator();
    mnArchivo.add(separator);

    mntmSalir = new JMenuItem("Salir");
    mntmSalir.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            frmVisualizadord.dispose();
          }
        });
    mntmSalir.setIcon(new ImageIcon(Visualizador3D.class.getResource("/icon/close.png")));
    mntmSalir.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, InputEvent.ALT_MASK));
    mnArchivo.add(mntmSalir);

    mnAyuda = new JMenu("Ayuda");
    menuBar.add(mnAyuda);

    mntmAcercaDe = new JMenuItem("Acerca De");
    mntmAcercaDe.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            AcercaDe acercaDe = new AcercaDe();
            acercaDe.setVisible(true);
          }
        });
    mntmAcercaDe.setIcon(new ImageIcon(Visualizador3D.class.getResource("/icon/about.png")));
    mnAyuda.add(mntmAcercaDe);
  }
Ejemplo n.º 18
0
  public void start() {
    menu.setMnemonic('f');
    submenu.setMnemonic('m');
    menu.add(submenu);
    submenu.add(item);
    bar.add(menu);
    frame.setJMenuBar(bar);
    frame.pack();

    item.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            Sysout.println(e.toString());
            synchronized (activated) {
              activated.set(true);
              activated.notifyAll();
            }
          }
        });

    frame.setVisible(true);
    Util.waitForIdle(robot);

    boolean isMacOSX = (OSInfo.getOSType() == OSInfo.OSType.MACOSX);
    if (isMacOSX) {
      robot.keyPress(KeyEvent.VK_CONTROL);
      robot.delay(20);
    }
    robot.keyPress(KeyEvent.VK_ALT);
    robot.delay(20);
    robot.keyPress(KeyEvent.VK_F);
    robot.delay(20);
    robot.keyRelease(KeyEvent.VK_F);
    robot.delay(20);
    robot.keyRelease(KeyEvent.VK_ALT);
    if (isMacOSX) {
      robot.keyRelease(KeyEvent.VK_CONTROL);
      robot.delay(20);
    }
    Util.waitForIdle(robot);

    robot.keyPress(KeyEvent.VK_M);
    robot.delay(20);
    robot.keyRelease(KeyEvent.VK_M);
    Util.waitForIdle(robot);

    robot.keyPress(KeyEvent.VK_SPACE);
    robot.delay(20);
    robot.keyRelease(KeyEvent.VK_SPACE);
    Util.waitForIdle(robot);

    if (!Util.waitForCondition(activated, 2000)) {
      throw new TestFailedException("a submenu wasn't activated by mnemonic key press");
    }

    Sysout.println("Test passed.");
  }
  public static void main(String[] args) {
    final Pizza pizza = new Pizza("Margherita", 4);
    Pizza pizza2 = new Pizza("Napoli", 5);
    Pizza pizza3 = new Pizza("Prosciutto", 4.5);
    pizzeria.aggiungiPizza(pizza);
    pizzeria.aggiungiPizza(pizza2);
    pizzeria.aggiungiPizza(pizza3);
    final JButton calcolaButton = new JButton("Calcola");
    JMenuBar jMenuBar = new JMenuBar();
    JMenu menu = new JMenu("Seleziona quantità");
    JMenu menu2 = new JMenu("Seleziona pizza");
    JMenu menu3 = new JMenu("Strumenti");
    JMenuItem pulisci = new JMenuItem("Pulisci");
    menu3.add(pulisci);
    inserisciJMenuteItemQuantità();
    inserisciJMenuItemPizze();
    impostaMenuQuantità(menu);
    impostaMenuPizze(menu2);
    jMenuBar.add(menu);
    jMenuBar.add(menu2);
    jMenuBar.add(menu3);
    selezionaMenuQuantità(0);
    selezionaMenuQuantità(1);
    selezionaMenuQuantità(2);
    selezionaMenuQuantità(3);
    impostaSelezionaPizze();
    area.setEditable(false);
    pulisci.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            area.setText(newLine);
            totale = 0;
          }
        });
    calcolaButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            totale = cassaPizzeria.calcolaConto();
            area.append(newLine);
            area.append("Totale " + totale + " Euro");
            System.out.println(totale);
            totale = 0;
          }
        });
    JFrame frame = new JFrame("Pizzeria");
    frame.setSize(500, 500);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setJMenuBar(jMenuBar);
    frame.add(calcolaButton, BorderLayout.SOUTH);
    frame.add(area, BorderLayout.CENTER);
    frame.setVisible(true);
  }
Ejemplo n.º 20
0
Archivo: Tiny.java Proyecto: srnsw/xena
 /**
  * Creates and configures a frame, builds the menu bar, builds the content, locates the frame on
  * the screen, and finally shows the frame.
  */
 private void buildInterface() {
   JFrame frame = new JFrame();
   frame.setJMenuBar(buildMenuBar());
   frame.setContentPane(buildContentPane());
   frame.setSize(600, 400);
   locateOnScreen(frame);
   frame.setTitle("JGoodies :: Tiny");
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setVisible(true);
 }
Ejemplo n.º 21
0
 protected void deleteMenuBar(final JFrame f) {
   f.setJMenuBar(null);
   // HACK - w/o this next call the JMenuBars do not get garbage collected.
   // At least its true on the Mac. This might be a Java bug. Update:
   // I hunted on web and have found multiple people with the same problem.
   // The Apple ScreenMenus don't GC when a Frame disposes. Their workaround
   // was exactly the same. I have not found any official documentation of
   // this issue.
   f.setMenuBar(null);
 }
Ejemplo n.º 22
0
  /** @param args the command line arguments */
  public static void main(String[] args) {
    JFrame frame = new JFrame("Editing and Mouse Menu Demo");
    SparseMultigraph<GraphElements.MyVertex, GraphElements.MyEdge> g =
        new SparseMultigraph<GraphElements.MyVertex, GraphElements.MyEdge>();
    // Layout<V, E>, VisualizationViewer<V,E>
    //        Map<GraphElements.MyVertex,Point2D> vertexLocations = new
    // HashMap<GraphElements.MyVertex, Point2D>();
    Layout<GraphElements.MyVertex, GraphElements.MyEdge> layout = new StaticLayout(g);
    layout.setSize(new Dimension(300, 300));
    VisualizationViewer<GraphElements.MyVertex, GraphElements.MyEdge> vv =
        new VisualizationViewer<GraphElements.MyVertex, GraphElements.MyEdge>(layout);
    vv.setPreferredSize(new Dimension(350, 350));
    // Show vertex and edge labels
    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
    vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller());
    // Create a graph mouse and add it to the visualization viewer
    EditingModalGraphMouse gm =
        new EditingModalGraphMouse(
            vv.getRenderContext(),
            GraphElements.MyVertexFactory.getInstance(),
            GraphElements.MyEdgeFactory.getInstance());
    // Set some defaults for the Edges...
    GraphElements.MyEdgeFactory.setDefaultCapacity(192.0);
    GraphElements.MyEdgeFactory.setDefaultWeight(5.0);
    // Trying out our new popup menu mouse plugin...
    PopupVertexEdgeMenuMousePlugin myPlugin = new PopupVertexEdgeMenuMousePlugin();
    // Add some popup menus for the edges and vertices to our mouse plugin.
    JPopupMenu edgeMenu = new MyMouseMenus.EdgeMenu(frame);
    JPopupMenu vertexMenu = new MyMouseMenus.VertexMenu();
    myPlugin.setEdgePopup(edgeMenu);
    myPlugin.setVertexPopup(vertexMenu);
    gm.remove(gm.getPopupEditingPlugin()); // Removes the existing popup editing plugin

    gm.add(myPlugin); // Add our new plugin to the mouse

    vv.setGraphMouse(gm);

    // JFrame frame = new JFrame("Editing and Mouse Menu Demo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(vv);

    // Let's add a menu for changing mouse modes
    JMenuBar menuBar = new JMenuBar();
    JMenu modeMenu = gm.getModeMenu();
    modeMenu.setText("Mouse Mode");
    modeMenu.setIcon(null); // I'm using this in a main menu
    modeMenu.setPreferredSize(new Dimension(80, 20)); // Change the size so I can see the text

    menuBar.add(modeMenu);
    frame.setJMenuBar(menuBar);
    gm.setMode(ModalGraphMouse.Mode.EDITING); // Start off in editing mode
    frame.pack();
    frame.setVisible(true);
  }
Ejemplo n.º 23
0
  public Kayttoliittyma(Sovelluslogiikka logiikka) {
    this.logiikka = logiikka;

    frame = new JFrame("Aritmetiikkaharjoittelu");

    frame.setPreferredSize(new Dimension(400, 600));
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    luoKomponentit(frame.getContentPane());
    frame.setJMenuBar(menubar());
  }
Ejemplo n.º 24
0
  /* Create and show the graphical user interface. */
  private static void createAndShowGUI() {
    JFrame frame = new JFrame("My Collapsing Puzzle");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Game game = new Game();
    frame.setJMenuBar(game.createMenuBar());
    frame.setContentPane(game.createContentPane());
    frame.setSize(game.getGameSize());

    frame.setVisible(true);
  }
 /**
  * This method initializes jFrame
  *
  * @return javax.swing.JFrame
  */
 private JFrame getJFrame() {
   if (jFrame == null) {
     jFrame = new JFrame();
     jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     jFrame.setJMenuBar(getJJMenuBar());
     jFrame.setSize(300, 200);
     jFrame.setContentPane(getJContentPane());
     jFrame.setTitle("MainFrameBeispiel");
   }
   return jFrame;
 }
Ejemplo n.º 26
0
  private void menu() {
    JMenuBar menuBar = new JMenuBar();
    ChessMenuListener listener = new ChessMenuListener(board);

    JMenu menu = new JMenu("File");
    menu.setMnemonic(KeyEvent.VK_F);

    JMenuItem open = new JMenuItem("Open");
    open.setMnemonic(KeyEvent.VK_O);

    JMenuItem save = new JMenuItem("Save");
    save.setMnemonic(KeyEvent.VK_S);

    JMenuItem newGame = new JMenuItem("New");
    newGame.setMnemonic(KeyEvent.VK_N);
    newGame.addActionListener(listener);

    JMenuItem quit = new JMenuItem("Quit");
    quit.setMnemonic(KeyEvent.VK_Q);

    menu.add(newGame);
    menu.add(open);
    menu.add(save);
    menu.addSeparator();
    menu.add(quit);

    menuBar.add(menu);

    frame.setJMenuBar(menuBar);

    // Menu section 2

    JMenu menu2 = new JMenu("Options");
    menu2.setMnemonic(KeyEvent.VK_O);

    JMenuItem rollback = new JMenuItem("Play From View");
    JMenuItem edit = new JMenuItem("Edit View");

    JCheckBoxMenuItem bAI = new JCheckBoxMenuItem("Black AI");
    JCheckBoxMenuItem wAI = new JCheckBoxMenuItem("White AI");

    JCheckBoxMenuItem show = new JCheckBoxMenuItem("Show Moves");
    JCheckBoxMenuItem timer = new JCheckBoxMenuItem("Timer");

    menu2.add(rollback);
    menu2.add(edit);
    menu2.add(bAI);
    menu2.add(wAI);
    menu2.add(show);
    menu2.add(timer);

    menuBar.add(menu2);
  }
Ejemplo n.º 27
0
  public ConsoleWindow() {
    if (gui) {
      window = new JFrame("Package Tracking Console");
      window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
      window.setSize((int) (screenSize.getWidth() / 4), (int) (screenSize.getHeight() / 1.5));
      window.setLocationRelativeTo(null);
      window.getContentPane().setLayout(new BorderLayout());

      menuBar = new JMenuBar();
      menuBar.add("test", new JLabel("Testing"));
      window.setJMenuBar(menuBar);

      StyleContext sc = new StyleContext();
      document = new DefaultStyledDocument(sc);

      // Styles

      send = sc.addStyle("(Send)", null);
      send.addAttribute(StyleConstants.Foreground, Color.CYAN);

      info = sc.addStyle("(Info)", null);
      info.addAttribute(StyleConstants.Foreground, Color.WHITE);

      warning = sc.addStyle("(Warning)", null);
      warning.addAttribute(StyleConstants.Foreground, Color.YELLOW);

      error = sc.addStyle("(Error)", null);
      error.addAttribute(StyleConstants.Foreground, Color.RED);
      error.addAttribute(StyleConstants.Bold, new Boolean(true));

      textArea = new JTextPane(document);
      textArea.setBackground(new Color(50, 50, 50));
      textArea.setEditable(true);
      textArea.setBorder(null);
      textArea.setForeground(Color.WHITE);

      scrollPane = new JScrollPane(textArea);
      new SmartScroller(scrollPane);

      window.getContentPane().add(scrollPane);

      input = new JTextField();
      input.setBackground(new Color(50, 50, 50));
      input.setForeground(Color.WHITE);
      input.setCaretColor(Color.WHITE);
      input.addActionListener(new test());
      window.getContentPane().add(input, BorderLayout.SOUTH);

      window.setVisible(true);
      info.addAttribute(StyleConstants.Foreground, Color.BLUE);
    }
  }
  private static void components() {
    Container c = frame.getContentPane();
    JMenuBar menuBar = new JMenuBar();
    frame.setJMenuBar(menuBar);

    // Aca voy agregando los distintos menus
    menuBar.add(new MenuArchivo());
    menuBar.add(new MenuProveedor());

    // Aca voy agregando los componentes
    c.add(new PanelCentral(), BorderLayout.CENTER);
    c.add(new PanelSur(), BorderLayout.SOUTH);
  }
Ejemplo n.º 29
-1
  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);
  }
Ejemplo n.º 30
-1
  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);

  }