public AddLayerDialog(String title, Document document) { super(title); this.document = document; Panel buttons = new Panel(); buttons.add("East", ok = new Button("OK")); buttons.add("West", cancel = new Button("Cancel")); // add("Center", text = new TextArea()); add("South", buttons); }
public void init(GUI gui) { m_gui = gui; // Create the display // width, height addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { dispose(); } }); setSize(new Dimension(100, 100)); setBackground(Color.white); setFont(new Font("Helvetica", Font.PLAIN, 14)); GridBagLayout gridbag = new GridBagLayout(); setLayout(gridbag); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.weightx = 1.0; recency = new TextField(Truline.userProps.getProperty("RecencyDays", "28"), 5); setRow(c, gridbag, new Label("Recency Days"), recency); maxdays = new TextField(Truline.userProps.getProperty("MaxDays", "120"), 5); setRow(c, gridbag, new Label("Max Days"), maxdays); maxvariant = new TextField(Truline.userProps.getProperty("MaxVariant", "25"), 5); setRow(c, gridbag, new Label("Max Variant"), maxvariant); maiden = new TextField(Truline.userProps.getProperty("UseMaiden", "Y"), 2); setRow(c, gridbag, new Label("Use Maiden"), maiden); betFactorVersion = new TextField(Truline.userProps.getProperty("BetFactorVersion", " "), 7); setRow(c, gridbag, new Label("Bet Factor Version"), betFactorVersion); datadir = new TextField(Truline.userProps.getProperty("DATADIR", "."), 40); setRow(c, gridbag, new Label("Data Directory"), datadir); fontsize = new TextField(Truline.userProps.getProperty("FontSize", "8"), 40); setRow(c, gridbag, new Label("Print Font Size (8,9,10)"), fontsize); printProgram = new TextField(Truline.userProps.getProperty("PrintProgram", "WordPad.exe /p"), 40); setRow(c, gridbag, new Label("Print program"), printProgram); // shell = new TextField(Truline.userProps.getProperty("Shell", "command"), // 40); // setRow(c, gridbag, new Label("Shell program"), shell); Panel panel1 = new Panel(); panel1.setLayout(new BorderLayout()); Button OKButton = new Button(" OK "); OKButton.setActionCommand("ok"); OKButton.addActionListener(this); panel1.add(OKButton, BorderLayout.CENTER); Panel panel2 = new Panel(); panel2.setLayout(new BorderLayout()); Button cancelButton = new Button("Cancel"); cancelButton.setActionCommand("cancel"); cancelButton.addActionListener(this); panel2.add(cancelButton, BorderLayout.CENTER); setRow(c, gridbag, panel2, panel1); pack(); show(); }
protected void createTools(Panel palette) { super.createTools(palette); Tool tool = new TextTool(view(), new NodeFigure()); palette.add(createToolButton(IMAGES + "TEXT", "Text Tool", tool)); tool = new CreationTool(view(), new NodeFigure()); palette.add(createToolButton(IMAGES + "RECT", "Create Org Unit", tool)); tool = new ConnectionTool(view(), new LineConnection()); palette.add(createToolButton(IMAGES + "CONN", "Connection Tool", tool)); }
/** Constructor for the test program's window. */ public Demo() { super("HardcopyWriter Test"); // Call frame constructor Panel p = new Panel(); // Add a panel to the frame this.add(p, "Center"); // Center it p.setFont( new Font( "SansSerif", // Set a default font Font.BOLD, 18)); print = new Button("Print Test Page"); // Create a Print button quit = new Button("Quit"); // Create a Quit button print.addActionListener(this); // Specify that we'll handle quit.addActionListener(this); // button presses p.add(print); // Add the buttons to the panel p.add(quit); this.pack(); // Set the size of everything }
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(); }
Board() { addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { exit(); } }); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); setSize(screenSize); setLocation(0, 0); r3 = Math.sqrt(3); Button ng, eg, ab; ng = new Button("New Game"); eg = new Button("Exit Game"); ab = new Button("About"); gold = new ImageIcon("./coin2.jpg").getImage(); silver = new ImageIcon("./coin1.jpg").getImage(); Panel pan = new Panel(); pan.setLayout(new FlowLayout()); pan.add(ng); pan.add(eg); pan.add(ab); setLayout(new BorderLayout()); add(pan, BorderLayout.NORTH); newGame(); ng.addActionListener(this); eg.addActionListener(this); ab.addActionListener(this); addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { int mx = e.getX(), my = e.getY(); place(mx, my); } }); }
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(); }
RecordingFrame(VncViewer v) { super("Teambox Screen Sharing Session Recording"); viewer = v; // Determine initial filename for next saved session. // FIXME: Check SecurityManager. String fname = nextNewFilename( System.getProperty("user.dir") + System.getProperty("file.separator") + "vncsession.fbs"); // Construct new panel with file name field and "Browse" button. Panel fnamePanel = new Panel(); GridBagLayout fnameGridbag = new GridBagLayout(); fnamePanel.setLayout(fnameGridbag); GridBagConstraints fnameConstraints = new GridBagConstraints(); fnameConstraints.gridwidth = GridBagConstraints.RELATIVE; fnameConstraints.fill = GridBagConstraints.BOTH; fnameConstraints.weightx = 4.0; fnameField = new TextField(fname, 64); fnameGridbag.setConstraints(fnameField, fnameConstraints); fnamePanel.add(fnameField); fnameField.addActionListener(this); fnameConstraints.gridwidth = GridBagConstraints.REMAINDER; fnameConstraints.weightx = 1.0; browseButton = new Button("Browse"); fnameGridbag.setConstraints(browseButton, fnameConstraints); fnamePanel.add(browseButton); browseButton.addActionListener(this); // Construct the frame. GridBagLayout gridbag = new GridBagLayout(); setLayout(gridbag); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.BOTH; gbc.weighty = 1.0; gbc.insets = new Insets(10, 0, 0, 0); Label helpLabel = new Label("File name to save next recorded session in:", Label.CENTER); gridbag.setConstraints(helpLabel, gbc); add(helpLabel); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weighty = 0.0; gbc.insets = new Insets(0, 0, 0, 0); gridbag.setConstraints(fnamePanel, gbc); add(fnamePanel); gbc.fill = GridBagConstraints.BOTH; gbc.weighty = 1.0; gbc.insets = new Insets(10, 0, 10, 0); statusLabel = new Label("", Label.CENTER); gridbag.setConstraints(statusLabel, gbc); add(statusLabel); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weightx = 1.0; gbc.weighty = 0.0; gbc.gridwidth = 1; gbc.insets = new Insets(0, 0, 0, 0); recordButton = new Button("Record"); gridbag.setConstraints(recordButton, gbc); add(recordButton); recordButton.addActionListener(this); nextButton = new Button("Next file"); gridbag.setConstraints(nextButton, gbc); add(nextButton); nextButton.addActionListener(this); closeButton = new Button("Close"); gridbag.setConstraints(closeButton, gbc); add(closeButton); closeButton.addActionListener(this); // Set correct text, font and color for the statusLabel. stopRecording(); pack(); addWindowListener(this); }
public void init() { try { // data init loginId.setText("" + cfg.REQPARAM_SRC_LOGIN_ID); password.setText("" + cfg.REQPARAM_SRC_PASSWORD); // ui init setLayout(new GridLayout(2, 1)); Panel inputArea = new Panel(new BorderLayout(2, 2)); inputArea.add(contactList, "Center"); Panel bottomR = new Panel(new FlowLayout(FlowLayout.RIGHT)); bottomR.add(loginBtn); bottomR.add(logoutBtn); bottomR.add(closeBtn); Panel bottomL = new Panel(new FlowLayout()); bottomL.add(new Label("status:")); bottomL.add(clientStatus); bottomL.add(new Label(" contact:")); bottomL.add(contactListEntry); bottomL.add(addToContactList); bottomL.add(removeFromContactList); bottomL.add(getUserDetailsButton()); bottomL.add(getSendContactsButton()); Panel bottom = new Panel(new BorderLayout()); bottom.add("Center", bottomR); bottom.add("West", bottomL); inputArea.add(bottom, "South"); Panel leftTop = new Panel(new GridLayout(10, 1)); leftTop.add(new Label("login id:")); // 1 leftTop.add(loginId); // 2 leftTop.add(new Label("password:"******"")); leftTop.add(new Label("")); // 6 leftTop.add(new Label("send msg")); leftTop.add(sendMsg); // 8 leftTop.add(new Label("to")); leftTop.add(dstLoginId); // 10 Panel left = new Panel(new FlowLayout()); left.add(leftTop); inputArea.add(left, "West"); Panel eventLogPanel = new Panel(new BorderLayout()); eventLogPanel.add("Center", eventLog); Panel eventLogPanelButtons = new Panel(new FlowLayout(FlowLayout.RIGHT)); eventLogPanelButtons.add(clearEventLogBtn); eventLogPanel.add("South", eventLogPanelButtons); add(inputArea); add(eventLogPanel); setBackground(SystemColor.control); doLayout(); sendMsg.requestFocus(); } catch (Throwable tr) { CAT.error("exception", tr); System.exit(1); } }
/** * 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(); }
paintboard1(String s) { super(s); addMouseMotionListener(this); addMouseListener(this); paintInfo = new Vector(); /* 各工具按钮及选择项 */ // 颜色选择 ColChoice = new Choice(); ColChoice.add("black"); ColChoice.add("red"); ColChoice.add("blue"); ColChoice.add("green"); ColChoice.addItemListener(this); // 画笔大小选择 SizeChoice = new Choice(); SizeChoice.add("1"); SizeChoice.add("3"); SizeChoice.add("5"); SizeChoice.add("7"); SizeChoice.add("9"); SizeChoice.addItemListener(this); // 橡皮大小选择 EraserChoice = new Choice(); EraserChoice.add("5"); EraserChoice.add("9"); EraserChoice.add("13"); EraserChoice.add("17"); EraserChoice.addItemListener(this); // ////////////////////////////////////////////////// toolPanel = new Panel(); clear = new Button("清除"); eraser = new Button("橡皮"); pen = new Button("画笔"); drLine = new Button("画直线"); drCircle = new Button("画圆形"); drRect = new Button("画矩形"); openPic = new Button("打开图画"); savePic = new Button("保存图画"); colchooser = new Button("显示调色板"); // 各组件事件监听 clear.addActionListener(this); eraser.addActionListener(this); pen.addActionListener(this); drLine.addActionListener(this); drCircle.addActionListener(this); drRect.addActionListener(this); openPic.addActionListener(this); savePic.addActionListener(this); colchooser.addActionListener(this); 颜色 = new Label("画笔颜色", Label.CENTER); 大小B = new Label("画笔大小", Label.CENTER); 大小E = new Label("橡皮大小", Label.CENTER); // 面板添加组件 toolPanel.add(openPic); toolPanel.add(savePic); toolPanel.add(pen); toolPanel.add(drLine); toolPanel.add(drCircle); toolPanel.add(drRect); toolPanel.add(颜色); toolPanel.add(ColChoice); toolPanel.add(大小B); toolPanel.add(SizeChoice); toolPanel.add(colchooser); toolPanel.add(eraser); toolPanel.add(大小E); toolPanel.add(EraserChoice); toolPanel.add(clear); // 工具面板到APPLET面板 add(toolPanel, BorderLayout.NORTH); setBounds(230, 50, 900, 650); setVisible(true); validate(); // dialog for save and load openPicture = new FileDialog(this, "打开图画", FileDialog.LOAD); openPicture.setVisible(false); savePicture = new FileDialog(this, "保存图画", FileDialog.SAVE); savePicture.setVisible(false); openPicture.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { openPicture.setVisible(false); } }); savePicture.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { savePicture.setVisible(false); } }); addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); }
/** * 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); }