void init() { mainFrame = new Frame(); mainFrame.setBounds(400, 500, 800, 600); mainFrame.setLayout(new FlowLayout()); mainFrame.setResizable(false); upPanel = new Panel(); downPanel = new Panel(); addressTextField = new TextField(75); gotoButton = new Button("转到"); contentTextArea = new TextArea(30, 82); upPanel.add(addressTextField); upPanel.add(gotoButton); downPanel.add(contentTextArea); mainFrame.add(upPanel); mainFrame.add(downPanel); addEvent(); mainFrame.setVisible(true); }
public CipherChatClient() { super("Cipher Chat Client"); // Establish keys for RSA cipher makeKeys(); // Lay out the components and display the frame setLayout(new GridLayout(2, 1)); top.setLayout(new GridLayout(3, 1)); add(top); bottom.setLayout(new GridLayout(1, 1)); add(bottom); connectButton.addActionListener(this); enterField.setEnabled(false); enterField.addActionListener(this); top.add(serverField); top.add(connectButton); top.add(enterField); bottom.add(displayArea); setSize(400, 300); show(); }
public babylonServerWindow(babylonServer parent, String Name) { super(Name); server = parent; myLayout = new GridBagLayout(); setLayout(myLayout); p = new Panel(); p.setLayout(myLayout); listening = new Label(server.strings.get(thisClass, "listenport") + " " + server.port); p.add( listening, new babylonConstraints( 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); logChat = new Checkbox(server.strings.get(thisClass, "logchats"), server.logChats); logChat.addItemListener(this); p.add( logChat, new babylonConstraints( 1, 0, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); userList = new List(4, false); userList.addItemListener(this); p.add( userList, new babylonConstraints( 0, 1, 1, 5, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0, 0, 5, 0), 0, 0)); userAdmin = new Button(server.strings.get(thisClass, "usermanagement")); userAdmin.addActionListener(this); p.add( userAdmin, new babylonConstraints( 1, 1, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); console = new Button(server.strings.get(thisClass, "adminclient")); console.addActionListener(this); p.add( console, new babylonConstraints( 1, 2, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); disconnect = new Button(server.strings.get(thisClass, "disconnectuser")); disconnect.setEnabled(false); disconnect.addActionListener(this); p.add( disconnect, new babylonConstraints( 1, 3, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); disconnectAll = new Button(server.strings.get(thisClass, "disconnectall")); disconnectAll.setEnabled(false); disconnectAll.addActionListener(this); p.add( disconnectAll, new babylonConstraints( 1, 4, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); shutdown = new Button(server.strings.get(thisClass, "shutdown")); shutdown.addActionListener(this); p.add( shutdown, new babylonConstraints( 1, 5, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); stats = new TextField( server.strings.get(thisClass, "connectionscurrent") + " 0 " + server.strings.get(thisClass, "connectionspeak") + " 0 " + server.strings.get(thisClass, "connectionstotal") + " 0", 40); stats.setEditable(false); p.add( stats, new babylonConstraints( 0, 7, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); logWindow = new TextArea( server.strings.get(thisClass, "activitylog") + "\n", 10, 40, TextArea.SCROLLBARS_VERTICAL_ONLY); logWindow.setEditable(false); p.add( logWindow, new babylonConstraints( 0, 8, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0, 0, 5, 0), 0, 0)); canvas = new babylonPictureCanvas(this); p.add( canvas, new babylonConstraints( 0, 9, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); add( p, new babylonConstraints( 0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); try { URL url = new URL("file", "localhost", "babylonPic.jpg"); Image image = getToolkit().getImage(url); canvas.setimage(image); } catch (Exception e) { System.out.println(e); } try { URL iconUrl = new URL("file", "localhost", "babylonIcon.jpg"); ImageIcon icon = new ImageIcon(iconUrl); this.setIconImage(icon.getImage()); } catch (Exception e) { /* Not important */ } addWindowListener(this); setSize(600, 600); pack(); }
public babylonServerShutdownDialog(babylonServerWindow serverWindow, babylonServer theServer) { super(serverWindow, theServer.strings.get(babylonServerWindow.class, "servershutdown"), true); parentWindow = serverWindow; server = theServer; myLayout = new GridBagLayout(); setLayout(myLayout); p = new Panel(); p.setLayout(myLayout); message1 = new Label(server.strings.get(babylonServerWindow.class, "areyousure1")); p.add( message1, new babylonConstraints( 0, 0, 2, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); message2 = new Label(server.strings.get(babylonServerWindow.class, "areyousure2")); p.add( message2, new babylonConstraints( 0, 1, 2, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); yes = new Button(server.strings.get(babylonServerWindow.class, "yes")); yes.addKeyListener(this); yes.addActionListener(this); p.add( yes, new babylonConstraints( 0, 2, 1, 1, 1.0, 1.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); cancel = new Button(server.strings.get("cancel")); cancel.addKeyListener(this); cancel.addActionListener(this); p.add( cancel, new babylonConstraints( 1, 2, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); add( p, new babylonConstraints( 0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); setBackground(Color.lightGray); pack(); setResizable(false); parentWindow.centerDialog(this); addKeyListener(this); addWindowListener(this); setVisible(true); yes.requestFocus(); }
/** * If 'applet' is not null, creates a new ImageJ frame that runs as an applet. If 'mode' is * ImageJ.EMBEDDED and 'applet is null, creates an embedded (non-standalone) version of ImageJ. */ public ImageJ(java.applet.Applet applet, int mode) { super("ImageJ"); if ((mode & DEBUG) != 0) IJ.setDebugMode(true); mode = mode & 255; if (IJ.debugMode) IJ.log("ImageJ starting in debug mode: " + mode); embedded = applet == null && (mode == EMBEDDED || mode == NO_SHOW); this.applet = applet; String err1 = Prefs.load(this, applet); setBackground(backgroundColor); Menus m = new Menus(this, applet); String err2 = m.addMenuBar(); m.installPopupMenu(this); setLayout(new BorderLayout()); // Tool bar toolbar = new Toolbar(); toolbar.addKeyListener(this); add("Center", toolbar); // Status bar statusBar = new Panel(); statusBar.setLayout(new BorderLayout()); statusBar.setForeground(Color.black); statusBar.setBackground(backgroundColor); statusLine = new JLabel(); statusLine.setFont(new Font("SansSerif", Font.PLAIN, 13)); statusLine.addKeyListener(this); statusLine.addMouseListener(this); statusBar.add("Center", statusLine); progressBar = new ProgressBar(120, 20); progressBar.addKeyListener(this); progressBar.addMouseListener(this); statusBar.add("East", progressBar); add("South", statusBar); IJ.init(this, applet); addKeyListener(this); addWindowListener(this); setFocusTraversalKeysEnabled(false); m.installStartupMacroSet(); // add custom tools runStartupMacro(); Point loc = getPreferredLocation(); Dimension tbSize = toolbar.getPreferredSize(); setCursor(Cursor.getDefaultCursor()); // work-around for JDK 1.1.8 bug if (mode != NO_SHOW) { if (IJ.isWindows()) try { setIcon(); } catch (Exception e) { } setLocation(loc.x, loc.y); setResizable(!IJ.isMacOSX()); pack(); setVisible(true); } if (err1 != null) IJ.error(err1); if (err2 != null) { IJ.error(err2); IJ.runPlugIn("ij.plugin.ClassChecker", ""); } if (IJ.isMacintosh() && applet == null) { Object qh = null; qh = IJ.runPlugIn("MacAdapter", ""); if (qh == null) IJ.runPlugIn("QuitHandler", ""); } if (applet == null) IJ.runPlugIn("ij.plugin.DragAndDrop", ""); String str = m.getMacroCount() == 1 ? " macro" : " macros"; IJ.showStatus(version() + m.getPluginCount() + " commands; " + m.getMacroCount() + str); configureProxy(); if (applet == null) loadCursors(); }
/** * If 'applet' is not null, creates a new ImageJ frame that runs as an applet. If 'mode' is * ImageJ.EMBEDDED and 'applet is null, creates an embedded (non-standalone) version of ImageJ. */ public ImageJ(java.applet.Applet applet, int mode) { super("ImageJ"); embedded = applet == null && (mode == EMBEDDED || mode == NO_SHOW); this.applet = applet; String err1 = Prefs.load(this, applet); if (IJ.isLinux()) { backgroundColor = new Color(240, 240, 240); setBackground(backgroundColor); } Menus m = new Menus(this, applet); String err2 = m.addMenuBar(); m.installPopupMenu(this); setLayout(new GridLayout(2, 1)); // Tool bar toolbar = new Toolbar(); toolbar.addKeyListener(this); add(toolbar); // Status bar statusBar = new Panel(); statusBar.setLayout(new BorderLayout()); statusBar.setForeground(Color.black); statusBar.setBackground(backgroundColor); statusLine = new Label(); statusLine.setFont(SansSerif12); statusLine.addKeyListener(this); statusLine.addMouseListener(this); statusBar.add("Center", statusLine); progressBar = new ProgressBar(120, 20); progressBar.addKeyListener(this); progressBar.addMouseListener(this); statusBar.add("East", progressBar); statusBar.setSize(toolbar.getPreferredSize()); add(statusBar); IJ.init(this, applet); addKeyListener(this); addWindowListener(this); setFocusTraversalKeysEnabled(false); Point loc = getPreferredLocation(); Dimension tbSize = toolbar.getPreferredSize(); int ijWidth = tbSize.width + 10; int ijHeight = 100; setCursor(Cursor.getDefaultCursor()); // work-around for JDK 1.1.8 bug if (mode != NO_SHOW) { if (IJ.isWindows()) try { setIcon(); } catch (Exception e) { } setBounds(loc.x, loc.y, ijWidth, ijHeight); // needed for pack to work setLocation(loc.x, loc.y); pack(); setResizable(!(IJ.isMacintosh() || IJ.isWindows())); // make resizable on Linux show(); } if (err1 != null) IJ.error(err1); if (err2 != null) { IJ.error(err2); IJ.runPlugIn("ij.plugin.ClassChecker", ""); } m.installStartupMacroSet(); if (IJ.isMacintosh() && applet == null) { Object qh = null; qh = IJ.runPlugIn("MacAdapter", ""); if (qh == null) IJ.runPlugIn("QuitHandler", ""); } if (applet == null) IJ.runPlugIn("ij.plugin.DragAndDrop", ""); String str = m.getMacroCount() == 1 ? " macro" : " macros"; IJ.showStatus(version() + m.getPluginCount() + " commands; " + m.getMacroCount() + str); // if (applet==null && !embedded && Prefs.runSocketListener) // new SocketListener(); configureProxy(); if (applet == null) loadCursors(); }
/** * Create a new MailClient window with fields for entering all the relevant information (From, To, * Subject, and message). */ public MailClient() { super("Java Mailclient"); /* Create panels for holding the fields. To make it look nice, create an extra panel for holding all the child panels. */ Panel serverPanel = new Panel(new BorderLayout()); Panel fromPanel = new Panel(new BorderLayout()); Panel toPanel = new Panel(new BorderLayout()); Panel subjectPanel = new Panel(new BorderLayout()); Panel messagePanel = new Panel(new BorderLayout()); serverPanel.add(serverLabel, BorderLayout.WEST); serverPanel.add(serverField, BorderLayout.CENTER); fromPanel.add(fromLabel, BorderLayout.WEST); fromPanel.add(fromField, BorderLayout.CENTER); toPanel.add(toLabel, BorderLayout.WEST); toPanel.add(toField, BorderLayout.CENTER); subjectPanel.add(subjectLabel, BorderLayout.WEST); subjectPanel.add(subjectField, BorderLayout.CENTER); messagePanel.add(messageLabel, BorderLayout.NORTH); messagePanel.add(messageText, BorderLayout.CENTER); Panel fieldPanel = new Panel(new GridLayout(0, 1)); fieldPanel.add(serverPanel); fieldPanel.add(fromPanel); fieldPanel.add(toPanel); fieldPanel.add(subjectPanel); /* Create a panel for the buttons and add listeners to the buttons. */ Panel buttonPanel = new Panel(new GridLayout(1, 0)); btSend.addActionListener(new SendListener()); btClear.addActionListener(new ClearListener()); btQuit.addActionListener(new QuitListener()); buttonPanel.add(btSend); buttonPanel.add(btClear); buttonPanel.add(btQuit); /* Add, pack, and show. */ add(fieldPanel, BorderLayout.NORTH); add(messagePanel, BorderLayout.CENTER); add(buttonPanel, BorderLayout.SOUTH); pack(); setVisible(true); }