Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ramble_on.panels;
- import java.awt.BorderLayout;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.image.BufferedImage;
- import javax.swing.JComboBox;
- import javax.swing.JPanel;
- import mini_game.Sprite;
- import mini_game.SpriteType;
- import ramble_on.RambleOn;
- import ramble_on.events.WelcomeScreenHandler;
- public class SelectAccountPanel extends JPanel
- {
- private static final String IMAGES_PATH = "./data/images/";
- private static final String BACKGROUND_IMAGE_PATH = IMAGES_PATH + "selectAccount.png";
- private static final String SELECT_ACCOUNT_TYPE = "SELECT ACCOUNT TYPE";
- private static final String DEFAULT_STATE = "DEFAULT STATE";
- private JPanel flowPanel;
- private Sprite background;
- private RambleOn game;
- public SelectAccountPanel(RambleOn g)
- {
- super();
- game = g;
- SpriteType st = new SpriteType(SELECT_ACCOUNT_TYPE);
- BufferedImage img = game.loadImage(BACKGROUND_IMAGE_PATH);
- st.addState(DEFAULT_STATE, img);
- background = new Sprite(st,0,0,0,0, DEFAULT_STATE);
- //TODO add action listener
- //WelcomeScreenHandler wsh = new WelcomeScreenHandler(game);
- String[] accounts = {"Fred", "Joe", "Mike", "Jake"};
- JComboBox comboBox = new JComboBox(accounts);
- comboBox.setEditable(false);
- comboBox.setLocation(450, 450);
- // flowPanel = new JPanel();
- // flowPanel.add(comboBox);
- this.add(comboBox, BorderLayout.CENTER);
- // background.setActionListener(wsh);
- img = game.loadImage(BACKGROUND_IMAGE_PATH);
- game.getGUIDecor().put(SELECT_ACCOUNT_TYPE, background);
- }
- /**
- * This is where rendering starts. Note that the order of
- * rendering is of particular importance, since things drawn
- * first will be on the bottom, and things rendered last will
- * be on top.
- *
- * @param g the Graphics context for this panel. Draw commands
- * given through g will render things onto this panel.
- */
- @Override
- public void paintComponent(Graphics g)
- {
- renderToGraphicsContext(g);
- }
- private void renderToGraphicsContext(Graphics g)
- {
- Sprite img = game.getGUIDecor().get(SELECT_ACCOUNT_TYPE);
- renderSprite(g, img);
- }
- public String getType()
- {
- return SELECT_ACCOUNT_TYPE;
- }
- /**
- * Renders the s Sprite into the Graphics context g. Note
- * that each Sprite knows its own x,y coordinate location.
- *
- * @param g the Graphics context of this panel
- *
- * @param s the Sprite to be rendered
- */
- public void renderSprite(Graphics g, Sprite s)
- {
- //if (!s.getState().equals(INVISIBLE_STATE))
- {
- SpriteType bgST = s.getSpriteType();
- Image img = bgST.getStateImage(s.getState());
- g.drawImage(img, (int)s.getX(), (int)s.getY(),bgST.getWidth(), bgST.getHeight(), null);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement