Esempio n. 1
0
 /**
  * Creates and shows an alert dialog.
  *
  * @param frame the parent frame. Can be null.
  * @param whatToSay the body of the dialog.
  * @param title the title of the dialog.
  * @param iconPath the icon's name (x.png)
  */
 public static void showDialog(JFrame frame, String whatToSay, String title, String iconPath) {
   JOptionPane.showMessageDialog(
       frame, // parent
       whatToSay, // text
       title, // title
       JOptionPane.INFORMATION_MESSAGE, // mesage type
       GUI.createImageIcon(iconPath) // icon
       );
 }
Esempio n. 2
0
  /**
   * Draws an emblem (based on current theme) in the bottom left of the given component. Call this
   * in paintComponent() of the component.
   *
   * @param component the component to draw on
   * @param g the Graphics object from paintComponent()
   */
  public static void drawEmblem(JComponent component, Graphics g) {
    Themes currentTheme = Themes.getCurrentTheme();
    ImageIcon image = GUI.createImageIcon("translucent/" + currentTheme.getImageIconPath());

    /*if(Themes.getCurrentTheme() == Themes.SNOW){
        image = GUI.createImageIcon("translucent/snow.png");
    }*/

    int imageWidth = image.getIconWidth();
    int imageHeight = image.getIconHeight();
    // top left corner of where to start drawing
    int topLeftX = component.getWidth() - imageWidth; // x (horizontal) coordinate
    int topLeftY = component.getHeight() - imageHeight; // y (vertical) coordinate

    // draw in bottom right corner
    g.drawImage(image.getImage(), topLeftX, topLeftY, (java.awt.image.ImageObserver) null);
    // g.drawImage(image.getImage(), 0,0, (java.awt.image.ImageObserver)null);
  }
Esempio n. 3
0
  /**
   * Uses a JEditorPane to open the given URL in a dialog
   *
   * @param url the url to load
   * @param title the title of the dialog
   * @param frame the parent frame
   * @param visible true if you want the dialog to be visible, false if you want it to be invisible
   *     to user
   * @param iconPath the path to the image icon for the dialog.
   */
  public static void openURLinDialog(
      String url, String title, String iconPath, JFrame frame, boolean visible) {
    // create panel with page in it
    final int WIDTH = 400;
    final int HEIGHT = 300;
    JPanel webView = createEditorPane(url, WIDTH, HEIGHT);

    // put it in a dialog
    JDialog dialog = new JDialog(frame);
    dialog.setTitle(title);
    dialog.setIconImage(GUI.createImageIcon(iconPath).getImage());
    dialog.setContentPane(webView);
    dialog.pack();
    dialog.setResizable(false);
    dialog.setModal(true);
    Utils.centerComponent(dialog, frame);

    // open it
    dialog.setVisible(visible);
  }
Esempio n. 4
0
 /**
  * Creates a new Theme.
  *
  * @param name the theme's name
  * @param imageIconPath the path to the image of the rank (usually "[name].png")
  * @param rankToUnlock the rank needed to unlock this rank
  */
 Themes(String name, String imageIconPath, Rank rankToUnlock) {
   this.name = name;
   this.imageIconPath = imageIconPath;
   this.image = GUI.createImageIcon(imageIconPath);
   this.rankToUnlock = rankToUnlock;
 }