List of usage examples for java.awt Button setActionCommand
public void setActionCommand(String command)
From source file:FileViewer.java
/** * The real constructor. Create a FileViewer object to display the specified * file from the specified directory//from www . ja v a2s .c o m */ public FileViewer(String directory, String filename) { super(); // Create the frame // Destroy the window when the user requests it addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { dispose(); } }); // Create a TextArea to display the contents of the file in textarea = new TextArea("", 24, 80); textarea.setFont(new Font("MonoSpaced", Font.PLAIN, 12)); textarea.setEditable(false); this.add("Center", textarea); // Create a bottom panel to hold a couple of buttons in Panel p = new Panel(); p.setLayout(new FlowLayout(FlowLayout.RIGHT, 10, 5)); this.add(p, "South"); // Create the buttons and arrange to handle button clicks Font font = new Font("SansSerif", Font.BOLD, 14); Button openfile = new Button("Open File"); Button close = new Button("Close"); openfile.addActionListener(this); openfile.setActionCommand("open"); openfile.setFont(font); close.addActionListener(this); close.setActionCommand("close"); close.setFont(font); p.add(openfile); p.add(close); this.pack(); // Figure out the directory, from filename or current dir, if necessary if (directory == null) { File f; if ((filename != null) && (f = new File(filename)).isAbsolute()) { directory = f.getParent(); filename = f.getName(); } else directory = System.getProperty("user.dir"); } this.directory = directory; // Remember the directory, for FileDialog setFile(directory, filename); // Now load and display the file }
From source file:mesquite.zephyr.lib.RAxMLRunner.java
public boolean queryOptions() { if (!okToInteractWithUser(CAN_PROCEED_ANYWAY, "Querying Options")) //Debugg.println needs to check that options set well enough to proceed anyway return true; boolean closeWizard = false; if ((MesquiteTrunk.isMacOSXBeforeSnowLeopard()) && MesquiteDialog.currentWizard == null) { CommandRecord cRec = null;/* w w w . ja v a2 s. c om*/ cRec = MesquiteThread.getCurrentCommandRecordDefIfNull(null); if (cRec != null) { cRec.requestEstablishWizard(true); closeWizard = true; } } MesquiteInteger buttonPressed = new MesquiteInteger(1); ExtensibleDialog dialog = new ExtensibleDialog(containerOfModule(), "RAxML Options & Locations", buttonPressed); //MesquiteTrunk.mesquiteTrunk.containerOfModule() // dialog.addLabel("RAxML - Options and Locations"); String helpString = "This module will prepare a matrix for RAxML, and ask RAxML do to an analysis. A command-line version of RAxML must be installed. " + "You can ask it to do multiple searches for optimal trees, OR to do a bootstrap analysis (but not both). " + "Mesquite will read in the trees found by RAxML, and, for non-bootstrap analyses, also read in the value of the RAxML score (-ln L) of the tree. " + "You can see the RAxML score by choosing Taxa&Trees>List of Trees, and then in the List of Trees for that trees block, choose " + "Columns>Number for Tree>Other Choices, and then in the Other Choices dialog, choose RAxML Score."; dialog.appendToHelpString(helpString); dialog.setHelpURL(zephyrRunnerEmployer.getProgramURL()); MesquiteTabbedPanel tabbedPanel = dialog.addMesquiteTabbedPanel(); tabbedPanel.addPanel("RAxML Program Details", true); externalProcRunner.addItemsToDialogPanel(dialog); addRunnerOptions(dialog); if (treeInferer != null) treeInferer.addItemsToDialogPanel(dialog); tabbedPanel.addPanel("Search Replicates & Bootstrap", true); doBootstrapCheckbox = dialog.addCheckBox("do bootstrap analysis", doBootstrap); dialog.addHorizontalLine(1); dialog.addLabel("Bootstrap Options", Label.LEFT, false, true); doBootstrapCheckbox.addItemListener(this); bootStrapRepsField = dialog.addIntegerField("Bootstrap Replicates", bootstrapreps, 8, 0, MesquiteInteger.infinite); seedField = dialog.addIntegerField("Random number seed: ", randomIntSeed, 20); dialog.addHorizontalLine(1); dialog.addLabel("Maximum Likelihood Tree Search Options", Label.LEFT, false, true); numRunsField = dialog.addIntegerField("Number of Search Replicates", numRuns, 8, 1, MesquiteInteger.infinite); onlyBestBox = dialog.addCheckBox("save only best tree", onlyBest); checkEnabled(doBootstrap); tabbedPanel.addPanel("Character Models & Constraints", true); dnaModelField = dialog.addTextField("DNA Model:", dnaModel, 20); proteinModelField = dialog.addTextField("Protein Model:", proteinModel, 20); dialog.addHorizontalLine(1); dialog.addLabel("Constraint tree:", Label.LEFT, false, true); constraintButtons = dialog.addRadioButtons( new String[] { "No Constraint", "Partial Resolution", "Skeletal Constraint" }, useConstraintTree); constraintButtons.addItemListener(this); /* dialog.addHorizontalLine(1); MPISetupField = dialog.addTextField("MPI setup command: ", MPIsetupCommand, 20); */ tabbedPanel.addPanel("Other options", true); otherOptionsField = dialog.addTextField("Other RAxML options:", otherOptions, 40); commandLabel = dialog.addLabel(""); commandField = dialog.addSingleLineTextArea("", 2); dialog.addBlankLine(); Button showCommand = dialog.addAListenedButton("Compose Command", null, this); showCommand.setActionCommand("composeRAxMLCommand"); Button clearCommand = dialog.addAListenedButton("Clear", null, this); clearCommand.setActionCommand("clearCommand"); tabbedPanel.cleanup(); dialog.nullifyAddPanel(); dialog.addHorizontalLine(1); // retainFilescheckBox = dialog.addCheckBox("Retain Files", retainFiles); dialog.completeAndShowDialog(true); if (buttonPressed.getValue() == 0) { boolean infererOK = (treeInferer == null || treeInferer.optionsChosen()); if (externalProcRunner.optionsChosen() && infererOK) { dnaModel = dnaModelField.getText(); proteinModel = proteinModelField.getText(); numRuns = numRunsField.getValue(); randomIntSeed = seedField.getValue(); bootstrapreps = bootStrapRepsField.getValue(); onlyBest = onlyBestBox.getState(); doBootstrap = doBootstrapCheckbox.getState(); useConstraintTree = constraintButtons.getValue(); otherOptions = otherOptionsField.getText(); processRunnerOptions(); storeRunnerPreferences(); } } dialog.dispose(); return (buttonPressed.getValue() == 0); }