1 10 package org.jgap.gui; 11 12 import java.util.*; 13 14 import javax.swing.*; 15 16 import org.jgap.*; 17 import org.jgap.data.config.*; 18 19 30 public class GUIManager { 31 32 private final static String CVS_REVISION = "$Revision: 1.10 $"; 33 34 private ConfigFrame m_frame; 36 37 private List m_childFrames; 39 40 private List m_childCons; 42 43 private Configurable m_con; 45 46 49 private static GUIManager m_gm; 50 51 57 public static GUIManager getInstance() { 58 if (m_gm == null) { 59 m_gm = new GUIManager(); 60 } 61 return m_gm; 62 } 63 64 70 private GUIManager() { 71 m_frame = null; 72 m_childFrames = Collections.synchronizedList(new ArrayList()); 73 m_childCons = Collections.synchronizedList(new ArrayList()); 74 } 75 76 83 public void showFrame(final ConfigFrame a_parent, final Configurable a_con) 84 throws Exception { 85 try { 86 88 if (a_con.getClass() == Configuration.class) { 90 m_frame = new ConfigFrame(null, "JGAP Configurator: " 91 + "Configuration", 92 true); 93 m_con = a_con; 94 m_frame.createAndShowGUI(a_con); 95 } 96 else { 97 ConfigFrame tmpFrame = 98 new ConfigFrame(a_parent, "JGAP Configurator: " 99 + "Unknown Title", 100 false); 101 m_childCons.add(a_con); 102 m_childFrames.add(tmpFrame); 103 tmpFrame.createAndShowGUI(a_con); 104 } 105 } 106 catch (Exception ex) { 107 JOptionPane.showMessageDialog(null, 108 "Could not show configuration frame. This" 109 + " attribute may not be configurable.", 110 "Configuration Error", 111 JOptionPane.INFORMATION_MESSAGE); 112 } 113 } 114 115 123 public static void main(String [] args) { 124 try { 125 SwingUtilities.invokeLater(new Runnable () { 126 public void run() { 127 Configuration con = new Configuration(); 128 try { 130 GUIManager.getInstance().showFrame(null, con); 131 } 132 catch (Exception ex) { 133 } 134 } 135 }); 136 } 137 catch (Exception ex) { 138 ex.printStackTrace(); 139 } 140 } 141 } 142 | Popular Tags |