public void paintComponent(java.awt.Graphics g) { super.paintComponent(g); _title.paint((Graphics2D) g, _title.getImage()); _newGame.paint((Graphics2D) g, _newGame.getImage()); _continue.paint((Graphics2D) g, _continue.getImage()); _quit.paint((Graphics2D) g, _quit.getImage()); }
public MainMenuScreen(DoodleTactics dt) { super(dt); this.setBackground(java.awt.Color.GRAY); BufferedImage titleD = dt.importImage("src/graphics/menu/title.png"); BufferedImage newGameD = dt.importImage("src/graphics/menu/new_game.png"); BufferedImage newGameH = dt.importImage("src/graphics/menu/new_game_hovered.png"); BufferedImage continueD = dt.importImage("src/graphics/menu/continue.png"); BufferedImage continueH = dt.importImage("src/graphics/menu/continue_hovered.png"); BufferedImage quitD = dt.importImage("src/graphics/menu/quit.png"); BufferedImage quitH = dt.importImage("src/graphics/menu/quit_hovered.png"); _title = new MenuItem(this, titleD, titleD, dt); _newGame = new ScreenChangeMenuItem(this, newGameD, newGameH, dt, dt.getGameScreen()); _continue = new LoadGameMenuItem(this, continueD, continueH, dt); _quit = new QuitMenuButton(this, quitD, quitH, dt); _title.setLocation( ((DoodleTactics.TILE_COLS * map.Tile.TILE_SIZE) - _title.getImage().getWidth()) / 2, 50); int offset = ((DoodleTactics.TILE_COLS * map.Tile.TILE_SIZE) - _newGame.getImage().getWidth()) / 2; _newGame.setLocation(offset, 250); _continue.setLocation(offset, 400); _quit.setLocation(offset, 550); _title.setVisible(true); _newGame.setVisible(true); _continue.setVisible(true); _quit.setVisible(true); }
public MenuItemFragment(MenuItem menuItem) { super("menuItemFragment", "MENU_ITEM_FRAGMENT", MenuPanel.this); setRenderBodyOnly(true); // add the menu's label (hyperlinked if a link is provided) if (menuItem.getLink() != null) { if (menuItem.getImage() != null) { if (menuItem.getLabel() != null) { add( new LinkImageTextFragment( menuItem.getLink(), menuItem.getImage(), menuItem.getLabel())); } else { add(new LinkImageFragment(menuItem.getLink(), menuItem.getImage())); } } else { add(new LinkFragment(menuItem.getLink(), menuItem.getLabel())); } } else { if (menuItem.getImage() != null) { if (menuItem.getLabel() == null) { add(new ImageFragment(menuItem.getImage())); } } else { add(new TextFragment(menuItem.getLabel())); } } WebMarkupContainer menuItemList = new WebMarkupContainer("menuItemList"); add(menuItemList); // hide the <ul> tag if there are no submenus menuItemList.setVisible(menuItem.getChildren().size() > 0); /* // add a down or right arrow icon if there are children if (menuItem.getChildren().size() > 0) { menuItem.getLabel().add(MENU_HAS_SUBMENU_APPENDER); } */ // add the submenus menuItemList.add(new SubMenuListView("menuItemLinks", menuItem.getChildren())); }