List of usage examples for javax.swing JButton setBackground
@BeanProperty(preferred = true, visualUpdate = true, description = "The background color of the component.") public void setBackground(Color bg)
From source file:org.apache.jmeter.visualizers.StatGraphVisualizer.java
private JButton createColorBarButton(BarGraph barGraph, int index) { // Button/*from w w w. j a v a2 s . c o m*/ JButton colorBtn = new JButton(); colorBtn.setName(String.valueOf(index)); colorBtn.setFont(FONT_SMALL); colorBtn.addActionListener(this); colorBtn.setBackground(barGraph.getBackColor()); return colorBtn; }
From source file:org.micromanager.asidispim.AcquisitionPanel.java
public AcquisitionPanel(ScriptInterface gui, Devices devices, Properties props, Cameras cameras, Prefs prefs, StagePositionUpdater posUpdater, Positions positions, ControllerUtils controller, AutofocusUtils autofocus) {//ww w . j a v a2s .c o m super(MyStrings.PanelNames.ACQUSITION.toString(), new MigLayout("", "[center]0[center]0[center]", "0[top]0")); gui_ = gui; devices_ = devices; props_ = props; cameras_ = cameras; prefs_ = prefs; posUpdater_ = posUpdater; positions_ = positions; controller_ = controller; autofocus_ = autofocus; core_ = gui_.getMMCore(); numTimePointsDone_ = 0; sliceTiming_ = new SliceTiming(); lastAcquisitionPath_ = ""; lastAcquisitionName_ = ""; acq_ = null; channelNames_ = null; resetXaxisSpeed_ = true; acquisitionPanel_ = this; PanelUtils pu = new PanelUtils(prefs_, props_, devices_); // added to spinner controls where we should re-calculate the displayed // slice period, volume duration, and time lapse duration ChangeListener recalculateTimingDisplayCL = new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { if (advancedSliceTimingCB_.isSelected()) { // need to update sliceTiming_ from property values sliceTiming_ = getTimingFromAdvancedSettings(); } updateDurationLabels(); } }; // added to combobox controls where we should re-calculate the displayed // slice period, volume duration, and time lapse duration ActionListener recalculateTimingDisplayAL = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { updateDurationLabels(); } }; // start volume sub-panel volPanel_ = new JPanel(new MigLayout("", "[right]10[center]", "4[]8[]")); volPanel_.setBorder(PanelUtils.makeTitledBorder("Volume Settings")); if (!ASIdiSPIM.oSPIM) { } else { props_.setPropValue(Devices.Keys.PLUGIN, Properties.Keys.PLUGIN_NUM_SIDES, "1"); } volPanel_.add(new JLabel("Number of sides:")); String[] str12 = { "1", "2" }; numSides_ = pu.makeDropDownBox(str12, Devices.Keys.PLUGIN, Properties.Keys.PLUGIN_NUM_SIDES, str12[1]); numSides_.addActionListener(recalculateTimingDisplayAL); if (!ASIdiSPIM.oSPIM) { } else { numSides_.setEnabled(false); } volPanel_.add(numSides_, "wrap"); volPanel_.add(new JLabel("First side:")); String[] ab = { Devices.Sides.A.toString(), Devices.Sides.B.toString() }; if (!ASIdiSPIM.oSPIM) { } else { props_.setPropValue(Devices.Keys.PLUGIN, Properties.Keys.PLUGIN_FIRST_SIDE, Devices.Sides.A.toString()); } firstSide_ = pu.makeDropDownBox(ab, Devices.Keys.PLUGIN, Properties.Keys.PLUGIN_FIRST_SIDE, Devices.Sides.A.toString()); firstSide_.addActionListener(recalculateTimingDisplayAL); if (!ASIdiSPIM.oSPIM) { } else { firstSide_.setEnabled(false); } volPanel_.add(firstSide_, "wrap"); volPanel_.add(new JLabel("Delay before side [ms]:")); // used to read/write directly to galvo/micro-mirror firmware, but want different stage scan behavior delaySide_ = pu.makeSpinnerFloat(0, 10000, 0.25, Devices.Keys.PLUGIN, Properties.Keys.PLUGIN_DELAY_BEFORE_SIDE, 50); pu.addListenerLast(delaySide_, recalculateTimingDisplayCL); volPanel_.add(delaySide_, "wrap"); volPanel_.add(new JLabel("Slices per side:")); numSlices_ = pu.makeSpinnerInteger(1, 65000, Devices.Keys.PLUGIN, Properties.Keys.PLUGIN_NUM_SLICES, 20); pu.addListenerLast(numSlices_, recalculateTimingDisplayCL); volPanel_.add(numSlices_, "wrap"); volPanel_.add(new JLabel("Slice step size [\u00B5m]:")); stepSize_ = pu.makeSpinnerFloat(0, 100, 0.1, Devices.Keys.PLUGIN, Properties.Keys.PLUGIN_SLICE_STEP_SIZE, 1.0); pu.addListenerLast(stepSize_, recalculateTimingDisplayCL); // needed only for stage scanning b/c acceleration time related to speed volPanel_.add(stepSize_, "wrap"); // end volume sub-panel // start slice timing controls, have 2 options with advanced timing checkbox shared slicePanel_ = new JPanel(new MigLayout("", "[right]10[center]", "0[]0[]")); slicePanel_.setBorder(PanelUtils.makeTitledBorder("Slice Settings")); // start light sheet controls lightSheetPanel_ = new JPanel(new MigLayout("", "[right]10[center]", "4[]8")); lightSheetPanel_.add(new JLabel("Scan reset time [ms]:")); JSpinner lsScanReset = pu.makeSpinnerFloat(1, 100, 0.25, // practical lower limit of 1ms Devices.Keys.PLUGIN, Properties.Keys.PLUGIN_LS_SCAN_RESET, 3); lsScanReset.addChangeListener(PanelUtils.coerceToQuarterIntegers(lsScanReset)); pu.addListenerLast(lsScanReset, recalculateTimingDisplayCL); lightSheetPanel_.add(lsScanReset, "wrap"); lightSheetPanel_.add(new JLabel("Scan settle time [ms]:")); JSpinner lsScanSettle = pu.makeSpinnerFloat(0.25, 100, 0.25, Devices.Keys.PLUGIN, Properties.Keys.PLUGIN_LS_SCAN_SETTLE, 1); lsScanSettle.addChangeListener(PanelUtils.coerceToQuarterIntegers(lsScanSettle)); pu.addListenerLast(lsScanSettle, recalculateTimingDisplayCL); lightSheetPanel_.add(lsScanSettle, "wrap"); lightSheetPanel_.add(new JLabel("Shutter width [\u00B5m]:")); JSpinner lsShutterWidth = pu.makeSpinnerFloat(0.1, 100, 1, Devices.Keys.PLUGIN, Properties.Keys.PLUGIN_LS_SHUTTER_WIDTH, 5); pu.addListenerLast(lsShutterWidth, recalculateTimingDisplayCL); lightSheetPanel_.add(lsShutterWidth); // lightSheetPanel_.add(new JLabel("1 / (shutter speed):")); // JSpinner lsShutterSpeed = pu.makeSpinnerInteger(1, 10, // Devices.Keys.PLUGIN, Properties.Keys.PLUGIN_LS_SHUTTER_SPEED, 1); // lightSheetPanel_.add(lsShutterSpeed, "wrap"); // end light sheet controls // start "normal" (not light sheet) controls normalPanel_ = new JPanel(new MigLayout("", "[right]10[center]", "4[]8")); // out of order so we can reference it desiredSlicePeriod_ = pu.makeSpinnerFloat(1, 1000, 0.25, Devices.Keys.PLUGIN, Properties.Keys.PLUGIN_DESIRED_SLICE_PERIOD, 30); minSlicePeriodCB_ = pu.makeCheckBox("Minimize slice period", Properties.Keys.PREFS_MINIMIZE_SLICE_PERIOD, panelName_, false); minSlicePeriodCB_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean doMin = minSlicePeriodCB_.isSelected(); desiredSlicePeriod_.setEnabled(!doMin); desiredSlicePeriodLabel_.setEnabled(!doMin); recalculateSliceTiming(false); } }); normalPanel_.add(minSlicePeriodCB_, "span 2, wrap"); // special field that is enabled/disabled depending on whether advanced timing is enabled desiredSlicePeriodLabel_ = new JLabel("Slice period [ms]:"); normalPanel_.add(desiredSlicePeriodLabel_); normalPanel_.add(desiredSlicePeriod_, "wrap"); desiredSlicePeriod_.addChangeListener(PanelUtils.coerceToQuarterIntegers(desiredSlicePeriod_)); desiredSlicePeriod_.addChangeListener(recalculateTimingDisplayCL); // special field that is enabled/disabled depending on whether advanced timing is enabled desiredLightExposureLabel_ = new JLabel("Sample exposure [ms]:"); normalPanel_.add(desiredLightExposureLabel_); desiredLightExposure_ = pu.makeSpinnerFloat(1.0, 1000, 0.25, Devices.Keys.PLUGIN, Properties.Keys.PLUGIN_DESIRED_EXPOSURE, 8.5); desiredLightExposure_.addChangeListener(PanelUtils.coerceToQuarterIntegers(desiredLightExposure_)); desiredLightExposure_.addChangeListener(recalculateTimingDisplayCL); normalPanel_.add(desiredLightExposure_); // end normal simple slice timing controls slicePanelContainer_ = new JPanel(new MigLayout("", "0[center]0", "0[]0")); slicePanelContainer_.add( getSPIMCameraMode() == CameraModes.Keys.LIGHT_SHEET ? lightSheetPanel_ : normalPanel_, "growx"); slicePanel_.add(slicePanelContainer_, "span 2, center, wrap"); // special checkbox to use the advanced timing settings // action handler added below after defining components it enables/disables advancedSliceTimingCB_ = pu.makeCheckBox("Use advanced timing settings", Properties.Keys.PREFS_ADVANCED_SLICE_TIMING, panelName_, false); slicePanel_.add(advancedSliceTimingCB_, "span 2, left"); // end slice sub-panel // start advanced slice timing frame // visibility of this frame is controlled from advancedTiming checkbox // this frame is separate from main plugin window sliceFrameAdvanced_ = new MMFrame(); sliceFrameAdvanced_.setTitle("Advanced timing"); sliceFrameAdvanced_.loadPosition(100, 100); sliceAdvancedPanel_ = new JPanel(new MigLayout("", "[right]10[center]", "[]8[]")); sliceFrameAdvanced_.add(sliceAdvancedPanel_); class SliceFrameAdapter extends WindowAdapter { @Override public void windowClosing(WindowEvent e) { advancedSliceTimingCB_.setSelected(false); sliceFrameAdvanced_.savePosition(); } } sliceFrameAdvanced_.addWindowListener(new SliceFrameAdapter()); JLabel scanDelayLabel = new JLabel("Delay before scan [ms]:"); sliceAdvancedPanel_.add(scanDelayLabel); delayScan_ = pu.makeSpinnerFloat(0, 10000, 0.25, new Devices.Keys[] { Devices.Keys.GALVOA, Devices.Keys.GALVOB }, Properties.Keys.SPIM_DELAY_SCAN, 0); delayScan_.addChangeListener(PanelUtils.coerceToQuarterIntegers(delayScan_)); delayScan_.addChangeListener(recalculateTimingDisplayCL); sliceAdvancedPanel_.add(delayScan_, "wrap"); JLabel lineScanLabel = new JLabel("Lines scans per slice:"); sliceAdvancedPanel_.add(lineScanLabel); numScansPerSlice_ = pu.makeSpinnerInteger(1, 1000, new Devices.Keys[] { Devices.Keys.GALVOA, Devices.Keys.GALVOB }, Properties.Keys.SPIM_NUM_SCANSPERSLICE, 1); numScansPerSlice_.addChangeListener(recalculateTimingDisplayCL); sliceAdvancedPanel_.add(numScansPerSlice_, "wrap"); JLabel lineScanPeriodLabel = new JLabel("Line scan duration [ms]:"); sliceAdvancedPanel_.add(lineScanPeriodLabel); lineScanDuration_ = pu.makeSpinnerFloat(1, 10000, 0.25, new Devices.Keys[] { Devices.Keys.GALVOA, Devices.Keys.GALVOB }, Properties.Keys.SPIM_DURATION_SCAN, 10); lineScanDuration_.addChangeListener(PanelUtils.coerceToQuarterIntegers(lineScanDuration_)); lineScanDuration_.addChangeListener(recalculateTimingDisplayCL); sliceAdvancedPanel_.add(lineScanDuration_, "wrap"); JLabel delayLaserLabel = new JLabel("Delay before laser [ms]:"); sliceAdvancedPanel_.add(delayLaserLabel); delayLaser_ = pu.makeSpinnerFloat(0, 10000, 0.25, new Devices.Keys[] { Devices.Keys.GALVOA, Devices.Keys.GALVOB }, Properties.Keys.SPIM_DELAY_LASER, 0); delayLaser_.addChangeListener(PanelUtils.coerceToQuarterIntegers(delayLaser_)); delayLaser_.addChangeListener(recalculateTimingDisplayCL); sliceAdvancedPanel_.add(delayLaser_, "wrap"); JLabel durationLabel = new JLabel("Laser trig duration [ms]:"); sliceAdvancedPanel_.add(durationLabel); durationLaser_ = pu.makeSpinnerFloat(0, 10000, 0.25, new Devices.Keys[] { Devices.Keys.GALVOA, Devices.Keys.GALVOB }, Properties.Keys.SPIM_DURATION_LASER, 1); durationLaser_.addChangeListener(PanelUtils.coerceToQuarterIntegers(durationLaser_)); durationLaser_.addChangeListener(recalculateTimingDisplayCL); sliceAdvancedPanel_.add(durationLaser_, "span 2, wrap"); JLabel delayLabel = new JLabel("Delay before camera [ms]:"); sliceAdvancedPanel_.add(delayLabel); delayCamera_ = pu.makeSpinnerFloat(0, 10000, 0.25, new Devices.Keys[] { Devices.Keys.GALVOA, Devices.Keys.GALVOB }, Properties.Keys.SPIM_DELAY_CAMERA, 0); delayCamera_.addChangeListener(PanelUtils.coerceToQuarterIntegers(delayCamera_)); delayCamera_.addChangeListener(recalculateTimingDisplayCL); sliceAdvancedPanel_.add(delayCamera_, "wrap"); JLabel cameraLabel = new JLabel("Camera trig duration [ms]:"); sliceAdvancedPanel_.add(cameraLabel); durationCamera_ = pu.makeSpinnerFloat(0, 1000, 0.25, new Devices.Keys[] { Devices.Keys.GALVOA, Devices.Keys.GALVOB }, Properties.Keys.SPIM_DURATION_CAMERA, 0); durationCamera_.addChangeListener(PanelUtils.coerceToQuarterIntegers(durationCamera_)); durationCamera_.addChangeListener(recalculateTimingDisplayCL); sliceAdvancedPanel_.add(durationCamera_, "wrap"); JLabel exposureLabel = new JLabel("Camera exposure [ms]:"); sliceAdvancedPanel_.add(exposureLabel); exposureCamera_ = pu.makeSpinnerFloat(0, 1000, 0.25, Devices.Keys.PLUGIN, Properties.Keys.PLUGIN_ADVANCED_CAMERA_EXPOSURE, 10f); exposureCamera_.addChangeListener(recalculateTimingDisplayCL); sliceAdvancedPanel_.add(exposureCamera_, "wrap"); alternateBeamScanCB_ = pu.makeCheckBox("Alternate scan direction", Properties.Keys.PREFS_SCAN_OPPOSITE_DIRECTIONS, panelName_, false); sliceAdvancedPanel_.add(alternateBeamScanCB_, "center, span 2, wrap"); simpleTimingComponents_ = new JComponent[] { desiredLightExposure_, minSlicePeriodCB_, desiredSlicePeriodLabel_, desiredLightExposureLabel_ }; final JComponent[] advancedTimingComponents = { delayScan_, numScansPerSlice_, lineScanDuration_, delayLaser_, durationLaser_, delayCamera_, durationCamera_, exposureCamera_, alternateBeamScanCB_ }; PanelUtils.componentsSetEnabled(advancedTimingComponents, advancedSliceTimingCB_.isSelected()); PanelUtils.componentsSetEnabled(simpleTimingComponents_, !advancedSliceTimingCB_.isSelected()); // this action listener takes care of enabling/disabling inputs // of the advanced slice timing window // we call this to get GUI looking right ItemListener sliceTimingDisableGUIInputs = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { boolean enabled = advancedSliceTimingCB_.isSelected(); // set other components in this advanced timing frame PanelUtils.componentsSetEnabled(advancedTimingComponents, enabled); // also control some components in main volume settings sub-panel PanelUtils.componentsSetEnabled(simpleTimingComponents_, !enabled); desiredSlicePeriod_.setEnabled(!enabled && !minSlicePeriodCB_.isSelected()); desiredSlicePeriodLabel_.setEnabled(!enabled && !minSlicePeriodCB_.isSelected()); updateDurationLabels(); } }; // this action listener shows/hides the advanced timing frame ActionListener showAdvancedTimingFrame = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean enabled = advancedSliceTimingCB_.isSelected(); if (enabled) { sliceFrameAdvanced_.setVisible(enabled); } } }; sliceFrameAdvanced_.pack(); sliceFrameAdvanced_.setResizable(false); // end slice Frame // start repeat (time lapse) sub-panel timepointPanel_ = new JPanel(new MigLayout("", "[right]10[center]", "[]8[]")); useTimepointsCB_ = pu.makeCheckBox("Time points", Properties.Keys.PREFS_USE_TIMEPOINTS, panelName_, false); useTimepointsCB_.setToolTipText("Perform a time-lapse acquisition"); useTimepointsCB_.setEnabled(true); useTimepointsCB_.setFocusPainted(false); ComponentTitledBorder componentBorder = new ComponentTitledBorder(useTimepointsCB_, timepointPanel_, BorderFactory.createLineBorder(ASIdiSPIM.borderColor)); timepointPanel_.setBorder(componentBorder); ChangeListener recalculateTimeLapseDisplay = new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { updateActualTimeLapseDurationLabel(); } }; useTimepointsCB_.addChangeListener(recalculateTimeLapseDisplay); timepointPanel_.add(new JLabel("Number:")); numTimepoints_ = pu.makeSpinnerInteger(1, 100000, Devices.Keys.PLUGIN, Properties.Keys.PLUGIN_NUM_ACQUISITIONS, 1); numTimepoints_.addChangeListener(recalculateTimeLapseDisplay); numTimepoints_.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent arg0) { // update nrRepeats_ variable so the acquisition can be extended or shortened // as long as we have separate timepoints if (acquisitionRunning_.get() && getSavingSeparateFile()) { nrRepeats_ = getNumTimepoints(); } } }); timepointPanel_.add(numTimepoints_, "wrap"); timepointPanel_.add(new JLabel("Interval [s]:")); acquisitionInterval_ = pu.makeSpinnerFloat(0.1, 32000, 0.1, Devices.Keys.PLUGIN, Properties.Keys.PLUGIN_ACQUISITION_INTERVAL, 60); acquisitionInterval_.addChangeListener(recalculateTimeLapseDisplay); timepointPanel_.add(acquisitionInterval_, "wrap"); // enable/disable panel elements depending on checkbox state useTimepointsCB_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { PanelUtils.componentsSetEnabled(timepointPanel_, useTimepointsCB_.isSelected()); } }); PanelUtils.componentsSetEnabled(timepointPanel_, useTimepointsCB_.isSelected()); // initialize // end repeat sub-panel // start savePanel // TODO for now these settings aren't part of acquisition settings // TODO consider whether that should be changed final int textFieldWidth = 16; savePanel_ = new JPanel(new MigLayout("", "[right]10[center]8[left]", "[]4[]")); savePanel_.setBorder(PanelUtils.makeTitledBorder("Data Saving Settings")); separateTimePointsCB_ = pu.makeCheckBox("Separate viewer / file for each time point", Properties.Keys.PREFS_SEPARATE_VIEWERS_FOR_TIMEPOINTS, panelName_, false); saveCB_ = pu.makeCheckBox("Save while acquiring", Properties.Keys.PREFS_SAVE_WHILE_ACQUIRING, panelName_, false); // make sure that when separate viewer is enabled then saving gets enabled too separateTimePointsCB_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (separateTimePointsCB_.isSelected() && !saveCB_.isSelected()) { saveCB_.doClick(); // setSelected() won't work because need to call its listener } } }); savePanel_.add(separateTimePointsCB_, "span 3, left, wrap"); savePanel_.add(saveCB_, "skip 1, span 2, center, wrap"); JLabel dirRootLabel = new JLabel("Directory root:"); savePanel_.add(dirRootLabel); DefaultFormatter formatter = new DefaultFormatter(); formatter.setOverwriteMode(false); rootField_ = new JFormattedTextField(formatter); rootField_.setText(prefs_.getString(panelName_, Properties.Keys.PLUGIN_DIRECTORY_ROOT, "")); rootField_.addPropertyChangeListener(new PropertyChangeListener() { // will respond to commitEdit() as well as GUI edit on commit @Override public void propertyChange(PropertyChangeEvent evt) { prefs_.putString(panelName_, Properties.Keys.PLUGIN_DIRECTORY_ROOT, rootField_.getText()); } }); rootField_.setColumns(textFieldWidth); savePanel_.add(rootField_, "span 2"); JButton browseRootButton = new JButton(); browseRootButton.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { setRootDirectory(rootField_); prefs_.putString(panelName_, Properties.Keys.PLUGIN_DIRECTORY_ROOT, rootField_.getText()); } }); browseRootButton.setMargin(new Insets(2, 5, 2, 5)); browseRootButton.setText("..."); savePanel_.add(browseRootButton, "wrap"); JLabel namePrefixLabel = new JLabel(); namePrefixLabel.setText("Name prefix:"); savePanel_.add(namePrefixLabel); prefixField_ = new JFormattedTextField(formatter); prefixField_.setText(prefs_.getString(panelName_, Properties.Keys.PLUGIN_NAME_PREFIX, "acq")); prefixField_.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { prefs_.putString(panelName_, Properties.Keys.PLUGIN_NAME_PREFIX, prefixField_.getText()); } }); prefixField_.setColumns(textFieldWidth); savePanel_.add(prefixField_, "span 2, wrap"); // since we use the name field even for acquisitions in RAM, // we only need to gray out the directory-related components final JComponent[] saveComponents = { browseRootButton, rootField_, dirRootLabel }; PanelUtils.componentsSetEnabled(saveComponents, saveCB_.isSelected()); saveCB_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { PanelUtils.componentsSetEnabled(saveComponents, saveCB_.isSelected()); } }); // end save panel // start duration report panel durationPanel_ = new JPanel(new MigLayout("", "[right]6[left, 40%!]", "[]5[]")); durationPanel_.setBorder(PanelUtils.makeTitledBorder("Durations")); durationPanel_.setPreferredSize(new Dimension(125, 0)); // fix width so it doesn't constantly change depending on text durationPanel_.add(new JLabel("Slice:")); actualSlicePeriodLabel_ = new JLabel(); durationPanel_.add(actualSlicePeriodLabel_, "wrap"); durationPanel_.add(new JLabel("Volume:")); actualVolumeDurationLabel_ = new JLabel(); durationPanel_.add(actualVolumeDurationLabel_, "wrap"); durationPanel_.add(new JLabel("Total:")); actualTimeLapseDurationLabel_ = new JLabel(); durationPanel_.add(actualTimeLapseDurationLabel_, "wrap"); // end duration report panel buttonTestAcq_ = new JButton("Test Acquisition"); buttonTestAcq_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { runTestAcquisition(Devices.Sides.NONE); } }); buttonStart_ = new JToggleButton(); buttonStart_.setIconTextGap(6); buttonStart_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (isAcquisitionRequested()) { stopAcquisition(); } else { runAcquisition(); } } }); updateStartButton(); // call once to initialize, isSelected() will be false // make the size of the test button match the start button (easier on the eye) Dimension sizeStart = buttonStart_.getPreferredSize(); Dimension sizeTest = buttonTestAcq_.getPreferredSize(); sizeTest.height = sizeStart.height; buttonTestAcq_.setPreferredSize(sizeTest); acquisitionStatusLabel_ = new JLabel(""); acquisitionStatusLabel_.setBackground(prefixField_.getBackground()); acquisitionStatusLabel_.setOpaque(true); updateAcquisitionStatus(AcquisitionStatus.NONE); // Channel Panel (separate file for code) multiChannelPanel_ = new MultiChannelSubPanel(gui, devices_, props_, prefs_); multiChannelPanel_.addDurationLabelListener(this); // Position Panel final JPanel positionPanel = new JPanel(); positionPanel.setLayout(new MigLayout("flowx, fillx", "[right]10[left][10][]", "[]8[]")); usePositionsCB_ = pu.makeCheckBox("Multiple positions (XY)", Properties.Keys.PREFS_USE_MULTIPOSITION, panelName_, false); usePositionsCB_.setToolTipText("Acquire datasest at multiple postions"); usePositionsCB_.setEnabled(true); usePositionsCB_.setFocusPainted(false); componentBorder = new ComponentTitledBorder(usePositionsCB_, positionPanel, BorderFactory.createLineBorder(ASIdiSPIM.borderColor)); positionPanel.setBorder(componentBorder); usePositionsCB_.addChangeListener(recalculateTimingDisplayCL); final JButton editPositionListButton = new JButton("Edit position list..."); editPositionListButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { gui_.showXYPositionList(); } }); positionPanel.add(editPositionListButton); gridButton_ = new JButton("XYZ grid..."); positionPanel.add(gridButton_, "wrap"); // start XYZ grid frame // visibility of this frame is controlled from XYZ grid button // this frame is separate from main plugin window gridXPanel_ = new JPanel(new MigLayout("", "[right]10[center]", "[]8[]")); useXGridCB_ = pu.makeCheckBox("Slices from stage coordinates", Properties.Keys.PREFS_USE_X_GRID, panelName_, true); useXGridCB_.setEnabled(true); useXGridCB_.setFocusPainted(false); componentBorder = new ComponentTitledBorder(useXGridCB_, gridXPanel_, BorderFactory.createLineBorder(ASIdiSPIM.borderColor)); gridXPanel_.setBorder(componentBorder); // enable/disable panel elements depending on checkbox state useXGridCB_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { PanelUtils.componentsSetEnabled(gridXPanel_, useXGridCB_.isSelected()); } }); gridXPanel_.add(new JLabel("X start [um]:")); gridXStartField_ = pu.makeFloatEntryField(panelName_, "Grid_X_Start", -400, 5); gridXStartField_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { updateGridXCount(); } }); gridXPanel_.add(gridXStartField_); JButton tmp_but = new JButton("Set"); tmp_but.setBackground(Color.red); tmp_but.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { gridXStartField_.setValue(positions_.getUpdatedPosition(Devices.Keys.XYSTAGE, Directions.X)); updateGridXCount(); } }); gridXPanel_.add(tmp_but, "wrap"); gridXPanel_.add(new JLabel("X stop [um]:")); gridXStopField_ = pu.makeFloatEntryField(panelName_, "Grid_X_Stop", 400, 5); gridXStopField_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { updateGridXCount(); } }); gridXPanel_.add(gridXStopField_); tmp_but = new JButton("Set"); tmp_but.setBackground(Color.red); tmp_but.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { gridXStopField_.setValue(positions_.getUpdatedPosition(Devices.Keys.XYSTAGE, Directions.X)); updateGridXCount(); } }); gridXPanel_.add(tmp_but, "wrap"); gridXPanel_.add(new JLabel("X delta [um]:")); gridXDeltaField_ = pu.makeFloatEntryField(panelName_, "Grid_X_Delta", 3, 5); gridXDeltaField_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { updateGridXCount(); } }); gridXPanel_.add(gridXDeltaField_, "wrap"); // tmp_but = new JButton("Set"); // tmp_but.setBackground(Color.red); // tmp_but.addActionListener(new ActionListener() { // @Override // public void actionPerformed(ActionEvent arg0) { // // TODO figure out spacing, maybe to make reslicing trivial // updateGridXCount(); // } // }); // gridPanel_.add(tmp_but, "wrap"); gridXPanel_.add(new JLabel("Slice count:")); gridXCount_ = new JLabel(""); gridXPanel_.add(gridXCount_, "wrap"); updateGridXCount(); PanelUtils.componentsSetEnabled(gridXPanel_, useXGridCB_.isSelected()); // initialize gridYPanel_ = new JPanel(new MigLayout("", "[right]10[center]", "[]8[]")); useYGridCB_ = pu.makeCheckBox("Grid in Y", Properties.Keys.PREFS_USE_Y_GRID, panelName_, true); useYGridCB_.setEnabled(true); useYGridCB_.setFocusPainted(false); componentBorder = new ComponentTitledBorder(useYGridCB_, gridYPanel_, BorderFactory.createLineBorder(ASIdiSPIM.borderColor)); gridYPanel_.setBorder(componentBorder); // enable/disable panel elements depending on checkbox state useYGridCB_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { PanelUtils.componentsSetEnabled(gridYPanel_, useYGridCB_.isSelected()); } }); gridYPanel_.add(new JLabel("Y start [um]:")); gridYStartField_ = pu.makeFloatEntryField(panelName_, "Grid_Y_Start", -1200, 5); gridYStartField_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { updateGridYCount(); } }); gridYPanel_.add(gridYStartField_); tmp_but = new JButton("Set"); tmp_but.setBackground(Color.red); tmp_but.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { gridYStartField_.setValue(positions_.getUpdatedPosition(Devices.Keys.XYSTAGE, Directions.Y)); updateGridYCount(); } }); gridYPanel_.add(tmp_but, "wrap"); gridYPanel_.add(new JLabel("Y stop [um]:")); gridYStopField_ = pu.makeFloatEntryField(panelName_, "Grid_Y_Stop", 1200, 5); gridYStopField_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { updateGridYCount(); } }); gridYPanel_.add(gridYStopField_); tmp_but = new JButton("Set"); tmp_but.setBackground(Color.red); tmp_but.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { gridYStopField_.setValue(positions_.getUpdatedPosition(Devices.Keys.XYSTAGE, Directions.Y)); updateGridYCount(); } }); gridYPanel_.add(tmp_but, "wrap"); gridYPanel_.add(new JLabel("Y delta [um]:")); gridYDeltaField_ = pu.makeFloatEntryField(panelName_, "Grid_Y_Delta", 700, 5); gridYDeltaField_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { updateGridYCount(); } }); gridYPanel_.add(gridYDeltaField_); tmp_but = new JButton("Set"); tmp_but.setBackground(Color.red); tmp_but.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { Devices.Keys camKey = isFirstSideA() ? Devices.Keys.CAMERAA : Devices.Keys.CAMERAB; int height; try { height = core_.getROI(devices_.getMMDevice(camKey)).height; } catch (Exception e) { height = 1; } float pixelSize = (float) core_.getPixelSizeUm(); double delta = height * pixelSize; double overlap = props_.getPropValueFloat(Devices.Keys.PLUGIN, Properties.Keys.PLUGIN_GRID_OVERLAP_PERCENT); delta *= (1 - overlap / 100); // sanity checks, would be better handled with exceptions or more formal checks if (height > 4100 || height < 4 || pixelSize < 1e-6) { return; } gridYDeltaField_.setValue(Math.round(delta)); updateGridYCount(); } }); gridYPanel_.add(tmp_but, "wrap"); gridYPanel_.add(new JLabel("Y count:")); gridYCount_ = new JLabel(""); gridYPanel_.add(gridYCount_, "wrap"); updateGridYCount(); PanelUtils.componentsSetEnabled(gridYPanel_, useYGridCB_.isSelected()); // initialize gridZPanel_ = new JPanel(new MigLayout("", "[right]10[center]", "[]8[]")); useZGridCB_ = pu.makeCheckBox("Grid in Z", Properties.Keys.PREFS_USE_Z_GRID, panelName_, true); useZGridCB_.setEnabled(true); useZGridCB_.setFocusPainted(false); componentBorder = new ComponentTitledBorder(useZGridCB_, gridZPanel_, BorderFactory.createLineBorder(ASIdiSPIM.borderColor)); gridZPanel_.setBorder(componentBorder); // enable/disable panel elements depending on checkbox state useZGridCB_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { PanelUtils.componentsSetEnabled(gridZPanel_, useZGridCB_.isSelected()); } }); gridZPanel_.add(new JLabel("Z start [um]:")); gridZStartField_ = pu.makeFloatEntryField(panelName_, "Grid_Z_Start", 0, 5); gridZStartField_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { updateGridZCount(); } }); gridZPanel_.add(gridZStartField_); tmp_but = new JButton("Set"); tmp_but.setBackground(Color.red); tmp_but.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { gridZStartField_.setValue(positions_.getUpdatedPosition(Devices.Keys.UPPERZDRIVE)); updateGridZCount(); } }); gridZPanel_.add(tmp_but, "wrap"); gridZPanel_.add(new JLabel("Z stop [um]:")); gridZStopField_ = pu.makeFloatEntryField(panelName_, "Grid_Z_Stop", -800, 5); gridZStopField_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { updateGridZCount(); } }); gridZPanel_.add(gridZStopField_); tmp_but = new JButton("Set"); tmp_but.setBackground(Color.red); tmp_but.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { gridZStopField_.setValue(positions_.getUpdatedPosition(Devices.Keys.UPPERZDRIVE)); updateGridZCount(); } }); gridZPanel_.add(tmp_but, "wrap"); gridZPanel_.add(new JLabel("Z delta [um]:")); gridZDeltaField_ = pu.makeFloatEntryField(panelName_, "Grid_Z_Delta", 400, 5); gridZDeltaField_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { updateGridZCount(); } }); gridZPanel_.add(gridZDeltaField_); tmp_but = new JButton("Set"); tmp_but.setBackground(Color.red); tmp_but.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { Devices.Keys camKey = isFirstSideA() ? Devices.Keys.CAMERAA : Devices.Keys.CAMERAB; int width; try { width = core_.getROI(devices_.getMMDevice(camKey)).width; } catch (Exception e) { width = 1; } float pixelSize = (float) core_.getPixelSizeUm(); // sanity checks, would be better handled with exceptions or more formal checks if (width > 4100 || width < 4 || pixelSize < 1e-6) { return; } double delta = width * pixelSize / Math.sqrt(2); double overlap = props_.getPropValueFloat(Devices.Keys.PLUGIN, Properties.Keys.PLUGIN_GRID_OVERLAP_PERCENT); delta *= (1 - overlap / 100); gridZDeltaField_.setValue(Math.round(delta)); updateGridZCount(); } }); gridZPanel_.add(tmp_but, "wrap"); gridZPanel_.add(new JLabel("Z count:")); gridZCount_ = new JLabel(""); gridZPanel_.add(gridZCount_, "wrap"); updateGridZCount(); PanelUtils.componentsSetEnabled(gridZPanel_, useZGridCB_.isSelected()); // initialize gridSettingsPanel_ = new JPanel(new MigLayout("", "[right]10[center]", "[]8[]")); gridSettingsPanel_.setBorder(PanelUtils.makeTitledBorder("Grid settings")); gridSettingsPanel_.add(new JLabel("Overlap (Y and Z) [%]:")); JSpinner tileOverlapPercent = pu.makeSpinnerFloat(0, 100, 1, Devices.Keys.PLUGIN, Properties.Keys.PLUGIN_GRID_OVERLAP_PERCENT, 10); gridSettingsPanel_.add(tileOverlapPercent, "wrap"); clearYZGridCB_ = pu.makeCheckBox("Clear position list if YZ unused", Properties.Keys.PREFS_CLEAR_YZ_GRID, panelName_, true); gridSettingsPanel_.add(clearYZGridCB_, "span 2"); computeGridButton_ = new JButton("Compute grid"); computeGridButton_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { final boolean useX = useXGridCB_.isSelected(); final boolean useY = useYGridCB_.isSelected(); final boolean useZ = useZGridCB_.isSelected(); final int numX = useX ? updateGridXCount() : 1; final int numY = useY ? updateGridYCount() : 1; final int numZ = useZ ? updateGridZCount() : 1; double centerX = (((Double) gridXStartField_.getValue()) + ((Double) gridXStopField_.getValue())) / 2; double centerY = (((Double) gridYStartField_.getValue()) + ((Double) gridYStopField_.getValue())) / 2; double centerZ = (((Double) gridZStartField_.getValue()) + ((Double) gridZStopField_.getValue())) / 2; double deltaX = (Double) gridXDeltaField_.getValue(); double deltaY = (Double) gridYDeltaField_.getValue(); double deltaZ = (Double) gridZDeltaField_.getValue(); double startY = centerY - deltaY * (numY - 1) / 2; double startZ = centerZ - deltaZ * (numZ - 1) / 2; String xy_device = devices_.getMMDevice(Devices.Keys.XYSTAGE); String z_device = devices_.getMMDevice(Devices.Keys.UPPERZDRIVE); if (useX) { try { setVolumeSliceStepSize(Math.abs(deltaX) / Math.sqrt(2)); setVolumeSlicesPerVolume(numX); if (!useY && !useZ) { // move to X center if we aren't generating position list with it positions_.setPosition(Devices.Keys.XYSTAGE, Directions.X, centerX); } } catch (Exception ex) { // not sure what to do in case of error so ignore } } else { // use current X value as center; this was original behavior centerX = positions_.getUpdatedPosition(Devices.Keys.XYSTAGE, Directions.X); } // if we aren't using one axis, use the current position instead of GUI position if (useY && !useZ) { startZ = positions_.getUpdatedPosition(Devices.Keys.UPPERZDRIVE); } if (useZ && !useY) { startY = positions_.getUpdatedPosition(Devices.Keys.XYSTAGE, Directions.Y); } if (!useY && !useZ && !clearYZGridCB_.isSelected()) { return; } PositionList pl; try { pl = gui_.getPositionList(); } catch (MMScriptException e) { pl = new PositionList(); } boolean isPositionListEmpty = pl.getNumberOfPositions() == 0; if (!isPositionListEmpty) { boolean overwrite = MyDialogUtils.getConfirmDialogResult( "Do you really want to overwrite the existing position list?", JOptionPane.YES_NO_OPTION); if (!overwrite) { return; // nothing to do } } pl = new PositionList(); if (useY || useZ) { for (int iZ = 0; iZ < numZ; ++iZ) { for (int iY = 0; iY < numY; ++iY) { MultiStagePosition msp = new MultiStagePosition(); StagePosition s = new StagePosition(); s.stageName = xy_device; s.numAxes = 2; s.x = centerX; s.y = startY + iY * deltaY; msp.add(s); StagePosition s2 = new StagePosition(); s2.stageName = z_device; s2.x = startZ + iZ * deltaZ; msp.add(s2); msp.setLabel("Pos_" + iZ + "_" + iY); pl.addPosition(msp); } } } try { gui_.setPositionList(pl); } catch (MMScriptException ex) { MyDialogUtils.showError(ex, "Couldn't overwrite position list with generated YZ grid"); } } }); gridFrame_ = new MMFrame(); gridFrame_.setTitle("XYZ Grid"); gridFrame_.loadPosition(100, 100); gridPanel_ = new JPanel(new MigLayout("", "[right]10[center]", "[]8[]")); gridFrame_.add(gridPanel_); class GridFrameAdapter extends WindowAdapter { @Override public void windowClosing(WindowEvent e) { gridButton_.setSelected(false); gridFrame_.savePosition(); } } gridFrame_.addWindowListener(new GridFrameAdapter()); gridButton_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { gridFrame_.setVisible(true); } }); gridPanel_.add(gridYPanel_); gridPanel_.add(gridZPanel_, "wrap"); gridPanel_.add(gridXPanel_, "spany 2"); gridPanel_.add(gridSettingsPanel_, "growx, wrap"); gridPanel_.add(computeGridButton_, "growx, growy"); gridFrame_.pack(); gridFrame_.setResizable(false); // end YZ grid frame positionPanel.add(new JLabel("Post-move delay [ms]:")); positionDelay_ = pu.makeSpinnerFloat(0.0, 10000.0, 100.0, Devices.Keys.PLUGIN, Properties.Keys.PLUGIN_POSITION_DELAY, 0.0); positionPanel.add(positionDelay_, "wrap"); // enable/disable panel elements depending on checkbox state usePositionsCB_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { PanelUtils.componentsSetEnabled(positionPanel, usePositionsCB_.isSelected()); gridButton_.setEnabled(true); // leave this always enabled } }); PanelUtils.componentsSetEnabled(positionPanel, usePositionsCB_.isSelected()); // initialize gridButton_.setEnabled(true); // leave this always enabled // end of Position panel // checkbox to use navigation joystick settings or not // an "orphan" UI element navigationJoysticksCB_ = new JCheckBox("Use Navigation joystick settings"); navigationJoysticksCB_ .setSelected(prefs_.getBoolean(panelName_, Properties.Keys.PLUGIN_USE_NAVIGATION_JOYSTICKS, false)); navigationJoysticksCB_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { updateJoysticks(); prefs_.putBoolean(panelName_, Properties.Keys.PLUGIN_USE_NAVIGATION_JOYSTICKS, navigationJoysticksCB_.isSelected()); } }); // checkbox to signal that autofocus should be used during acquisition // another orphan UI element useAutofocusCB_ = new JCheckBox("Autofocus periodically"); useAutofocusCB_ .setSelected(prefs_.getBoolean(panelName_, Properties.Keys.PLUGIN_ACQUSITION_USE_AUTOFOCUS, false)); useAutofocusCB_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { prefs_.putBoolean(panelName_, Properties.Keys.PLUGIN_ACQUSITION_USE_AUTOFOCUS, useAutofocusCB_.isSelected()); } }); // checkbox to signal that movement should be corrected during acquisition // Yet another orphan UI element useMovementCorrectionCB_ = new JCheckBox("Motion correction"); useMovementCorrectionCB_.setSelected( prefs_.getBoolean(panelName_, Properties.Keys.PLUGIN_ACQUSITION_USE_MOVEMENT_CORRECTION, false)); useMovementCorrectionCB_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { prefs_.putBoolean(panelName_, Properties.Keys.PLUGIN_ACQUSITION_USE_MOVEMENT_CORRECTION, useMovementCorrectionCB_.isSelected()); } }); // set up tabbed panels for GUI // make 3 columns as own JPanels to get vertical space right // in each column without dependencies on other columns leftColumnPanel_ = new JPanel(new MigLayout("", "[]", "[]6[]10[]10[]")); leftColumnPanel_.add(durationPanel_, "split 2"); leftColumnPanel_.add(timepointPanel_, "wrap, growx"); leftColumnPanel_.add(savePanel_, "wrap"); leftColumnPanel_.add(new JLabel("Acquisition mode: "), "split 2, right"); AcquisitionModes acqModes = new AcquisitionModes(devices_, prefs_); spimMode_ = acqModes.getComboBox(); spimMode_.addActionListener(recalculateTimingDisplayAL); leftColumnPanel_.add(spimMode_, "left, wrap"); leftColumnPanel_.add(buttonStart_, "split 3, left"); leftColumnPanel_.add(new JLabel(" ")); leftColumnPanel_.add(buttonTestAcq_, "wrap"); leftColumnPanel_.add(new JLabel("Status:"), "split 2, left"); leftColumnPanel_.add(acquisitionStatusLabel_); centerColumnPanel_ = new JPanel(new MigLayout("", "[]", "[]")); centerColumnPanel_.add(positionPanel, "growx, wrap"); centerColumnPanel_.add(multiChannelPanel_, "wrap"); centerColumnPanel_.add(navigationJoysticksCB_, "wrap"); centerColumnPanel_.add(useAutofocusCB_, "split 2"); centerColumnPanel_.add(useMovementCorrectionCB_); rightColumnPanel_ = new JPanel(new MigLayout("", "[center]0", "[]0[]")); rightColumnPanel_.add(volPanel_, "growx, wrap"); rightColumnPanel_.add(slicePanel_, "growx"); // add the column panels to the main panel super.add(leftColumnPanel_); super.add(centerColumnPanel_); super.add(rightColumnPanel_); // properly initialize the advanced slice timing advancedSliceTimingCB_.addItemListener(sliceTimingDisableGUIInputs); sliceTimingDisableGUIInputs.itemStateChanged(null); advancedSliceTimingCB_.addActionListener(showAdvancedTimingFrame); // included is calculating slice timing updateDurationLabels(); // update local variables zStepUm_ = PanelUtils.getSpinnerFloatValue(stepSize_); refreshXYZPositions(); }
From source file:org.ohdsi.whiteRabbit.WhiteRabbitMain.java
private JPanel createLocationsPanel() { JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.weightx = 0.5;/*from ww w. j a v a 2 s . c o m*/ JPanel folderPanel = new JPanel(); folderPanel.setLayout(new BoxLayout(folderPanel, BoxLayout.X_AXIS)); folderPanel.setBorder(BorderFactory.createTitledBorder("Working folder")); folderField = new JTextField(); folderField.setText((new File("").getAbsolutePath())); folderField.setToolTipText("The folder where all output will be written"); folderPanel.add(folderField); JButton pickButton = new JButton("Pick folder"); pickButton.setToolTipText("Pick a different working folder"); folderPanel.add(pickButton); pickButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { pickFolder(); } }); componentsToDisableWhenRunning.add(pickButton); c.gridx = 0; c.gridy = 0; c.gridwidth = 1; panel.add(folderPanel, c); JPanel sourcePanel = new JPanel(); sourcePanel.setLayout(new GridLayout(0, 2)); sourcePanel.setBorder(BorderFactory.createTitledBorder("Source data location")); sourcePanel.add(new JLabel("Data type")); sourceType = new JComboBox<String>(new String[] { "Delimited text files", "MySQL", "Oracle", "SQL Server", "PostgreSQL", "MS Access", "PDW", "Redshift", "Teradata" }); sourceType.setToolTipText("Select the type of source data available"); sourceType.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent arg0) { sourceIsFiles = arg0.getItem().toString().equals("Delimited text files"); sourceServerField.setEnabled(!sourceIsFiles); sourceUserField.setEnabled(!sourceIsFiles); sourcePasswordField.setEnabled(!sourceIsFiles); sourceDatabaseField.setEnabled(!sourceIsFiles); sourceDelimiterField.setEnabled(sourceIsFiles); addAllButton.setEnabled(!sourceIsFiles); if (!sourceIsFiles && arg0.getItem().toString().equals("Oracle")) { sourceServerField.setToolTipText( "For Oracle servers this field contains the SID, servicename, and optionally the port: '<host>/<sid>', '<host>:<port>/<sid>', '<host>/<service name>', or '<host>:<port>/<service name>'"); sourceUserField.setToolTipText( "For Oracle servers this field contains the name of the user used to log in"); sourcePasswordField.setToolTipText( "For Oracle servers this field contains the password corresponding to the user"); sourceDatabaseField.setToolTipText( "For Oracle servers this field contains the schema (i.e. 'user' in Oracle terms) containing the source tables"); } else if (!sourceIsFiles && arg0.getItem().toString().equals("PostgreSQL")) { sourceServerField.setToolTipText( "For PostgreSQL servers this field contains the host name and database name (<host>/<database>)"); sourceUserField.setToolTipText("The user used to log in to the server"); sourcePasswordField.setToolTipText("The password used to log in to the server"); sourceDatabaseField.setToolTipText( "For PostgreSQL servers this field contains the schema containing the source tables"); } else if (!sourceIsFiles) { sourceServerField .setToolTipText("This field contains the name or IP address of the database server"); if (arg0.getItem().toString().equals("SQL Server")) sourceUserField.setToolTipText( "The user used to log in to the server. Optionally, the domain can be specified as <domain>/<user> (e.g. 'MyDomain/Joe')"); else sourceUserField.setToolTipText("The user used to log in to the server"); sourcePasswordField.setToolTipText("The password used to log in to the server"); sourceDatabaseField.setToolTipText("The name of the database containing the source tables"); } } }); sourcePanel.add(sourceType); sourcePanel.add(new JLabel("Server location")); sourceServerField = new JTextField("127.0.0.1"); sourceServerField.setEnabled(false); sourcePanel.add(sourceServerField); sourcePanel.add(new JLabel("User name")); sourceUserField = new JTextField(""); sourceUserField.setEnabled(false); sourcePanel.add(sourceUserField); sourcePanel.add(new JLabel("Password")); sourcePasswordField = new JPasswordField(""); sourcePasswordField.setEnabled(false); sourcePanel.add(sourcePasswordField); sourcePanel.add(new JLabel("Database name")); sourceDatabaseField = new JTextField(""); sourceDatabaseField.setEnabled(false); sourcePanel.add(sourceDatabaseField); sourcePanel.add(new JLabel("Delimiter")); sourceDelimiterField = new JTextField(","); sourceDelimiterField.setToolTipText("The delimiter that separates values. Enter 'tab' for tab."); sourcePanel.add(sourceDelimiterField); c.gridx = 0; c.gridy = 1; c.gridwidth = 1; panel.add(sourcePanel, c); JPanel testConnectionButtonPanel = new JPanel(); testConnectionButtonPanel.setLayout(new BoxLayout(testConnectionButtonPanel, BoxLayout.X_AXIS)); testConnectionButtonPanel.add(Box.createHorizontalGlue()); JButton testConnectionButton = new JButton("Test connection"); testConnectionButton.setBackground(new Color(151, 220, 141)); testConnectionButton.setToolTipText("Test the connection"); testConnectionButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { testConnection(getSourceDbSettings()); } }); componentsToDisableWhenRunning.add(testConnectionButton); testConnectionButtonPanel.add(testConnectionButton); c.gridx = 0; c.gridy = 2; c.gridwidth = 1; panel.add(testConnectionButtonPanel, c); return panel; }
From source file:org.ohdsi.whiteRabbit.WhiteRabbitMain.java
private JPanel createScanPanel() { JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); JPanel tablePanel = new JPanel(); tablePanel.setLayout(new BorderLayout()); tablePanel.setBorder(new TitledBorder("Tables to scan")); tableList = new JList<String>(); tableList.setToolTipText("Specify the tables (or CSV files) to be scanned here"); tablePanel.add(new JScrollPane(tableList), BorderLayout.CENTER); JPanel tableButtonPanel = new JPanel(); tableButtonPanel.setLayout(new GridLayout(3, 1)); addAllButton = new JButton("Add all in DB"); addAllButton.setToolTipText("Add all tables in the database"); addAllButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { addAllTables();/*from w ww .j a va 2s. c o m*/ } }); addAllButton.setEnabled(false); tableButtonPanel.add(addAllButton); JButton addButton = new JButton("Add"); addButton.setToolTipText("Add tables to list"); addButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { pickTables(); } }); tableButtonPanel.add(addButton); JButton removeButton = new JButton("Remove"); removeButton.setToolTipText("Remove tables from list"); removeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { removeTables(); } }); tableButtonPanel.add(removeButton); tablePanel.add(tableButtonPanel, BorderLayout.EAST); panel.add(tablePanel, BorderLayout.CENTER); JPanel southPanel = new JPanel(); southPanel.setLayout(new BoxLayout(southPanel, BoxLayout.Y_AXIS)); JPanel scanOptionsPanel = new JPanel(); scanOptionsPanel.setLayout(new BoxLayout(scanOptionsPanel, BoxLayout.X_AXIS)); scanValueScan = new JCheckBox("Scan field values", true); scanValueScan.setToolTipText("Include a frequency count of field values in the scan report"); scanValueScan.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent arg0) { scanMinCellCount.setEnabled(((JCheckBox) arg0.getSource()).isSelected()); scanRowCount.setEnabled(((JCheckBox) arg0.getSource()).isSelected()); scanValuesCount.setEnabled(((JCheckBox) arg0.getSource()).isSelected()); } }); scanOptionsPanel.add(scanValueScan); scanOptionsPanel.add(Box.createHorizontalGlue()); scanOptionsPanel.add(new JLabel("Min cell count ")); scanMinCellCount = new JSpinner(); scanMinCellCount.setValue(5); scanMinCellCount.setToolTipText("Minimum frequency for a field value to be included in the report"); scanOptionsPanel.add(scanMinCellCount); scanOptionsPanel.add(Box.createHorizontalGlue()); scanOptionsPanel.add(new JLabel("Max distinct values ")); scanValuesCount = new JComboBox<String>(new String[] { "100", "1,000", "10,000" }); scanValuesCount.setSelectedIndex(1); scanValuesCount.setToolTipText("Maximum number of distinct values per field to be reported"); scanOptionsPanel.add(scanValuesCount); scanOptionsPanel.add(Box.createHorizontalGlue()); scanOptionsPanel.add(new JLabel("Rows per table ")); scanRowCount = new JComboBox<String>(new String[] { "100,000", "500,000", "1 million", "all" }); scanRowCount.setSelectedIndex(0); scanRowCount.setToolTipText("Maximum number of rows per table to be scanned for field values"); scanOptionsPanel.add(scanRowCount); southPanel.add(scanOptionsPanel); southPanel.add(Box.createVerticalStrut(3)); JPanel scanButtonPanel = new JPanel(); scanButtonPanel.setLayout(new BoxLayout(scanButtonPanel, BoxLayout.X_AXIS)); scanButtonPanel.add(Box.createHorizontalGlue()); JButton scanButton = new JButton("Scan tables"); scanButton.setBackground(new Color(151, 220, 141)); scanButton.setToolTipText("Scan the selected tables"); scanButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scanRun(); } }); componentsToDisableWhenRunning.add(scanButton); scanButtonPanel.add(scanButton); southPanel.add(scanButtonPanel); panel.add(southPanel, BorderLayout.SOUTH); return panel; }
From source file:org.ohdsi.whiteRabbit.WhiteRabbitMain.java
private JPanel createFakeDataPanel() { JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.weightx = 0.5;//from w w w . j a va2 s .c o m JPanel folderPanel = new JPanel(); folderPanel.setLayout(new BoxLayout(folderPanel, BoxLayout.X_AXIS)); folderPanel.setBorder(BorderFactory.createTitledBorder("Scan report file")); scanReportFileField = new JTextField(); scanReportFileField.setText((new File("ScanReport.xlsx").getAbsolutePath())); scanReportFileField.setToolTipText( "The path to the scan report that will be used as a template to generate the fake data"); folderPanel.add(scanReportFileField); JButton pickButton = new JButton("Pick file"); pickButton.setToolTipText("Pick a scan report file"); folderPanel.add(pickButton); pickButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { pickScanReportFile(); } }); componentsToDisableWhenRunning.add(pickButton); c.gridx = 0; c.gridy = 0; c.gridwidth = 1; panel.add(folderPanel, c); JPanel targetPanel = new JPanel(); targetPanel.setLayout(new GridLayout(0, 2)); targetPanel.setBorder(BorderFactory.createTitledBorder("Target data location")); targetPanel.add(new JLabel("Data type")); targetType = new JComboBox<String>( new String[] { "Delimited text files", "MySQL", "Oracle", "SQL Server", "PostgreSQL" }); // targetType = new JComboBox(new String[] { "Delimited text files", "MySQL" }); targetType.setToolTipText("Select the type of source data available"); targetType.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent arg0) { targetIsFiles = arg0.getItem().toString().equals("Delimited text files"); targetServerField.setEnabled(!targetIsFiles); targetUserField.setEnabled(!targetIsFiles); targetPasswordField.setEnabled(!targetIsFiles); targetDatabaseField.setEnabled(!targetIsFiles); targetCSVFormat.setEnabled(targetIsFiles); if (!targetIsFiles && arg0.getItem().toString().equals("Oracle")) { targetServerField.setToolTipText( "For Oracle servers this field contains the SID, servicename, and optionally the port: '<host>/<sid>', '<host>:<port>/<sid>', '<host>/<service name>', or '<host>:<port>/<service name>'"); targetUserField.setToolTipText( "For Oracle servers this field contains the name of the user used to log in"); targetPasswordField.setToolTipText( "For Oracle servers this field contains the password corresponding to the user"); targetDatabaseField.setToolTipText( "For Oracle servers this field contains the schema (i.e. 'user' in Oracle terms) containing the source tables"); } else if (!targetIsFiles && arg0.getItem().toString().equals("PostgreSQL")) { targetServerField.setToolTipText( "For PostgreSQL servers this field contains the host name and database name (<host>/<database>)"); targetUserField.setToolTipText("The user used to log in to the server"); targetPasswordField.setToolTipText("The password used to log in to the server"); targetDatabaseField.setToolTipText( "For PostgreSQL servers this field contains the schema containing the source tables"); } else if (!targetIsFiles) { targetServerField .setToolTipText("This field contains the name or IP address of the database server"); if (arg0.getItem().toString().equals("SQL Server")) targetUserField.setToolTipText( "The user used to log in to the server. Optionally, the domain can be specified as <domain>/<user> (e.g. 'MyDomain/Joe')"); else targetUserField.setToolTipText("The user used to log in to the server"); targetPasswordField.setToolTipText("The password used to log in to the server"); targetDatabaseField.setToolTipText("The name of the database containing the source tables"); } } }); targetPanel.add(targetType); targetPanel.add(new JLabel("Server location")); targetServerField = new JTextField("127.0.0.1"); targetServerField.setEnabled(false); targetPanel.add(targetServerField); targetPanel.add(new JLabel("User name")); targetUserField = new JTextField(""); targetUserField.setEnabled(false); targetPanel.add(targetUserField); targetPanel.add(new JLabel("Password")); targetPasswordField = new JPasswordField(""); targetPasswordField.setEnabled(false); targetPanel.add(targetPasswordField); targetPanel.add(new JLabel("Database name")); targetDatabaseField = new JTextField(""); targetDatabaseField.setEnabled(false); targetPanel.add(targetDatabaseField); targetPanel.add(new JLabel("CSV Format")); targetCSVFormat = new JComboBox<>(new String[] { "Default (comma, CRLF)", "TDF (tab, CRLF)", "MySQL (tab, LF)", "RFC4180", "Excel CSV" }); targetCSVFormat.setToolTipText("The format of the output"); targetCSVFormat.setEnabled(true); targetPanel.add(targetCSVFormat); c.gridx = 0; c.gridy = 1; c.gridwidth = 1; panel.add(targetPanel, c); JPanel fakeDataButtonPanel = new JPanel(); fakeDataButtonPanel.setLayout(new BoxLayout(fakeDataButtonPanel, BoxLayout.X_AXIS)); fakeDataButtonPanel.add(new JLabel("Max rows per table")); generateRowCount = new JSpinner(); generateRowCount.setValue(10000); fakeDataButtonPanel.add(generateRowCount); fakeDataButtonPanel.add(Box.createHorizontalGlue()); JButton testConnectionButton = new JButton("Test connection"); testConnectionButton.setBackground(new Color(151, 220, 141)); testConnectionButton.setToolTipText("Test the connection"); testConnectionButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { testConnection(getTargetDbSettings()); } }); componentsToDisableWhenRunning.add(testConnectionButton); fakeDataButtonPanel.add(testConnectionButton); JButton fakeDataButton = new JButton("Generate fake data"); fakeDataButton.setBackground(new Color(151, 220, 141)); fakeDataButton.setToolTipText("Generate fake data based on the scan report"); fakeDataButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { fakeDataRun(); } }); componentsToDisableWhenRunning.add(fakeDataButton); fakeDataButtonPanel.add(fakeDataButton); c.gridx = 0; c.gridy = 2; c.gridwidth = 1; panel.add(fakeDataButtonPanel, c); return panel; }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.PropertiesUI.java
/** * Formats the specified button.//from w w w . ja v a2s . c o m * * @param button The button to handle. * @param text The tool tip text. * @param actionID The action command id. */ private void formatButton(JButton button, String text, int actionID) { button.setOpaque(false); UIUtilities.unifiedButtonLookAndFeel(button); button.setBackground(UIUtilities.BACKGROUND_COLOR); button.setToolTipText(text); button.addActionListener(this); button.setActionCommand("" + actionID); }
From source file:org.optaplanner.examples.meetingscheduling.swingui.MeetingSchedulingPanel.java
private JButton createButton(MeetingAssignment meetingAssignment, Color color) { JButton button = SwingUtils.makeSmallButton(new JButton(new MeetingAssignmentAction(meetingAssignment))); button.setBackground(color); return button; }
From source file:org.ut.biolab.medsavant.client.cohort.CohortDetailedView.java
private JButton removeIndividualsButton() { JButton button = ViewUtil.getSoftButton("Remove selected member"); button.setBackground(ViewUtil.getDetailsBackgroundColor()); button.setOpaque(false);//w w w . ja v a2 s.c o m button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int[] rows = list.getSelectedRows(); int[] patientIDs = new int[rows.length]; for (int i = 0; i < rows.length; i++) { patientIDs[i] = ((SimplePatient) list.getModel().getValueAt(rows[i], 0)).getId(); } if (patientIDs != null && patientIDs.length > 0) { if (DialogUtils.askYesNo("Confirm", "Are you sure you want to remove these individual(s)?") == DialogUtils.NO) { return; } try { MedSavantClient.CohortManager.removePatientsFromCohort(LoginController.getSessionID(), patientIDs, cohorts[0].getId()); } catch (Exception ex) { LOG.error("Error removing patients from cohort.", ex); } worker = new CohortDetailsWorker(cohorts[0]); worker.execute(); } } }); return button; }
From source file:plugins.tprovoost.Microscopy.MicroManagerForIcy.MMMainFrame.java
/** * Create an error dialog concerning DLL issues with Micro-Manager. * //from www.j av a2 s. c o m * @return Returns the dialog. */ private JDialog createDLLErrorDialog() { MainFrame mainFrame = Icy.getMainInterface().getMainFrame(); // Dialog frame to be returned final JDialog dialog = new JDialog(mainFrame, "Loading Error", true); // main panel of the dialog JPanel panel_main = new JPanel(); panel_main.setLayout(new BorderLayout()); JLabel lbl_html = new JLabel("<html>" + "<h2>Unable to load library</h2>" + "<br/><b>What happened ?</b>" + "<p>The library is a file used by Manager to interact with the devices. Each device needs a specific file in order <br/>" + "to work properly with the system. If only one file is missing, this error occurs.</p>" + "<b>To avoid getting this problem again, please acknowledge the following steps: </b>" + "<ol><li>Do you have Micro-Manager 1.4 installed ? If not, please install it via the button below.</li>" + "<li>Check the application directory of Icy. You should find a file named: " + "<ul><li>on Windows: MMCoreJ_wrap</li><li>on Mac: libMMCoreJ_wrap</li></ul>" + "<li>Plus : you should have a file for each of your devices starting with the name:" + "<ul><li>on Windows: mmgr_dal_</li><li>on Mac: libmmgr_dal_</li></ul>" + "<li>If you don't have these files, please copy (not move) them from the Manager application directory<br/>" + "to your Icy application directory.</li></ol></html>"); panel_main.add(lbl_html, BorderLayout.CENTER); panel_main.setBorder(BorderFactory.createEmptyBorder(10, 20, 10, 20)); JPanel panel_buttons = new JPanel(); panel_buttons.setLayout(new BoxLayout(panel_buttons, BoxLayout.X_AXIS)); panel_buttons.add(Box.createHorizontalGlue()); JButton btn_link = new JButton(); btn_link.setText("Download Micro-Manager 1.4.14"); btn_link.setBackground(Color.WHITE); btn_link.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { NetworkUtil .openBrowser("http://valelab.ucsf.edu/~MM/MMwiki/index.php/Micro-Manager_Version_Archive"); } }); panel_buttons.add(btn_link); JButton btn_ok = new JButton("OK"); btn_ok.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialog.setVisible(false); } }); panel_buttons.add(btn_ok); panel_main.add(panel_buttons, BorderLayout.SOUTH); dialog.add(panel_main); dialog.pack(); dialog.setLocation((int) mainFrame.getSize().getWidth() / 2 - dialog.getWidth() / 2, (int) mainFrame.getSize().getHeight() / 2 - dialog.getHeight() / 2); return dialog; }
From source file:Proiect.uploadFTP.java
public void actionFTP() { adressf.addCaretListener(new CaretListener() { public void caretUpdate(CaretEvent e) { InetAddress thisIp;// w w w. j av a2s. c om try { thisIp = InetAddress.getLocalHost(); titleFTP.setText("Connection: " + thisIp.getHostAddress() + " -> " + adressf.getText()); } catch (UnknownHostException e1) { e1.printStackTrace(); } } }); exit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { saveState(); uploadFTP.dispose(); tree.dispose(); } }); connect.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { FTPClient client = new FTPClient(); FileInputStream fis = null; String pass = String.valueOf(passf.getPassword()); try { if (filename == null) { status.setText("File does not exist!"); } else { // Server address client.connect(adressf.getText()); // Login credentials client.login(userf.getText(), pass); if (client.isConnected()) { status.setText("Succesfull transfer!"); // File type client.setFileType(FTP.BINARY_FILE_TYPE); // File location File file = new File(filepath); fis = new FileInputStream(file); // Change the folder on the server client.changeWorkingDirectory(folderf.getText()); // Save the file on the server client.storeFile(filename, fis); } else { status.setText("Transfer failed!"); } } client.logout(); } catch (IOException e1) { Encrypter.printException(e1); } finally { try { if (fis != null) { fis.close(); } client.disconnect(); } catch (IOException e1) { Encrypter.printException(e1); } } } }); browsef.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int retval = chooserf.showOpenDialog(chooserf); if (retval == JFileChooser.APPROVE_OPTION) { status.setText(""); filename = chooserf.getSelectedFile().getName().toString(); filepath = chooserf.getSelectedFile().getPath(); filenf.setText(chooserf.getSelectedFile().getName().toString()); } } }); adv.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { tree.setSize(220, uploadFTP.getHeight()); tree.setLocation(uploadFTP.getX() + 405, uploadFTP.getY()); tree.setResizable(false); tree.setIconImage(Toolkit.getDefaultToolkit() .getImage(getClass().getClassLoader().getResource("assets/ico.png"))); tree.setUndecorated(true); tree.getRootPane().setBorder(BorderFactory.createLineBorder(Encrypter.color_black, 2)); tree.setVisible(true); tree.setLayout(new BorderLayout()); JLabel labeltree = new JLabel("Server documents"); labeltree.setOpaque(true); labeltree.setBackground(Encrypter.color_light); labeltree.setBorder(BorderFactory.createMatteBorder(8, 10, 10, 0, Encrypter.color_light)); labeltree.setForeground(Encrypter.color_blue); labeltree.setFont(Encrypter.font16); JButton refresh = new JButton(""); ImageIcon refresh_icon = getImageIcon("assets/icons/refresh.png"); refresh.setIcon(refresh_icon); refresh.setBackground(Encrypter.color_light); refresh.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0)); refresh.setForeground(Encrypter.color_black); refresh.setFont(Encrypter.font16); refresh.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); final FTPClient client = new FTPClient(); DefaultMutableTreeNode top = new DefaultMutableTreeNode(adressf.getText()); DefaultMutableTreeNode files = null; DefaultMutableTreeNode leaf = null; final JTree tree_view = new JTree(top); tree_view.setForeground(Encrypter.color_black); tree_view.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0)); tree_view.putClientProperty("JTree.lineStyle", "None"); tree_view.setBackground(Encrypter.color_light); JScrollPane scrolltree = new JScrollPane(tree_view); scrolltree.setBackground(Encrypter.color_light); scrolltree.getVerticalScrollBar().setPreferredSize(new Dimension(0, 0)); UIManager.put("Tree.textBackground", Encrypter.color_light); UIManager.put("Tree.selectionBackground", Encrypter.color_blue); UIManager.put("Tree.selectionBorderColor", Encrypter.color_blue); tree_view.updateUI(); final String pass = String.valueOf(passf.getPassword()); try { client.connect(adressf.getText()); client.login(userf.getText(), pass); client.enterLocalPassiveMode(); if (client.isConnected()) { try { FTPFile[] ftpFiles = client.listFiles(); for (FTPFile ftpFile : ftpFiles) { files = new DefaultMutableTreeNode(ftpFile.getName()); top.add(files); if (ftpFile.getType() == FTPFile.DIRECTORY_TYPE) { FTPFile[] ftpFiles1 = client.listFiles(ftpFile.getName()); for (FTPFile ftpFile1 : ftpFiles1) { leaf = new DefaultMutableTreeNode(ftpFile1.getName()); files.add(leaf); } } } } catch (IOException e1) { Encrypter.printException(e1); } client.disconnect(); } else { status.setText("Failed connection!"); } } catch (IOException e1) { Encrypter.printException(e1); } finally { try { client.disconnect(); } catch (IOException e1) { Encrypter.printException(e1); } } tree.add(labeltree, BorderLayout.NORTH); tree.add(scrolltree, BorderLayout.CENTER); tree.add(refresh, BorderLayout.SOUTH); uploadFTP.addComponentListener(new ComponentListener() { public void componentMoved(ComponentEvent e) { tree.setLocation(uploadFTP.getX() + 405, uploadFTP.getY()); } public void componentShown(ComponentEvent e) { } public void componentResized(ComponentEvent e) { } public void componentHidden(ComponentEvent e) { } }); uploadFTP.addWindowListener(new WindowListener() { public void windowActivated(WindowEvent e) { tree.toFront(); } public void windowOpened(WindowEvent e) { } public void windowIconified(WindowEvent e) { } public void windowDeiconified(WindowEvent e) { } public void windowDeactivated(WindowEvent e) { } public void windowClosing(WindowEvent e) { } public void windowClosed(WindowEvent e) { } }); refresh.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { tree.dispose(); tree.setVisible(true); } }); } }); }