Ejemplo n.º 1
0
 public static java.awt.Image loadImageFromFile(String path) {
   java.io.File file = new java.io.File(path);
   if (file.exists()) {
     java.awt.Toolkit tk = java.awt.Toolkit.getDefaultToolkit();
     java.awt.Image img = tk.createImage(path);
     try {
       java.awt.MediaTracker mt = new java.awt.MediaTracker(new javax.swing.JPanel());
       mt.addImage(img, 0);
       mt.waitForID(0);
     } catch (Exception ex) {
       return null;
     }
     return img;
   }
   return null;
 }
Ejemplo n.º 2
0
 public static void centerFrame(java.awt.Component c) {
   java.awt.Toolkit tk = java.awt.Toolkit.getDefaultToolkit();
   c.setLocation(
       (int) ((tk.getScreenSize().getWidth() - c.getWidth()) / 2),
       (int) ((tk.getScreenSize().getHeight() - c.getHeight()) / 2));
 }