System.out.println("Finished buttons after "+(System.currentTimeMillis() - startTime));
	public void run(String arg)	{		ij = IJ.getInstance();		long startTime = System.currentTimeMillis();		System.out.println("Run starting at "+startTime);		SliderPane pane = null;		windowLevel = arg.equals("wl");		balance = arg.equals("balance");		if (windowLevel) {			setTitle("W&L");		} else if (balance) {			setTitle("Color");			channels = 4;		}		if (instance != null) {			instance.toFront();			return;		}		instance = this;		IJ.register(ContrastAdjuster.class);		System.out.println("Registered with IJ after "+(System.currentTimeMillis() - startTime));		gridbag = new GridBagLayout();		c = new GridBagConstraints();		getContentPane().setLayout(gridbag);		System.out.println("Finished setting layout after "+(System.currentTimeMillis() - startTime));		// plot		c.gridx = 0;		y = 0;		c.gridy = y++;		c.fill = GridBagConstraints.BOTH;		c.anchor = GridBagConstraints.CENTER;		c.insets = new Insets(4, 4, 4, 4);		gridbag.setConstraints(plot, c);		System.out.println("Finished setting constraints for plot after "+(System.currentTimeMillis() - startTime));		getContentPane().add(plot);		System.out.println("Added plot after "+(System.currentTimeMillis() - startTime));		// min slider		if (!windowLevel) {			minSlider = new Scrollbar(Scrollbar.HORIZONTAL, sliderRange/2, 1, 0, sliderRange);			pane = new SliderPane(minSlider, "Minimum: ");			c.gridy = y++;			gridbag.setConstraints(pane, c);			getContentPane().add(pane);			minSlider.addAdjustmentListener(this);			minSlider.setUnitIncrement(1);		}		// max slider		if (!windowLevel) {			maxSlider = new Scrollbar(Scrollbar.HORIZONTAL, sliderRange/2, 1, 0, sliderRange);			pane = new SliderPane(maxSlider, "Maximum: ");			c.gridy = y++;			gridbag.setConstraints(pane, c);			getContentPane().add(pane);			maxSlider.addAdjustmentListener(this);			maxSlider.setUnitIncrement(1);		}		// brightness slider		brightnessSlider = new Scrollbar(Scrollbar.HORIZONTAL, sliderRange/2, 1, 0, sliderRange);		pane = new SliderPane(brightnessSlider, windowLevel ? "Level: " : "Brightness: ");		c.gridy = y++;		gridbag.setConstraints(pane, c);		getContentPane().add(pane);		brightnessSlider.addAdjustmentListener(this);		brightnessSlider.setUnitIncrement(1);		// contrast slider		if (!balance) {			contrastSlider = new Scrollbar(Scrollbar.HORIZONTAL, sliderRange/2, 1, 0, sliderRange);			pane = new SliderPane(contrastSlider, windowLevel ? "Window: " : "Contrast: ");			c.gridy = y++;			gridbag.setConstraints(pane, c);			getContentPane().add(pane);			contrastSlider.addAdjustmentListener(this);			contrastSlider.setUnitIncrement(1);		}		System.out.println("Finished sliders after "+(System.currentTimeMillis() - startTime));		// color channel popup menu		if (balance) {			c.gridy = y++;			choice = new Choice();			for (int i=0; i<channelLabels.length; i++) {				choice.addItem(channelLabels[i]);			}			gridbag.setConstraints(choice, c);			choice.addItemListener(this);			getContentPane().add(choice);		}		// buttons		int trim = IJ.isMacOSX()?20:0;		panel = new JPanel();		panel.setLayout(new GridLayout(0,2, 0, 0));		autoB = new TrimmedButton("Auto",trim);		autoB.addActionListener(this);		autoB.addKeyListener(ij);		panel.add(autoB);		resetB = new TrimmedButton("Reset",trim);		resetB.addActionListener(this);		resetB.addKeyListener(ij);		panel.add(resetB);		setB = new TrimmedButton("Set",trim);		setB.addActionListener(this);		setB.addKeyListener(ij);		panel.add(setB);		applyB = new TrimmedButton("Apply",trim);		applyB.addActionListener(this);		applyB.addKeyListener(ij);		panel.add(applyB);		if (!windowLevel && !balance) {			threshB = new TrimmedButton("Thresh",trim);			threshB.addActionListener(this);			threshB.addKeyListener(ij);			panel.add(threshB);			updateB = new TrimmedButton("Update",trim);			updateB.addActionListener(this);			updateB.addKeyListener(ij);			panel.add(updateB);		}		c.gridy = y++;		gridbag.setConstraints(panel, c);		getContentPane().add(panel);		System.out.println("Finished buttons after "+(System.currentTimeMillis() - startTime));		addKeyListener(ij);  // ImageJ handles keyboard shortcuts		setVisible(true);		System.out.println("finished showing after "+(System.currentTimeMillis() - startTime));		thread = new Thread(this, "ContrastAdjuster");		thread.start();		setup();		System.out.println("Run ending at "+System.currentTimeMillis());	}//end run()