public GetDataFrame(PlayableApplet anApplet, AppletRecorder ar) { // call base class constructor super("Get Student Data"); theApplet = anApplet; theAR = ar; resize(212, 206); start = new Button("Start"); step = new Button("Step"); step.disable(); close = new Button("Cancel"); makeSessionList(); buttonsPanel = new Panel(); buttonsPanel.add("West", start); buttonsPanel.add("Center", step); buttonsPanel.add("East", close); sessionsPanel = new Panel(); sessionsPanel.resize(150, 150); sessionsPanel.add("Center", sessionList); add("North", new Label("Select a Session:", Label.LEFT)); add("Center", sessionsPanel); add("South", buttonsPanel); show(); }
private void updateDebugPanelState(String result, boolean debug, boolean test) { result = result == null ? "nothing" : result; List<Component> componentList = Arrays.asList(getComponents()); if (!componentList.contains(p_debug)) { choice = new Label(String.format("Your choice is: %s", result)); isDebug = new Label(String.format("Debug mode: %b", debug)); isTest = new Label(String.format("Test mode: %b", test)); GridBagLayout layout = new GridBagLayout(); GridBagConstraints constraints = new GridBagConstraints(); layout.setConstraints(choice, constraints); constraints.gridy = 1; layout.setConstraints(isDebug, constraints); constraints.gridy = 2; layout.setConstraints(isTest, constraints); p_debug.setLayout(layout); p_debug.add(choice); p_debug.add(isDebug); p_debug.add(isTest); add(p_debug, BorderLayout.SOUTH); } else { choice.setText(String.format("Your choice is: %s", result)); isDebug.setText(String.format("Debug mode: %b", debug)); isTest.setText(String.format("Test mode: %b", test)); } }
private void addEnterTwoValues(Panel p, String one, String two) { p.add(new Label("Enter value for Dimension " + one)); TextField dim1 = new TextField(8); p.add(dim1); p.add(new Label("Enter value for Dimension " + two)); TextField dim2 = new TextField(8); p.add(dim2); }
/** Method declaration */ private void initGUI() { Panel pQuery = new Panel(); Panel pCommand = new Panel(); pResult = new Panel(); pQuery.setLayout(new BorderLayout()); pCommand.setLayout(new BorderLayout()); pResult.setLayout(new BorderLayout()); Font fFont = new Font("Dialog", Font.PLAIN, 12); txtCommand = new TextArea(5, 40); txtCommand.addKeyListener(this); txtResult = new TextArea(20, 40); txtCommand.setFont(fFont); txtResult.setFont(new Font("Courier", Font.PLAIN, 12)); butExecute = new Button("Execute"); butClear = new Button("Clear"); butExecute.addActionListener(this); butClear.addActionListener(this); pCommand.add("East", butExecute); pCommand.add("West", butClear); pCommand.add("Center", txtCommand); gResult = new Grid(); setLayout(new BorderLayout()); pResult.add("Center", gResult); pQuery.add("North", pCommand); pQuery.add("Center", pResult); fMain.add("Center", pQuery); tTree = new Tree(); // (ulrivo): screen with less than 640 width Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); if (d.width >= 640) { tTree.setMinimumSize(new Dimension(200, 100)); } else { tTree.setMinimumSize(new Dimension(80, 100)); } gResult.setMinimumSize(new Dimension(200, 300)); fMain.add("West", tTree); doLayout(); fMain.pack(); }
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)); }
/** * Adds a numeric field. The first word of the label must be unique or command recording will not * work. * * @param label the label * @param defaultValue value to be initially displayed * @param digits number of digits to right of decimal point * @param columns width of field in characters * @param units a string displayed to the right of the field */ public void addNumericField( String label, double defaultValue, int digits, int columns, String units) { String label2 = label; if (label2.indexOf('_') != -1) label2 = label2.replace('_', ' '); Label theLabel = makeLabel(label2); c.gridx = 0; c.gridy = y; c.anchor = GridBagConstraints.EAST; c.gridwidth = 1; if (firstNumericField) c.insets = getInsets(5, 0, 3, 0); else c.insets = getInsets(0, 0, 3, 0); grid.setConstraints(theLabel, c); add(theLabel); if (numberField == null) { numberField = new Vector(5); defaultValues = new Vector(5); defaultText = new Vector(5); } if (IJ.isWindows()) columns -= 2; if (columns < 1) columns = 1; String defaultString = IJ.d2s(defaultValue, digits); if (Double.isNaN(defaultValue)) defaultString = ""; TextField tf = new TextField(defaultString, columns); if (IJ.isLinux()) tf.setBackground(Color.white); tf.addActionListener(this); tf.addTextListener(this); tf.addFocusListener(this); tf.addKeyListener(this); numberField.addElement(tf); defaultValues.addElement(new Double(defaultValue)); defaultText.addElement(tf.getText()); c.gridx = 1; c.gridy = y; c.anchor = GridBagConstraints.WEST; tf.setEditable(true); // if (firstNumericField) tf.selectAll(); firstNumericField = false; if (units == null || units.equals("")) { grid.setConstraints(tf, c); add(tf); } else { Panel panel = new Panel(); panel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); panel.add(tf); panel.add(new Label(" " + units)); grid.setConstraints(panel, c); add(panel); } if (Recorder.record || macro) saveLabel(tf, label); y++; }
/** * Adds a radio button group. * * @param label group label (or null) * @param items radio button labels * @param rows number of rows * @param columns number of columns * @param defaultItem button initially selected */ public void addRadioButtonGroup( String label, String[] items, int rows, int columns, String defaultItem) { Panel panel = new Panel(); int n = items.length; panel.setLayout(new GridLayout(rows, columns, 0, 0)); CheckboxGroup cg = new CheckboxGroup(); for (int i = 0; i < n; i++) { Checkbox cb = new Checkbox(items[i], cg, items[i].equals(defaultItem)); cb.addItemListener(this); panel.add(cb); } if (radioButtonGroups == null) radioButtonGroups = new Vector(); radioButtonGroups.addElement(cg); Insets insets = getInsets(5, 10, 0, 0); if (label == null || label.equals("")) { label = "rbg" + radioButtonGroups.size(); insets.top += 5; } else { setInsets(10, insets.left, 0); addMessage(label); insets.top = 2; insets.left += 10; } c.gridx = 0; c.gridy = y; c.gridwidth = 2; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(insets.top, insets.left, 0, 0); grid.setConstraints(panel, c); add(panel); if (Recorder.record || macro) saveLabel(cg, label); y++; }
/** 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 }
// load the images when the applet begins executing public void init() { int i; this.processHTMLParameters(); if (totalImages == 0 || imageName == null) { this.showStatus("Invalid parameters"); this.destroy(); } images = new Vector(totalImages, 1); imageTracker = new MediaTracker(this); for (i = 0; i < totalImages; i++) { images.addElement(this.getImage(this.getDocumentBase(), "images/" + imageName + i + ".gif")); // track loading image imageTracker.addImage((Image) images.elementAt(i), i); } // wait for the first image, // must use a Joos version of tracker to avoid catching // interruped exception new JoosMediaTracker(imageTracker).waitForID(0); width = ((Image) images.elementAt(0)).getWidth(this); height = ((Image) images.elementAt(0)).getHeight(this); this.resize(width, height + 30); buffer = this.createImage(width, height); gContext = buffer.getGraphics(); // set background of buffer to white gContext.setColor(c.white()); gContext.fillRect(0, 0, 160, 80); this.setLayout(new BorderLayout(10, 10)); sleepLabel = new Label("Sleep time", c.LABEL_CENTER()); sleepDisplay = new TextField("", 5); sleepDisplay.setText(new Integer(sleepTime).toString()); sleepStuff = new Panel(); sleepStuff.add(sleepLabel); sleepStuff.add(sleepDisplay); new JoosContainer(this).addString("South", sleepStuff); }
public void buildChooser() { Panel panel = new Panel(); panel.setLayout(new GridLayout()); for (int i = 1; i <= 3; i++) { for (int x = 1; x <= 2; x++) { panel.add(addButton(i * x + "", Color.yellow)); } } add(panel); }
/** * Adds one or two (side by side) text areas. * * @param text1 initial contents of the first text area * @param text2 initial contents of the second text area or null * @param rows the number of rows * @param columns the number of columns */ public void addTextAreas(String text1, String text2, int rows, int columns) { if (textArea1 != null) return; Panel panel = new Panel(); textArea1 = new TextArea(text1, rows, columns, TextArea.SCROLLBARS_NONE); if (IJ.isLinux()) textArea1.setBackground(Color.white); textArea1.addTextListener(this); panel.add(textArea1); if (text2 != null) { textArea2 = new TextArea(text2, rows, columns, TextArea.SCROLLBARS_NONE); if (IJ.isLinux()) textArea2.setBackground(Color.white); panel.add(textArea2); } c.gridx = 0; c.gridy = y; c.gridwidth = 2; c.anchor = GridBagConstraints.WEST; c.insets = getInsets(15, 20, 0, 0); grid.setConstraints(panel, c); add(panel); y++; }
/** * Method declaration * * @param s * @param help */ void showHelp(String help[]) { txtCommand.setText(help[0]); txtResult.setText(help[1]); bHelp = true; pResult.removeAll(); pResult.add("Center", txtResult); pResult.doLayout(); txtCommand.requestFocus(); txtCommand.setCaretPosition(help[0].length()); }
public NslWrong(NslFrame parent) { super(parent, "Error", true); frame = parent; setLayout(new GridLayout(2, 1)); Panel panel = new Panel(); panel.add(new Label("Error: Invalid value for variable entered!")); add(panel); Button b; Panel okbutton = new Panel(); okbutton.add(b = new Button("Ok")); b.addActionListener(this); add(okbutton); setSize(300, 85); setVisible(true); }
/** * Adds a group of checkboxs using a grid layout. * * @param rows the number of rows * @param columns the number of columns * @param labels the labels * @param defaultValues the initial states * @param headings the column headings Example: * http://imagej.nih.gov/ij/plugins/multi-column-dialog/index.html */ public void addCheckboxGroup( int rows, int columns, String[] labels, boolean[] defaultValues, String[] headings) { Panel panel = new Panel(); int nRows = headings != null ? rows + 1 : rows; panel.setLayout(new GridLayout(nRows, columns, 6, 0)); int startCBIndex = cbIndex; if (checkbox == null) checkbox = new Vector(12); if (headings != null) { Font font = new Font("SansSerif", Font.BOLD, 12); for (int i = 0; i < columns; i++) { if (i > headings.length - 1 || headings[i] == null) panel.add(new Label("")); else { Label label = new Label(headings[i]); label.setFont(font); panel.add(label); } } } int i1 = 0; int[] index = new int[labels.length]; for (int row = 0; row < rows; row++) { for (int col = 0; col < columns; col++) { int i2 = col * rows + row; if (i2 >= labels.length) break; index[i1] = i2; String label = labels[i1]; if (label == null || label.length() == 0) { Label lbl = new Label(""); panel.add(lbl); i1++; continue; } if (label.indexOf('_') != -1) label = label.replace('_', ' '); Checkbox cb = new Checkbox(label); checkbox.addElement(cb); cb.setState(defaultValues[i1]); cb.addItemListener(this); if (Recorder.record || macro) saveLabel(cb, labels[i1]); if (IJ.isLinux()) { Panel panel2 = new Panel(); panel2.setLayout(new BorderLayout()); panel2.add("West", cb); panel.add(panel2); } else panel.add(cb); i1++; } } c.gridx = 0; c.gridy = y; c.gridwidth = 2; c.anchor = GridBagConstraints.WEST; c.insets = getInsets(10, 0, 0, 0); grid.setConstraints(panel, c); add(panel); y++; }
public void addPanel(String caption, Component comp) { int pos = pages.size(); NotebookPage np = new NotebookPage(); np.setImageResolver(imgres); np.comp = comp; np.label = caption; np.hidden = false; np.poly = null; np.color = Color.gray; np.name = Integer.toString(pos); if (curIndex < 0) curIndex = pos; pages.addElement(np); oobj.add(np.name, np.comp); repaint(); }
/** Method declaration */ void updateResult() { if (iResult == 0) { // in case 'help' has removed the grid if (bHelp) { pResult.removeAll(); pResult.add("Center", gResult); pResult.doLayout(); bHelp = false; } gResult.update(); gResult.repaint(); } else { showResultInText(); } txtCommand.selectAll(); txtCommand.requestFocus(); }
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); } }); }
/** * Method declaration * * @param ev */ public void actionPerformed(ActionEvent ev) { String s = ev.getActionCommand(); if (s == null) { if (ev.getSource() instanceof MenuItem) { MenuItem i; s = ((MenuItem) ev.getSource()).getLabel(); } } if (s.equals("Execute")) { execute(); } else if (s.equals("Exit")) { windowClosing(null); } else if (s.equals("Transfer")) { Transfer.work(null); } else if (s.equals("Dump")) { Transfer.work(new String[] {"-d"}); /* NB - 26052002 Restore is not implemented yet in the transfer tool */ /* } else if (s.equals("Restore")) { Transfer.work(new String[]{"-r"}); */ } else if (s.equals("Logging on")) { jdbcSystem.setLogToSystem(true); } else if (s.equals("Logging off")) { jdbcSystem.setLogToSystem(false); } else if (s.equals("Refresh Tree")) { refreshTree(); } else if (s.startsWith("#")) { int i = Integer.parseInt(s.substring(1)); txtCommand.setText(sRecent[i]); } else if (s.equals("Connect...")) { connect(ConnectionDialog.createConnection(fMain, "Connect")); refreshTree(); } else if (s.equals("Results in Grid")) { iResult = 0; pResult.removeAll(); pResult.add("Center", gResult); pResult.doLayout(); } else if (s.equals("Open Script...")) { FileDialog f = new FileDialog(fMain, "Open Script", FileDialog.LOAD); // (ulrivo): set default directory if set from command line if (defDirectory != null) { f.setDirectory(defDirectory); } f.show(); String file = f.getFile(); if (file != null) { txtCommand.setText(DatabaseManagerCommon.readFile(f.getDirectory() + file)); } } else if (s.equals("Save Script...")) { FileDialog f = new FileDialog(fMain, "Save Script", FileDialog.SAVE); // (ulrivo): set default directory if set from command line if (defDirectory != null) { f.setDirectory(defDirectory); } f.show(); String file = f.getFile(); if (file != null) { DatabaseManagerCommon.writeFile(f.getDirectory() + file, txtCommand.getText()); } } else if (s.equals("Save Result...")) { FileDialog f = new FileDialog(fMain, "Save Result", FileDialog.SAVE); // (ulrivo): set default directory if set from command line if (defDirectory != null) { f.setDirectory(defDirectory); } f.show(); String file = f.getFile(); if (file != null) { showResultInText(); DatabaseManagerCommon.writeFile(f.getDirectory() + file, txtResult.getText()); } } else if (s.equals("Results in Text")) { iResult = 1; pResult.removeAll(); pResult.add("Center", txtResult); pResult.doLayout(); showResultInText(); } else if (s.equals("AutoCommit on")) { try { cConn.setAutoCommit(true); } catch (SQLException e) { } } else if (s.equals("AutoCommit off")) { try { cConn.setAutoCommit(false); } catch (SQLException e) { } } else if (s.equals("Enlarge Tree")) { Dimension d = tTree.getMinimumSize(); d.width += 20; tTree.setMinimumSize(d); fMain.pack(); } else if (s.equals("Shrink Tree")) { Dimension d = tTree.getMinimumSize(); d.width -= 20; if (d.width >= 0) { tTree.setMinimumSize(d); } fMain.pack(); } else if (s.equals("Enlarge Command")) { txtCommand.setRows(txtCommand.getRows() + 1); fMain.pack(); } else if (s.equals("Shrink Command")) { int i = txtCommand.getRows() - 1; txtCommand.setRows(i < 1 ? 1 : i); fMain.pack(); } else if (s.equals("Commit")) { try { cConn.commit(); } catch (SQLException e) { } } else if (s.equals("Insert test data")) { insertTestData(); } else if (s.equals("Rollback")) { try { cConn.rollback(); } catch (SQLException e) { } } else if (s.equals("Disable MaxRows")) { try { sStatement.setMaxRows(0); } catch (SQLException e) { } } else if (s.equals("Set MaxRows to 100")) { try { sStatement.setMaxRows(100); } catch (SQLException e) { } } else if (s.equals("SELECT")) { showHelp(DatabaseManagerCommon.selectHelp); } else if (s.equals("INSERT")) { showHelp(DatabaseManagerCommon.insertHelp); } else if (s.equals("UPDATE")) { showHelp(DatabaseManagerCommon.updateHelp); } else if (s.equals("DELETE")) { showHelp(DatabaseManagerCommon.deleteHelp); } else if (s.equals("CREATE TABLE")) { showHelp(DatabaseManagerCommon.createTableHelp); } else if (s.equals("DROP TABLE")) { showHelp(DatabaseManagerCommon.dropTableHelp); } else if (s.equals("CREATE INDEX")) { showHelp(DatabaseManagerCommon.createIndexHelp); } else if (s.equals("DROP INDEX")) { showHelp(DatabaseManagerCommon.dropIndexHelp); } else if (s.equals("CHECKPOINT")) { showHelp(DatabaseManagerCommon.checkpointHelp); } else if (s.equals("SCRIPT")) { showHelp(DatabaseManagerCommon.scriptHelp); } else if (s.equals("SHUTDOWN")) { showHelp(DatabaseManagerCommon.shutdownHelp); } else if (s.equals("SET")) { showHelp(DatabaseManagerCommon.setHelp); } else if (s.equals("Test Script")) { showHelp(DatabaseManagerCommon.testHelp); } }
/** * 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(); }
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); } }
private void addEnterOneValue(Panel p, String one) { p.add(new Label("Enter value for Dimension " + one)); TextField dim1 = new TextField(8); p.add(dim1); }
public NslDimValue( NslFrame nsl_display_frame, String var_sel_full_name, NslVariableInfo var_sel_info, String plot_type_name, boolean replace_canvas) { super(nsl_display_frame, "Enter Values", true); /* these variables are needed in the action method */ this.nsl_display_frame = nsl_display_frame; this.var_sel_full_name = var_sel_full_name; this.var_sel_info = var_sel_info; this.plot_type_name = plot_type_name; this.replace_canvas = replace_canvas; num_dims = (var_sel_info.getCountDimensions()); if ((num_dims == 0) || (num_dims == 1) || (num_dims == 2) || (num_dims >= 4)) { System.err.println("Error: NslDimValue: should not have gotten here in the code."); return; } Panel p = new Panel(); if (num_dims == 3) { if (NslDimInput.dim_choice.equals("HI")) { addEnterOneValue(p, "J"); } else if (NslDimInput.dim_choice.equals("HJ")) { addEnterOneValue(p, "I"); } else if (NslDimInput.dim_choice.equals("IJ")) { addEnterOneValue(p, "H"); } else { System.err.println("Error: NslDimVal: bad input choice."); dispose(); return; } } // end if (num_dims==3) else if (num_dims == 4) { if (NslDimInput.dim_choice.equals("GH")) { addEnterTwoValues(p, "I", "J"); } else if (NslDimInput.dim_choice.equals("GI")) { addEnterTwoValues(p, "H", "J"); } else if (NslDimInput.dim_choice.equals("GJ")) { addEnterTwoValues(p, "H", "I"); } else if (NslDimInput.dim_choice.equals("HI")) { addEnterTwoValues(p, "G", "J"); } else if (NslDimInput.dim_choice.equals("HJ")) { addEnterTwoValues(p, "G", "I"); } else if (NslDimInput.dim_choice.equals("IJ")) { addEnterTwoValues(p, "G", "H"); } else { System.err.println("Error: NslDimVal:bad input choice"); dispose(); return; } } // end if (num_dims==4) add("Center", p); Button b; Panel p4 = new Panel(); p4.setLayout(new GridLayout(1, 5)); p4.add(b = new Button("<Back")); b.addActionListener(this); p4.add(new Label("")); p4.add(b = new Button("Cancel")); b.addActionListener(this); p4.add(new Label("")); p4.add(b = new Button("Next>")); b.addActionListener(this); add("South", p4); setSize(450, 180); } // end constructor
public BandAdjuster() { super("Threshold Colour"); if (instance != null) { instance.toFront(); return; } imp = WindowManager.getCurrentImage(); if (imp == null) { IJ.beep(); IJ.showStatus("No image"); return; } IJ.run("Select None"); thread = new Thread(this, "BandAdjuster"); WindowManager.addWindow(this); instance = this; IJ.register(PasteController.class); ij = IJ.getInstance(); Font font = new Font("SansSerif", Font.PLAIN, 10); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); setLayout(gridbag); int y = 0; c.gridx = 0; c.gridy = y; c.gridwidth = 1; c.weightx = 0; c.insets = new Insets(5, 0, 0, 0); labelh = new Label("Hue", Label.CENTER); add(labelh, c); c.gridx = 1; c.gridy = y++; c.gridwidth = 1; c.weightx = 0; c.insets = new Insets(7, 0, 0, 0); labelf = new Label("Filter type", Label.RIGHT); add(labelf, c); // plot c.gridx = 0; c.gridy = y; c.gridwidth = 1; c.fill = c.BOTH; c.anchor = c.CENTER; c.insets = new Insets(0, 5, 0, 0); add(plot, c); // checkboxes panelh = new Panel(); filterTypeH = new CheckboxGroup(); bandPassH = new Checkbox("Pass"); bandPassH.setCheckboxGroup(filterTypeH); bandPassH.addItemListener(this); panelh.add(bandPassH); bandStopH = new Checkbox("Stop"); bandStopH.setCheckboxGroup(filterTypeH); bandStopH.addItemListener(this); panelh.add(bandStopH); bandPassH.setState(true); c.gridx = 1; c.gridy = y++; c.gridwidth = 2; c.insets = new Insets(5, 0, 0, 0); add(panelh, c); // minHue slider minSlider = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, sliderRange); c.gridx = 0; c.gridy = y++; c.gridwidth = 1; c.weightx = IJ.isMacintosh() ? 90 : 100; c.fill = c.HORIZONTAL; c.insets = new Insets(5, 5, 0, 0); add(minSlider, c); minSlider.addAdjustmentListener(this); minSlider.setUnitIncrement(1); // minHue slider label c.gridx = 1; c.gridwidth = 1; c.weightx = IJ.isMacintosh() ? 10 : 0; c.insets = new Insets(5, 0, 0, 0); label1 = new Label(" ", Label.LEFT); label1.setFont(font); add(label1, c); // maxHue sliderHue maxSlider = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, sliderRange); c.gridx = 0; c.gridy = y; c.gridwidth = 1; c.weightx = 100; c.insets = new Insets(5, 5, 0, 0); add(maxSlider, c); maxSlider.addAdjustmentListener(this); maxSlider.setUnitIncrement(1); // maxHue slider label c.gridx = 1; c.gridwidth = 1; c.gridy = y++; c.weightx = 0; c.insets = new Insets(5, 0, 0, 0); label2 = new Label(" ", Label.LEFT); label2.setFont(font); add(label2, c); // ===== c.gridx = 0; c.gridy = y++; c.gridwidth = 1; c.weightx = 0; c.insets = new Insets(10, 0, 0, 0); labels = new Label("Saturation", Label.CENTER); add(labels, c); // plot c.gridx = 0; c.gridy = y; c.gridwidth = 1; c.fill = c.BOTH; c.anchor = c.CENTER; c.insets = new Insets(0, 5, 0, 0); add(splot, c); // checkboxes panels = new Panel(); filterTypeS = new CheckboxGroup(); bandPassS = new Checkbox("Pass"); bandPassS.setCheckboxGroup(filterTypeS); bandPassS.addItemListener(this); panels.add(bandPassS); bandStopS = new Checkbox("Stop"); bandStopS.setCheckboxGroup(filterTypeS); bandStopS.addItemListener(this); panels.add(bandStopS); bandPassS.setState(true); c.gridx = 1; c.gridy = y++; c.gridwidth = 2; c.insets = new Insets(5, 0, 0, 0); add(panels, c); // minSat slider minSlider2 = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, sliderRange); c.gridx = 0; c.gridy = y++; c.gridwidth = 1; c.weightx = IJ.isMacintosh() ? 90 : 100; c.fill = c.HORIZONTAL; c.insets = new Insets(5, 5, 0, 0); add(minSlider2, c); minSlider2.addAdjustmentListener(this); minSlider2.setUnitIncrement(1); // minSat slider label c.gridx = 1; c.gridwidth = 1; c.weightx = IJ.isMacintosh() ? 10 : 0; c.insets = new Insets(5, 0, 0, 0); label3 = new Label(" ", Label.LEFT); label3.setFont(font); add(label3, c); // maxSat slider maxSlider2 = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, sliderRange); c.gridx = 0; c.gridy = y++; c.gridwidth = 1; c.weightx = 100; c.insets = new Insets(5, 5, 0, 0); add(maxSlider2, c); maxSlider2.addAdjustmentListener(this); maxSlider2.setUnitIncrement(1); // maxSat slider label c.gridx = 1; c.gridwidth = 1; c.weightx = 0; c.insets = new Insets(5, 0, 0, 0); label4 = new Label(" ", Label.LEFT); label4.setFont(font); add(label4, c); // ===== c.gridx = 0; c.gridwidth = 1; c.gridy = y++; c.weightx = 0; c.insets = new Insets(10, 0, 0, 0); labelb = new Label("Brightness", Label.CENTER); add(labelb, c); c.gridx = 0; c.gridwidth = 1; c.gridy = y; c.fill = c.BOTH; c.anchor = c.CENTER; c.insets = new Insets(0, 5, 0, 0); add(bplot, c); // checkboxes panelb = new Panel(); filterTypeB = new CheckboxGroup(); bandPassB = new Checkbox("Pass"); bandPassB.setCheckboxGroup(filterTypeB); bandPassB.addItemListener(this); panelb.add(bandPassB); bandStopB = new Checkbox("Stop"); bandStopB.setCheckboxGroup(filterTypeB); bandStopB.addItemListener(this); panelb.add(bandStopB); bandPassB.setState(true); c.gridx = 1; c.gridy = y++; c.gridwidth = 2; c.insets = new Insets(5, 0, 0, 0); add(panelb, c); // minBri slider minSlider3 = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, sliderRange); c.gridx = 0; c.gridy = y++; c.gridwidth = 1; c.weightx = IJ.isMacintosh() ? 90 : 100; c.fill = c.HORIZONTAL; c.insets = new Insets(5, 5, 0, 0); add(minSlider3, c); minSlider3.addAdjustmentListener(this); minSlider3.setUnitIncrement(1); // minBri slider label c.gridx = 1; c.gridwidth = 1; c.weightx = IJ.isMacintosh() ? 10 : 0; c.insets = new Insets(5, 0, 0, 0); label5 = new Label(" ", Label.LEFT); label5.setFont(font); add(label5, c); // maxBri slider maxSlider3 = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, sliderRange); c.gridx = 0; c.gridy = y++; c.gridwidth = 1; c.weightx = 100; c.insets = new Insets(5, 5, 0, 0); add(maxSlider3, c); maxSlider3.addAdjustmentListener(this); maxSlider3.setUnitIncrement(1); // maxBri slider label c.gridx = 1; c.gridwidth = 1; c.weightx = 0; c.insets = new Insets(5, 0, 0, 0); label6 = new Label(" ", Label.LEFT); label6.setFont(font); add(label6, c); // ===== panelt = new Panel(); threshold = new Checkbox("Threshold"); threshold.addItemListener(this); panelt.add(threshold); invert = new Checkbox("Invert"); invert.addItemListener(this); panelt.add(invert); c.gridx = 0; c.gridy = y++; c.gridwidth = 2; c.insets = new Insets(0, 0, 0, 0); add(panelt, c); // buttons panel = new Panel(); // panel.setLayout(new GridLayout(2, 2, 0, 0)); originalB = new Button("Original"); originalB.setEnabled(false); originalB.addActionListener(this); originalB.addKeyListener(ij); panel.add(originalB); filteredB = new Button("Filtered"); filteredB.setEnabled(false); filteredB.addActionListener(this); filteredB.addKeyListener(ij); panel.add(filteredB); stackB = new Button("Stack"); stackB.addActionListener(this); stackB.addKeyListener(ij); panel.add(stackB); helpB = new Button("Help"); helpB.addActionListener(this); helpB.addKeyListener(ij); panel.add(helpB); c.gridx = 0; c.gridy = y++; c.gridwidth = 2; c.insets = new Insets(0, 0, 0, 0); add(panel, c); panelMode = new Panel(); sampleB = new Button("Sample"); sampleB.addActionListener(this); sampleB.addKeyListener(ij); panelMode.add(sampleB); colourMode = new CheckboxGroup(); hsb = new Checkbox("HSB"); hsb.setCheckboxGroup(colourMode); hsb.addItemListener(this); panelMode.add(hsb); hsb.setState(true); rgb = new Checkbox("RGB"); rgb.setCheckboxGroup(colourMode); rgb.addItemListener(this); panelMode.add(rgb); c.gridx = 0; c.gridy = y++; c.gridwidth = 2; c.insets = new Insets(0, 0, 0, 0); add(panelMode, c); addKeyListener(ij); // ImageJ handles keyboard shortcuts pack(); GUI.center(this); setVisible(true); ip = setup(imp); if (ip == null) { imp.unlock(); IJ.beep(); IJ.showStatus("RGB image cannot be thresholded"); return; } thread.start(); }
/** Displays this dialog box. */ public void showDialog() { if (macro) { dispose(); recorderOn = Recorder.record && Recorder.recordInMacros; } else { if (pfr != null) // prepare preview (not in macro mode): tell the PlugInFilterRunner to listen pfr.setDialog(this); Panel buttons = new Panel(); buttons.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 0)); cancel = new Button(cancelLabel); cancel.addActionListener(this); cancel.addKeyListener(this); if (yesNoCancel) { okLabel = yesLabel; no = new Button(noLabel); no.addActionListener(this); no.addKeyListener(this); } okay = new Button(okLabel); okay.addActionListener(this); okay.addKeyListener(this); boolean addHelp = helpURL != null; if (addHelp) { help = new Button(helpLabel); help.addActionListener(this); help.addKeyListener(this); } if (IJ.isMacintosh()) { if (addHelp) buttons.add(help); if (yesNoCancel) buttons.add(no); if (!hideCancelButton) buttons.add(cancel); buttons.add(okay); } else { buttons.add(okay); if (yesNoCancel) buttons.add(no); ; if (!hideCancelButton) buttons.add(cancel); if (addHelp) buttons.add(help); } c.gridx = 0; c.gridy = y; c.anchor = GridBagConstraints.EAST; c.gridwidth = 2; c.insets = new Insets(15, 0, 0, 0); grid.setConstraints(buttons, c); add(buttons); if (IJ.isMacintosh()) setResizable(false); pack(); setup(); if (centerDialog) GUI.center(this); setVisible(true); recorderOn = Recorder.record; IJ.wait(50); // work around for Sun/WinNT bug } /* For plugins that read their input only via dialogItemChanged, call it at least once */ if (!wasCanceled && dialogListeners != null && dialogListeners.size() > 0) { resetCounters(); ((DialogListener) dialogListeners.elementAt(0)).dialogItemChanged(this, null); recorderOn = false; } resetCounters(); }
/** * 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(); }
/** * Adds a slider (scroll bar) to the dialog box. Floating point values will be used if * (maxValue-minValue)<=5.0 and either minValue or maxValue are non-integer. * * @param label the label * @param minValue the minimum value of the slider * @param maxValue the maximum value of the slider * @param defaultValue the initial value of the slider */ public void addSlider(String label, double minValue, double maxValue, double defaultValue) { if (defaultValue < minValue) defaultValue = minValue; if (defaultValue > maxValue) defaultValue = maxValue; int columns = 4; int digits = 0; double scale = 1.0; if ((maxValue - minValue) <= 5.0 && (minValue != (int) minValue || maxValue != (int) maxValue || defaultValue != (int) defaultValue)) { scale = 20.0; minValue *= scale; maxValue *= scale; defaultValue *= scale; digits = 2; } String label2 = label; if (label2.indexOf('_') != -1) label2 = label2.replace('_', ' '); Label theLabel = makeLabel(label2); c.gridx = 0; c.gridy = y; c.anchor = GridBagConstraints.EAST; c.gridwidth = 1; c.insets = new Insets(0, 0, 3, 0); grid.setConstraints(theLabel, c); add(theLabel); if (slider == null) { slider = new Vector(5); sliderIndexes = new int[MAX_SLIDERS]; sliderScales = new double[MAX_SLIDERS]; } Scrollbar s = new Scrollbar( Scrollbar.HORIZONTAL, (int) defaultValue, 1, (int) minValue, (int) maxValue + 1); GUI.fix(s); slider.addElement(s); s.addAdjustmentListener(this); s.setUnitIncrement(1); if (numberField == null) { numberField = new Vector(5); defaultValues = new Vector(5); defaultText = new Vector(5); } if (IJ.isWindows()) columns -= 2; if (columns < 1) columns = 1; TextField tf = new TextField(IJ.d2s(defaultValue / scale, digits), columns); if (IJ.isLinux()) tf.setBackground(Color.white); tf.addActionListener(this); tf.addTextListener(this); tf.addFocusListener(this); tf.addKeyListener(this); numberField.addElement(tf); sliderIndexes[slider.size() - 1] = numberField.size() - 1; sliderScales[slider.size() - 1] = scale; defaultValues.addElement(new Double(defaultValue / scale)); defaultText.addElement(tf.getText()); tf.setEditable(true); firstSlider = false; Panel panel = new Panel(); GridBagLayout pgrid = new GridBagLayout(); GridBagConstraints pc = new GridBagConstraints(); panel.setLayout(pgrid); pc.gridx = 0; pc.gridy = 0; pc.gridwidth = 1; pc.ipadx = 85; pc.anchor = GridBagConstraints.WEST; pgrid.setConstraints(s, pc); panel.add(s); pc.ipadx = 0; // reset // text field pc.gridx = 1; pc.insets = new Insets(5, 5, 0, 0); pc.anchor = GridBagConstraints.EAST; pgrid.setConstraints(tf, pc); panel.add(tf); grid.setConstraints(panel, c); c.gridx = 1; c.gridy = y; c.gridwidth = 1; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(0, 0, 0, 0); grid.setConstraints(panel, c); add(panel); y++; if (Recorder.record || macro) saveLabel(tf, label); }
/** * Handles when aides cover each other. They must tell * us who they're covering so that that poor person * doesn't get a missed shift. This of course means i * have to work on MyHours some more... If they select * a valid userid to cover for makes the appropriate * entry in AIDELOG. * * @param An SaoWorker who is covering someone else */ public void WhoRUCovering(final SaoWorker w) { int i = 0; int h = bd.getHours(); int m = bd.getMinutes(); if (((m >= 20) && (m < 30)) || ((m >= 50) && (m < 60))) { if (m < 30) { m = m + 10; } else { m = m + 10 - 60; h = h + 1; } } int dopp = bd.getDoPP(); if (dopp > 7) { dopp = dopp - 7; } String slotid = bd.getSlot(h, m, dopp); String q = "select * from AIDESCHED where " + slotid + "=1"; final String[] userids = {"", "", "", "", "", "", "", "", "", ""}; final BatSQL bSQL = new BatSQL(); ResultSet rs = bSQL.query(q); try { boolean more = rs.next(); if (more) //because there might be only one person for this slot { while (more) { userids[i] = rs.getString(1); i++; more = rs.next(); } } //end of if more } //end of try catch (SQLException ex) { System.out.println("!*******SQLException caught*******!"); System.out.println("WhoRUCovering"); while (ex != null) { System.out.println ("SQLState: " + ex.getSQLState ()); System.out.println ("Message: " + ex.getMessage ()); System.out.println ("Vendor: " + ex.getErrorCode ()); ex = ex.getNextException (); System.out.println (""); } System.exit(0); } //end catching SQLExceptions catch (java.lang.Exception ex) { System.out.println("!*******Exception caught*******!"); System.out.println("WhoRUCovering"); System.exit(0); } //end catching other Exceptions final Frame coverF = new Frame("Covering?"); final Panel p = new Panel(); final Panel btnP = new Panel(); final List coverL = new List(); Button ok = new Button("Cover"); Button nok = new Button("Cancel"); final int i2 = i; ok.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String id = coverL.getSelectedItem(); BatSQL bS = new BatSQL(); String a = "insert into aidelog values ('C', \"" + id + "\", \"" + bd.getDate() + "\", " + bd.getStringHours() + bd.getStringMinutes() + ", 'I')"; bS.update(a); a = "update AIDEDIN set COVERING='" + id + "' where USERID='" + w.getUserID() + "'"; bS.update(a); bS.disconnect(); coverF.dispose(); } }); nok.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { coverF.dispose(); } }); btnP.setLayout(new FlowLayout()); btnP.add(ok); btnP.add(nok); p.setLayout(new BorderLayout()); p.add(new Label("Who are you covering for?"), BorderLayout.NORTH); int j; for (j = 0; j <= i; j++) { coverL.add(userids[j]); } p.add(coverL, BorderLayout.CENTER); p.add(btnP, BorderLayout.SOUTH); coverL.select(0); coverF.setLayout(new FlowLayout()); coverF.add(p); coverF.pack(); coverF.setLocation(200, 200); coverF.show(); } //end of WhoRUCovering