Skip to content

IonFrame

Alex Gulko edited this page Jun 5, 2021 · 1 revision

IonFrame

Is the outer shell of your window. It extends JFrame, inheriting all its methods.

Cool things it can do:

  • Hide and reset the cursor
  • Go fullscreen (does not hide the window graphical frame, but will be able in future updates)
  • Redirect KeyEvents to use in behavior packs

Constructors:

IonFrame(int width, int height) - constructs a new frame with specified dimensions

IonFrame() - constructs a new frame with default dimensions of 500 x 500

Methods:

IonFrame setFullScreen(boolean state) - sets frame to full screen (if state is true) or to default (if state is false). Returns itself

IonFrame toggleFullScreen() - toggles the current full screen state. Returns itself

boolean getFullScreen() - returns true if in full screen mode, false instead

MenuBar addMenuBar() - adds a new MenuBar and returns it

MenuBar getMenuBar() - returns the menu bar. If the MenuBar was not added via the command above, returns null

Menu addMenu(String name) - adds and returns a new menu to the menu bar with a specified name. Returns it.

MenuItem[] addMenuItems(Menu menu, String[] itemNames, IonEventCaller eventCaller) - adds menu items to the menu with names specified in the itemNames array. adds eventCaller object as an eventListener. Menu item name is passed as the first parameter in the actionPerformed method of an eventCaller. Returns an array of menu items.

IonPanel addPanel(IonPanel newPanel) - adds a new IonPanel from the parameter, returns it

IonPanel addPanel() - creates a new default IonPanel and returns it

ArrayList<IonPanel> getPanelList() - returns an ArrayList of all added IonPanels

IonFrame hideCursor() - sets a transparent image to the cursor, making it invisible. Returns itself

IonFrame resetCursor() - resets the cursor to a default one. Returns itself

int getMiddleX() - returns the middle coordinate of the frame on x-axis (width / 2)

int getMiddleY() - returns the middle coordinate of the frame on y-axis (height / 2)

Robot robot() - initializes the robot on the first run and returns it every time

Useful methods extended from JFrame: void setVisible(boolean b) - displays the window if b is true, hides it instead void setTitle(String title) - sets the widow title

Example:

IonFrame frame = new IonFrame(518, 559);

    frame.setVisible(true);

    frame.setTitle("Paint");

    IonPanel panel = frame.addPanel();

Clone this wiki locally