1 package com.piratepete.dbpirate.ui; 2 3 import java.awt.Dimension ; 4 import java.awt.Toolkit ; 5 import java.awt.event.WindowEvent ; 6 import java.net.URL ; 7 8 import javax.swing.ImageIcon ; 9 import javax.swing.JFrame ; 10 import javax.swing.JOptionPane ; 11 import javax.swing.UIManager ; 12 import java.awt.*; 13 14 37 public class MainWindow extends JFrame { 38 39 private URL iPath; 40 41 42 43 public MainWindow(String title) 44 { 45 buildFrame(title); 46 } 47 48 public void buildFrame(String title) 49 { 50 51 this.setTitle(title); 52 iPath = this.getClass().getResource("/com/piratepete/dbpirate/ui/images/small_pirate.gif"); 53 54 Toolkit theKit = this.getToolkit(); Dimension wndSize = theKit.getScreenSize(); ImageIcon icon = new ImageIcon (iPath); 58 this.setBounds(wndSize.width/8, wndSize.height/8, (wndSize.width/8)*6, 59 (wndSize.height/8)*6); this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); this.setIconImage(icon.getImage()); 63 64 } 65 66 public void setPLAF() 67 { 68 try { 70 UIManager.setLookAndFeel(new com.incors.plaf.kunststoff.KunststoffLookAndFeel()); 71 UIManager.put("Desktop.background", new Color(174,174,222)); 73 UIManager.put("Table.font", new javax.swing.plaf.FontUIResource ("Tahoma",0,11)); 74 UIManager.put("List.font", new javax.swing.plaf.FontUIResource ("Tahoma",0,11)); 75 UIManager.put("FileChooserUI", "com.sun.java.swing.plaf.windows.WindowsFileChooserUI"); 76 UIManager.put("TextArea.font", new javax.swing.plaf.FontUIResource ("Tahoma",0,11)); 77 UIManager.put("TextField.font", new javax.swing.plaf.FontUIResource ("Tahoma",0,11)); 78 UIManager.put("TabbedPane.font", new javax.swing.plaf.FontUIResource ("Tahoma",1,11)); 79 UIManager.put("TitledBorder.font", new javax.swing.plaf.FontUIResource ("Tahoma",1,11)); 80 UIManager.put("Menu.font", new javax.swing.plaf.FontUIResource ("Tahoma",0,11)); 81 UIManager.put("MenuItem.font", new javax.swing.plaf.FontUIResource ("Tahoma",0,11)); 82 UIManager.put("MenuBar.font", new javax.swing.plaf.FontUIResource ("Tahoma",0,11)); 83 UIManager.put("TableHeader.font", new javax.swing.plaf.FontUIResource ("Tahoma",1,10)); 84 UIManager.put("Button.font", new javax.swing.plaf.FontUIResource ("Tahoma",1,11)); 85 UIManager.put("Label.font", new javax.swing.plaf.FontUIResource ("Tahoma",1,11)); 86 UIManager.put("PopupMenu.font", new javax.swing.plaf.FontUIResource ("Tahoma",0,11)); 87 UIManager.put("Panel.font", new javax.swing.plaf.FontUIResource ("Tahoma",1,11)); 88 UIManager.put("Viewport.font", new javax.swing.plaf.FontUIResource ("Tahoma",1,11)); 89 UIManager.put("Table.selectionBackground", new Color(153,153,255)); 90 UIManager.put("TabbedPane.focus", new Color(0,0,255)); 91 UIManager.put("TabbedPane.shadow", new Color(153,153,255)); 92 UIManager.put("TabbedPane.darkshadow", new Color(200,200,200)); 93 UIManager.put("TabbedPane.selected", new Color(174,174,222)); 94 UIManager.put("TextArea.selectionBackground", new Color(153,153,255)); 95 UIManager.put("TextField.selectionBackground", new Color(153,153,255)); 96 97 } 99 catch (Exception e) 100 { 101 System.out.println(e); 102 } 103 } 104 105 public void Maximize() 106 { 107 super.setExtendedState(JFrame.MAXIMIZED_BOTH); } 109 110 protected void processWindowEvent(WindowEvent e) 111 { 112 if (e.getID() == WindowEvent.WINDOW_CLOSING) 113 { 114 int returnVal = JOptionPane.showConfirmDialog(this, "Would you like to exit?", "Exit DBPirate", 115 JOptionPane.YES_NO_OPTION); 116 117 if(returnVal == JOptionPane.YES_OPTION) 118 { 119 System.exit(0); 120 } 121 } 122 else 123 { 124 super.processWindowEvent(e); 125 } 126 } 127 128 129 } 130 | Popular Tags |