/** Listener to handle button actions */ public void actionPerformed(ActionEvent e) { // Check if the user changed the service filter option if (e.getSource() == service_box) { service_list.setEnabled(service_box.isSelected()); service_list.clearSelection(); remove_service_button.setEnabled(false); add_service_field.setEnabled(service_box.isSelected()); add_service_field.setText(""); add_service_button.setEnabled(false); } // Check if the user pressed the add service button if ((e.getSource() == add_service_button) || (e.getSource() == add_service_field)) { String text = add_service_field.getText(); if ((text != null) && (text.length() > 0)) { service_data.addElement(text); service_list.setListData(service_data); } add_service_field.setText(""); add_service_field.requestFocus(); } // Check if the user pressed the remove service button if (e.getSource() == remove_service_button) { Object[] sels = service_list.getSelectedValues(); for (int i = 0; i < sels.length; i++) { service_data.removeElement(sels[i]); } service_list.setListData(service_data); service_list.clearSelection(); } }
/** Listener to handle button actions */ public void actionPerformed(ActionEvent e) { // Check if the user pressed the ok button if (e.getSource() == ok_button) { filter_include_list = include_panel.getServiceList(); filter_exclude_list = exclude_panel.getServiceList(); if (status_box.isSelected()) { filter_active = status_active.isSelected(); filter_complete = status_complete.isSelected(); } else { filter_active = false; filter_complete = false; } ok_pressed = true; dialog.dispose(); } // Check if the user pressed the cancel button if (e.getSource() == cancel_button) { dialog.dispose(); } // Check if the user changed the status filter option if (e.getSource() == status_box) { status_active.setEnabled(status_box.isSelected()); status_complete.setEnabled(status_box.isSelected()); } }
/** Show the filter dialog */ public void showDialog() { empty_border = new EmptyBorder(5, 5, 0, 5); indent_border = new EmptyBorder(5, 25, 5, 5); include_panel = new ServiceFilterPanel("Include messages based on target service:", filter_include_list); exclude_panel = new ServiceFilterPanel("Exclude messages based on target service:", filter_exclude_list); status_box = new JCheckBox("Filter messages based on status:"); status_box.addActionListener(this); status_active = new JRadioButton("Active messages only"); status_active.setSelected(true); status_active.setEnabled(false); status_complete = new JRadioButton("Complete messages only"); status_complete.setEnabled(false); status_group = new ButtonGroup(); status_group.add(status_active); status_group.add(status_complete); if (filter_active || filter_complete) { status_box.setSelected(true); status_active.setEnabled(true); status_complete.setEnabled(true); if (filter_complete) { status_complete.setSelected(true); } } status_options = new JPanel(); status_options.setLayout(new BoxLayout(status_options, BoxLayout.Y_AXIS)); status_options.add(status_active); status_options.add(status_complete); status_options.setBorder(indent_border); status_panel = new JPanel(); status_panel.setLayout(new BorderLayout()); status_panel.add(status_box, BorderLayout.NORTH); status_panel.add(status_options, BorderLayout.CENTER); status_panel.setBorder(empty_border); ok_button = new JButton("Ok"); ok_button.addActionListener(this); cancel_button = new JButton("Cancel"); cancel_button.addActionListener(this); buttons = new JPanel(); buttons.setLayout(new FlowLayout()); buttons.add(ok_button); buttons.add(cancel_button); panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.add(include_panel); panel.add(exclude_panel); panel.add(status_panel); panel.add(buttons); dialog = new JDialog(); dialog.setTitle("SOAP Monitor Filter"); dialog.setContentPane(panel); dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); dialog.setModal(true); dialog.pack(); Dimension d = dialog.getToolkit().getScreenSize(); dialog.setLocation((d.width - dialog.getWidth()) / 2, (d.height - dialog.getHeight()) / 2); ok_pressed = false; dialog.show(); }
void applyDirectives() { findRemoveDirectives(true); StringBuffer buffer = new StringBuffer(); String head = "", toe = "; \n"; if (crispBox.isSelected()) buffer.append(head + "crisp=true" + toe); if (!fontField.getText().trim().equals("")) buffer.append(head + "font=\"" + fontField.getText().trim() + "\"" + toe); if (globalKeyEventsBox.isSelected()) buffer.append(head + "globalKeyEvents=true" + toe); if (pauseOnBlurBox.isSelected()) buffer.append(head + "pauseOnBlur=true" + toe); if (!preloadField.getText().trim().equals("")) buffer.append(head + "preload=\"" + preloadField.getText().trim() + "\"" + toe); /*if ( transparentBox.isSelected() ) buffer.append( head + "transparent=true" + toe );*/ Sketch sketch = editor.getSketch(); SketchCode code = sketch.getCode(0); // first tab if (buffer.length() > 0) { code.setProgram("/* @pjs " + buffer.toString() + " */\n\n" + code.getProgram()); if (sketch.getCurrentCode() == code) // update textarea if on first tab { editor.setText(sketch.getCurrentCode().getProgram()); editor.setSelection(0, 0); } sketch.setModified(false); sketch.setModified(true); } }
private void setComponentsEnabled(boolean enabled) { list.setEnabled(enabled); process.setEnabled(enabled); remove.setEnabled(enabled); xres.setEnabled(enabled); yres.setEnabled(enabled); aspect.setEnabled(enabled); boolean b = aspect.isSelected() && enabled; colorLabel.setEnabled(b); colorBox.setEnabled(b); redLabel.setEnabled(b); red.setEnabled(b); redValue.setEnabled(b); greenLabel.setEnabled(b); green.setEnabled(b); greenValue.setEnabled(b); blueLabel.setEnabled(b); blue.setEnabled(b); blueValue.setEnabled(b); format.setEnabled(enabled); algorithm.setEnabled(enabled); prepend.setEnabled(enabled); append.setEnabled(enabled); output.setEnabled(enabled); }
/** * Creates a checkbox and sets it's value. * * @param strText either 'yes' or 'no' if yes then set the checkbox selected. */ protected JCheckBox createChkBox(String strText, JPanel pnlDisplay) { JCheckBox chkField = new JCheckBox(); boolean bSelected = (strText.equalsIgnoreCase("yes")) ? true : false; chkField.setSelected(bSelected); pnlDisplay.add(chkField); return chkField; }
public SISCFrame(AppContext ctx) { setLayout(new BorderLayout()); SchemePanel.SchemeDocument d = new SchemePanel.SchemeDocument(); sp = new SchemePanel(ctx, d, new JTextPane(d)); input = new JTextArea(4, 70); input.setText("; Enter s-expressions here"); JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, sp, input); JPanel execPanel = new JPanel(); execPanel.setLayout(new BoxLayout(execPanel, BoxLayout.X_AXIS)); execPanel.add(Box.createHorizontalGlue()); eval = new JButton("Evaluate"); clear = new JButton("Clear"); autoClear = new JCheckBox("Auto-Clear"); submitOnEnter = new JCheckBox("Evaluate on Enter"); autoClear.setSelected(true); submitOnEnter.setSelected(true); execPanel.add(submitOnEnter); execPanel.add(autoClear); execPanel.add(clear); execPanel.add(eval); add(split, BorderLayout.CENTER); add(execPanel, BorderLayout.SOUTH); eval.addActionListener(this); clear.addActionListener(this); input.addKeyListener(this); /* addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } });*/ }
/** * The ActionListener implementation * * @param event the event. */ public void actionPerformed(ActionEvent event) { String searchText = textField.getText().trim(); if (searchText.equals("") && !saveAs.isSelected() && (fileLength > 10000000)) { textPane.setText("Blank search text is not allowed for large IdTables."); } else { File outputFile = null; if (saveAs.isSelected()) { outputFile = chooser.getSelectedFile(); if (outputFile != null) { String name = outputFile.getName(); int k = name.lastIndexOf("."); if (k != -1) name = name.substring(0, k); name += ".txt"; File parent = outputFile.getAbsoluteFile().getParentFile(); outputFile = new File(parent, name); chooser.setSelectedFile(outputFile); } if (chooser.showSaveDialog(this) != JFileChooser.APPROVE_OPTION) System.exit(0); outputFile = chooser.getSelectedFile(); } textPane.setText(""); Searcher searcher = new Searcher(searchText, event.getSource().equals(searchPHI), outputFile); searcher.start(); } }
private void parseDirective(String directive) { if (directive == null) { System.err.println("Directive is null."); return; } String[] pair = directive.split("="); if (pair == null || pair.length != 2) { System.err.println("Unable to parse directive: \"" + directive + "\" Ignored."); return; } String key = pair[0].trim(), value = pair[1].trim(); // clean these, might have too much whitespace around commas if (validKeys.indexOf(key) == FONT || validKeys.indexOf(key) == PRELOAD) { value = value.replaceAll("[\\s]*,[\\s]*", ","); } if (validKeys.indexOf(key) == -1) { System.err.println("Directive key not recognized: \"" + key + "\" Ignored."); return; } if (value.equals("")) { System.err.println("Directive value empty. Ignored."); return; } value = value.replaceAll("^\"|\"$", "").replaceAll("^'|'$", ""); // System.out.println( key + " = " + value ); boolean v; switch (validKeys.indexOf(key)) { case CRISP: v = value.toLowerCase().equals("true"); crispBox.setSelected(v); break; case FONT: fontField.setText(value); break; case GLOBAL_KEY_EVENTS: v = value.toLowerCase().equals("true"); globalKeyEventsBox.setSelected(v); break; case PAUSE_ON_BLUR: v = value.toLowerCase().equals("true"); pauseOnBlurBox.setSelected(v); break; case PRELOAD: preloadField.setText(value); break; case TRANSPARENT: v = value.toLowerCase().equals("true"); // transparentBox.setSelected(v); break; } }
private void resetInterface() { for (JCheckBox b : new JCheckBox[] {crispBox, globalKeyEventsBox, pauseOnBlurBox /*, transparentBox*/}) { b.setSelected(false); } for (JTextField f : new JTextField[] {fontField, preloadField}) { f.setText(""); } }
/** Listener to handle button actions */ public void actionPerformed(ActionEvent e) { // Check if the user pressed the remove button if (e.getSource() == remove_button) { int row = table.getSelectedRow(); model.removeRow(row); table.clearSelection(); table.repaint(); valueChanged(null); } // Check if the user pressed the remove all button if (e.getSource() == remove_all_button) { model.clearAll(); table.setRowSelectionInterval(0, 0); table.repaint(); valueChanged(null); } // Check if the user pressed the filter button if (e.getSource() == filter_button) { filter.showDialog(); if (filter.okPressed()) { // Update the display with new filter model.setFilter(filter); table.repaint(); } } // Check if the user pressed the start button if (e.getSource() == start_button) { start(); } // Check if the user pressed the stop button if (e.getSource() == stop_button) { stop(); } // Check if the user wants to switch layout if (e.getSource() == layout_button) { details_panel.remove(details_soap); details_soap.removeAll(); if (details_soap.getOrientation() == JSplitPane.HORIZONTAL_SPLIT) { details_soap = new JSplitPane(JSplitPane.VERTICAL_SPLIT); } else { details_soap = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); } details_soap.setTopComponent(request_panel); details_soap.setRightComponent(response_panel); details_soap.setResizeWeight(.5); details_panel.add(details_soap, BorderLayout.CENTER); details_panel.validate(); details_panel.repaint(); } // Check if the user is changing the reflow option if (e.getSource() == reflow_xml) { request_text.setReflowXML(reflow_xml.isSelected()); response_text.setReflowXML(reflow_xml.isSelected()); } }
public GalaxyViewer(Settings settings, boolean animatorFrame) throws Exception { super("Stars GalaxyViewer"); this.settings = settings; this.animatorFrame = animatorFrame; if (settings.gameName.equals("")) throw new Exception("GameName not defined in settings."); setDefaultCloseOperation(EXIT_ON_CLOSE); File dir = new File(settings.directory); File map = new File(dir, settings.getGameName() + ".MAP"); if (map.exists() == false) { File f = new File(dir.getParentFile(), settings.getGameName() + ".MAP"); if (f.exists()) map = f; else { String error = "Could not find " + map.getAbsolutePath() + "\n"; error += "Export this file from Stars! (Only needs to be done one time pr game)"; throw new Exception(error); } } Vector<File> mFiles = new Vector<File>(); Vector<File> hFiles = new Vector<File>(); for (File f : dir.listFiles()) { if (f.getName().toUpperCase().endsWith("MAP")) continue; if (f.getName().toUpperCase().endsWith("HST")) continue; if (f.getName().toUpperCase().startsWith(settings.getGameName() + ".M")) mFiles.addElement(f); else if (f.getName().toUpperCase().startsWith(settings.getGameName() + ".H")) hFiles.addElement(f); } if (mFiles.size() == 0) throw new Exception("No M-files found matching game name."); if (hFiles.size() == 0) throw new Exception("No H-files found matching game name."); parseMapFile(map); Vector<File> files = new Vector<File>(); files.addAll(mFiles); files.addAll(hFiles); p = new Parser(files); calculateColors(); // UI: JPanel cp = (JPanel) getContentPane(); cp.setLayout(new BorderLayout()); cp.add(universe, BorderLayout.CENTER); JPanel south = createPanel(0, hw, new JLabel("Search: "), search, names, zoom, colorize); search.setPreferredSize(new Dimension(100, -1)); cp.add(south, BorderLayout.SOUTH); hw.addActionListener(this); names.addActionListener(this); zoom.addChangeListener(this); search.addKeyListener(this); colorize.addActionListener(this); setSize(800, 600); Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); setLocation((screen.width - getWidth()) / 2, (screen.height - getHeight()) / 2); setVisible(animatorFrame == false); if (animatorFrame) names.setSelected(false); }
/** Returns false if Exception is thrown. */ private boolean setDirectory() { String pathStr = dirTF.getText().trim(); if (pathStr.equals("")) pathStr = System.getProperty("user.dir"); try { File dirPath = new File(pathStr); if (!dirPath.isDirectory()) { if (!dirPath.exists()) { if (recursiveCheckBox.isSelected()) throw new NotDirectoryException(dirPath.getAbsolutePath()); else throw new NotFileException(dirPath.getAbsolutePath()); } else { convertSet.setFile(dirPath); convertSet.setDestinationPath(dirPath.getParentFile()); } } else { // Set the descriptors setMatchingFileNames(); FlexFilter flexFilter = new FlexFilter(); flexFilter.addDescriptors(descriptors); flexFilter.setFilesOnly(!recursiveCheckBox.isSelected()); convertSet.setSourcePath(dirPath, flexFilter); convertSet.setDestinationPath(dirPath); } } catch (NotDirectoryException e1) { final String caption = ResourceHandler.getMessage("notdirectory_dialog.caption1"); MessageFormat formatter; String info_msg; if (pathStr.equals("")) { info_msg = ResourceHandler.getMessage("notdirectory_dialog.info5"); } else { formatter = new MessageFormat(ResourceHandler.getMessage("notdirectory_dialog.info0")); info_msg = formatter.format(new Object[] {pathStr}); } final String info = info_msg; JOptionPane.showMessageDialog(this, info, caption, JOptionPane.ERROR_MESSAGE); return false; } catch (NotFileException e2) { final String caption = ResourceHandler.getMessage("notdirectory_dialog.caption0"); MessageFormat formatter = new MessageFormat(ResourceHandler.getMessage("notdirectory_dialog.info1")); final String info = formatter.format(new Object[] {pathStr}); JOptionPane.showMessageDialog(this, info, caption, JOptionPane.ERROR_MESSAGE); return false; } return true; // no exception thrown }
/** Constructor */ public ServiceFilterPanel(String text, Vector list) { empty_border = new EmptyBorder(5, 5, 0, 5); indent_border = new EmptyBorder(5, 25, 5, 5); service_box = new JCheckBox(text); service_box.addActionListener(this); service_data = new Vector(); if (list != null) { service_box.setSelected(true); service_data = (Vector) list.clone(); } service_list = new JList(service_data); service_list.setBorder(new EtchedBorder()); service_list.setVisibleRowCount(5); service_list.addListSelectionListener(this); service_list.setEnabled(service_box.isSelected()); service_scroll = new JScrollPane(service_list); service_scroll.setBorder(new EtchedBorder()); remove_service_button = new JButton("Remove"); remove_service_button.addActionListener(this); remove_service_button.setEnabled(false); remove_service_panel = new JPanel(); remove_service_panel.setLayout(new FlowLayout()); remove_service_panel.add(remove_service_button); service_area = new JPanel(); service_area.setLayout(new BorderLayout()); service_area.add(service_scroll, BorderLayout.CENTER); service_area.add(remove_service_panel, BorderLayout.EAST); service_area.setBorder(indent_border); add_service_field = new JTextField(); add_service_field.addActionListener(this); add_service_field.getDocument().addDocumentListener(this); add_service_field.setEnabled(service_box.isSelected()); add_service_button = new JButton("Add"); add_service_button.addActionListener(this); add_service_button.setEnabled(false); add_service_panel = new JPanel(); add_service_panel.setLayout(new BorderLayout()); JPanel dummy = new JPanel(); dummy.setBorder(empty_border); add_service_panel.add(dummy, BorderLayout.WEST); add_service_panel.add(add_service_button, BorderLayout.EAST); add_service_area = new JPanel(); add_service_area.setLayout(new BorderLayout()); add_service_area.add(add_service_field, BorderLayout.CENTER); add_service_area.add(add_service_panel, BorderLayout.EAST); add_service_area.setBorder(indent_border); setLayout(new BorderLayout()); add(service_box, BorderLayout.NORTH); add(service_area, BorderLayout.CENTER); add(add_service_area, BorderLayout.SOUTH); setBorder(empty_border); }
@Override public Component getOptionsPanel() { JPanel panel = new JPanel(new GridLayout()); final JCheckBox applyFileFilter = new JCheckBox("Show \"Program\" Folders/Files Only"); applyFileFilter.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { _applyFileFilter = applyFileFilter.isSelected(); } }); panel.add(applyFileFilter); return panel; }
public BooleanField(BooleanOption option) { super(option); checkbox = new JCheckBox(); checkbox.setSelected(option.isDefault()); checkbox.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { fireChangeEvent(); } }); }
public GLDemo() { super(VNMRFrame.getVNMRFrame(), "Jogl Demo", false); DisplayOptions.addChangeListener(this); contentPane = getContentPane(); contentPane.setLayout(new BorderLayout()); gradientPanel = createGradientPanel(); contentPane.add(gradientPanel, BorderLayout.CENTER); checkBox = new JCheckBox("Transparent", true); checkBox.setActionCommand("transparancy"); checkBox.addActionListener(this); optionsPan = new JPanel(); optionsPan.setLayout(new SimpleH2Layout(SimpleH2Layout.LEFT, 5, 0, true, false)); optionsPan.setBorder(new EtchedBorder(EtchedBorder.LOWERED)); optionsPan.add(checkBox); runButton = new JToggleButton("Run"); runButton.setActionCommand("run"); runButton.setSelected(false); runButton.addActionListener(this); optionsPan.add(runButton); getContentPane().add(optionsPan, BorderLayout.SOUTH); setSize(300, 300); setLocation(300, 300); addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { // Run this on another thread than the AWT event queue to // make sure the call to Animator.stop() completes before // exiting new Thread( new Runnable() { public void run() { stop(); } }) .start(); } }); setVisible(false); }
@Override public void chatLinkClicked(URI url) { String action = url.getPath(); if (action.equals("/SHOWPREVIEW")) { enableReplacement.setSelected(cfg.getBoolean(ReplacementProperty.REPLACEMENT_ENABLE, true)); enableReplacementProposal.setSelected( cfg.getBoolean(ReplacementProperty.REPLACEMENT_PROPOSAL, true)); currentMessageID = url.getQuery(); currentLinkPosition = url.getFragment(); this.setVisible(true); this.setLocationRelativeTo(chatPanel); } }
/** Loading the values stored into configuration form */ private void loadValues() { PacketLoggingService packetLogging = LoggingUtilsActivator.getPacketLoggingService(); PacketLoggingConfiguration cfg = packetLogging.getConfiguration(); enableCheckBox.setSelected(cfg.isGlobalLoggingEnabled()); sipProtocolCheckBox.setSelected(cfg.isSipLoggingEnabled()); jabberProtocolCheckBox.setSelected(cfg.isJabberLoggingEnabled()); rtpProtocolCheckBox.setSelected(cfg.isRTPLoggingEnabled()); ice4jProtocolCheckBox.setSelected(cfg.isIce4JLoggingEnabled()); fileCountField.setText(String.valueOf(cfg.getLogfileCount())); fileSizeField.setText(String.valueOf(cfg.getLimit() / 1000)); updateButtonsState(); }
/** Get the current list of services */ public Vector getServiceList() { Vector list = null; if (service_box.isSelected()) { list = service_data; } return list; }
public void actionPerformed(ActionEvent ae) { String cmd = ae.getActionCommand(); if (JOkCancelPanel.OK.equals(cmd)) { // update evaluator evaluator.name = tfName.getText(); evaluator.type = (byte) cbType.getSelectedIndex(); evaluator.ignoreDiagonals = cbDiagonals.isSelected(); evaluator.investments = (byte) cbInvestment.getSelectedIndex(); evaluator.orgFile = orgFile; setVisible(false); } else if (JOkCancelPanel.CANCEL.equals(cmd)) { // don't update evaluator setVisible(false); } else if (CMD_CHOOSE_FILE.equals(cmd)) { // get a file dialog JFrame f = new JFrame(); JFileChooser jfc = Application.getFileChooser(); int res = jfc.showOpenDialog(f); Application.setWorkingDirectory(jfc.getCurrentDirectory()); if (res == JFileChooser.CANCEL_OPTION) { return; } orgFile = jfc.getSelectedFile(); lOrgFileName.setText("File: " + orgFile.getName()); } }
/** handle button events. */ public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); if (cmd.equals("run")) { if (animator.isAnimating()) stop(); else start(); } else if (cmd.equals("transparancy")) { if (drawable != null) drawable.setOpaque(!checkBox.isSelected()); } }
private void loadPreferences() { // grab the preferences so that they can be used to fill out the layout ThumbMakerPreferences myPreferences = ThumbMakerPreferences.getInstance(); // x resolution text box xres.setText(myPreferences.getStringPref(ThumbMakerPreferences.RES_WIDTH_PREF_NAME)); // y resolution text box yres.setText(myPreferences.getStringPref(ThumbMakerPreferences.RES_HEIGHT_PREF_NAME)); // aspect ratio checkbox aspect.setSelected( myPreferences .getStringPref(ThumbMakerPreferences.DO_MAINTAIN_ASPECT_PREF_NAME) .equalsIgnoreCase(ThumbMakerPreferences.BOOLEAN_TRUE_STRING)); // load the color values from the preferences int redValueNumber = myPreferences.getIntegerPref(ThumbMakerPreferences.RED_VALUE_PREF_NAME); int greenValueNumber = myPreferences.getIntegerPref(ThumbMakerPreferences.GREEN_VALUE_PREF_NAME); int blueValueNumber = myPreferences.getIntegerPref(ThumbMakerPreferences.BLUE_VALUE_PREF_NAME); // set the background color image colorBox.setBackground(new Color(redValueNumber, greenValueNumber, blueValueNumber)); // red slider red.setValue(redValueNumber); redValue.setText("" + redValueNumber); // green slider green.setValue(greenValueNumber); greenValue.setText("" + greenValueNumber); // blue slider blue.setValue(blueValueNumber); blueValue.setText("" + blueValueNumber); // algorithm combo box algorithm.setSelectedIndex( myPreferences.getIntegerPref(ThumbMakerPreferences.RESIZE_ALG_PREF_NAME)); // format combo box format.setSelectedIndex( myPreferences.getIntegerPref(ThumbMakerPreferences.THUMB_FORMAT_PREF_NAME)); // prepend field prepend.setText(myPreferences.getStringPref(ThumbMakerPreferences.STRING_TO_PREPEND_PREF_NAME)); // append field append.setText(myPreferences.getStringPref(ThumbMakerPreferences.STRING_TO_APPEND_PREF_NAME)); // output folder field output.setText( (new File(myPreferences.getStringPref(ThumbMakerPreferences.FILE_PATH_STRING_PREF_NAME))) .getAbsolutePath()); }
void initComponents() { JPanel mainPanel = new JPanel(new BorderLayout()); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS)); Color bgColor = Color.getHSBColor(0.58f, 0.17f, 0.95f); buttonPanel.setBackground(bgColor); Border empty = BorderFactory.createEmptyBorder(5, 5, 5, 5); buttonPanel.setBorder(empty); textField = new JTextField(75); buttonPanel.add(textField); buttonPanel.add(Box.createHorizontalStrut(10)); searchPHI = new JButton("Search PHI"); searchPHI.addActionListener(this); buttonPanel.add(searchPHI); buttonPanel.add(Box.createHorizontalStrut(10)); searchTrial = new JButton("Search Trial IDs"); searchTrial.addActionListener(this); buttonPanel.add(searchTrial); buttonPanel.add(Box.createHorizontalStrut(20)); buttonPanel.add(Box.createHorizontalGlue()); saveAs = new JCheckBox("Save As..."); saveAs.setBackground(bgColor); buttonPanel.add(saveAs); mainPanel.add(buttonPanel, BorderLayout.NORTH); JScrollPane scrollPane = new JScrollPane(); textPane = new ColorPane(); // textPane.setEditable(false); scrollPane.setViewportView(textPane); mainPanel.add(scrollPane, BorderLayout.CENTER); JPanel footerPanel = new JPanel(); footerPanel.setLayout(new BoxLayout(footerPanel, BoxLayout.X_AXIS)); footerPanel.setBackground(bgColor); message = new JLabel("Ready..."); footerPanel.add(message); mainPanel.add(footerPanel, BorderLayout.SOUTH); setTitle(windowTitle); addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent evt) { System.exit(0); } }); getContentPane().add(mainPanel, BorderLayout.CENTER); pack(); centerFrame(); }
private void audioSetup() { if (musicCB.isSelected()) { try { if (mp3 == null) { mp3 = new MP3(); } } catch (Exception e) { } mp3.play(); } }
public FooterPanel() { super(); this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); this.setBackground(Color.getHSBColor(0.58f, 0.17f, 0.95f)); subdirectories = new JCheckBox("Include subdirectories"); subdirectories.setBackground(background); this.add(subdirectories); this.add(Box.createHorizontalGlue()); extensionButton = new JButton(filter.getDescription()); this.add(extensionButton); this.add(Box.createHorizontalStrut(17)); extensionButton.addActionListener(this); }
/* User pressed the "Update" button. Read the GUI fields and send a SettingsMsg with the requested values. When the requested settings are bad, we silently update them to sane values. */ public void updateSettings() { SettingsMsg smsg = new SettingsMsg(); short alert = 0; short detect = 0; int checkInterval = Constants.DEFAULT_CHECK_INTERVAL; /* Extract current interval value, fixing bad values */ String intervalS = fieldInterval.getText().trim(); try { int newInterval = Integer.parseInt(intervalS); if (newInterval < 10) throw new NumberFormatException(); checkInterval = newInterval; } catch (NumberFormatException e) { /* Reset field when value is bad */ fieldInterval.setText("" + checkInterval); } /* Extract alert settings */ if (repLedCb.isSelected()) alert |= Constants.ALERT_LEDS; if (repSirenCb.isSelected()) alert |= Constants.ALERT_SOUND; if (repNeighboursCb.isSelected()) alert |= Constants.ALERT_RADIO; if (repServerCb.isSelected()) alert |= Constants.ALERT_ROOT; if (alert == 0) { /* If nothing select, force-select LEDs */ alert = Constants.ALERT_LEDS; repLedCb.setSelected(true); } /* Extract detection settings */ if (detDarkCb.isSelected()) detect |= Constants.DETECT_DARK; if (detAccelCb.isSelected()) detect |= Constants.DETECT_ACCEL; if (detect == 0) { /* If no detection selected, force-select dark */ detect = Constants.DETECT_DARK; detDarkCb.setSelected(true); } /* Build and send settings message */ smsg.set_alert(alert); smsg.set_detect(detect); smsg.set_checkInterval(checkInterval); try { mote.send(MoteIF.TOS_BCAST_ADDR, smsg); } catch (IOException e) { error("Cannot send message to mote"); } }
/** Invoked when an action occurs. */ public void actionPerformed(ActionEvent e) { Object source = e.getSource(); PacketLoggingService packetLogging = LoggingUtilsActivator.getPacketLoggingService(); if (source.equals(enableCheckBox)) { // turn it on/off in activator packetLogging.getConfiguration().setGlobalLoggingEnabled(enableCheckBox.isSelected()); updateButtonsState(); } else if (source.equals(sipProtocolCheckBox)) { packetLogging.getConfiguration().setSipLoggingEnabled(sipProtocolCheckBox.isSelected()); } else if (source.equals(jabberProtocolCheckBox)) { packetLogging.getConfiguration().setJabberLoggingEnabled(jabberProtocolCheckBox.isSelected()); } else if (source.equals(rtpProtocolCheckBox)) { packetLogging.getConfiguration().setRTPLoggingEnabled(rtpProtocolCheckBox.isSelected()); } else if (source.equals(ice4jProtocolCheckBox)) { packetLogging.getConfiguration().setIce4JLoggingEnabled(ice4jProtocolCheckBox.isSelected()); } else if (source.equals(archiveButton)) { // don't block the UI thread new Thread( new Runnable() { public void run() { collectLogs(); } }) .start(); } else if (source.equals(uploadLogsButton)) { // don't block the UI thread new Thread( new Runnable() { public void run() { uploadLogs(); } }) .start(); } }
/** * Used to initialize the componenets. Also called after every event that is required to update * other fields. */ public void setup() { if (firstTime) { defaultDirBackupPath = convertSet.getBackupPath().getPath(); defaultOneFileBackupPath = System.getProperty("user.dir"); firstTime = false; } dirTF.setText(convertSet.getSourcePath().getPath()); recursiveCheckBox.setSelected(converter.isRecurse()); if (converter.isStaticVersioning()) { staticVersioningRadioButton.setSelected(true); } else { dynamicVersioningRadioButton.setSelected(true); } backupTF.setText(defaultDirBackupPath); }
private void savePreferences() { // grab the preferences so that they can be filled in from the // user's selections ThumbMakerPreferences myPreferences = ThumbMakerPreferences.getInstance(); // x resolution text box myPreferences.setStringPref(ThumbMakerPreferences.RES_WIDTH_PREF_NAME, xres.getText()); // y resolution text box myPreferences.setStringPref(ThumbMakerPreferences.RES_HEIGHT_PREF_NAME, yres.getText()); // aspect ratio checkbox String aspectText; if (aspect.isSelected()) { aspectText = ThumbMakerPreferences.BOOLEAN_TRUE_STRING; } else aspectText = ThumbMakerPreferences.BOOLEAN_FALSE_STRING; myPreferences.setStringPref(ThumbMakerPreferences.DO_MAINTAIN_ASPECT_PREF_NAME, aspectText); // red slider myPreferences.setIntegerPref(ThumbMakerPreferences.RED_VALUE_PREF_NAME, red.getValue()); // green slider myPreferences.setIntegerPref(ThumbMakerPreferences.GREEN_VALUE_PREF_NAME, green.getValue()); // blue slider myPreferences.setIntegerPref(ThumbMakerPreferences.BLUE_VALUE_PREF_NAME, blue.getValue()); // algorithm combo box myPreferences.setIntegerPref( ThumbMakerPreferences.RESIZE_ALG_PREF_NAME, algorithm.getSelectedIndex()); // format combo box myPreferences.setIntegerPref( ThumbMakerPreferences.THUMB_FORMAT_PREF_NAME, format.getSelectedIndex()); // prepend field myPreferences.setStringPref( ThumbMakerPreferences.STRING_TO_PREPEND_PREF_NAME, prepend.getText()); // append field myPreferences.setStringPref(ThumbMakerPreferences.STRING_TO_APPEND_PREF_NAME, append.getText()); // output folder field myPreferences.setStringPref(ThumbMakerPreferences.FILE_PATH_STRING_PREF_NAME, output.getText()); }