 		self.scrollbar.knobStyle = NSScrollerKnobStyle.Default
 		self.scrollbar.controlTint = NSControlTint.DefaultControlTint
 		self.scrollbar.controlSize = NSControlSize.RegularControlSize
-//TODO		self.scrollbar.arrowPosition = NSScrollArrowPosition.ScrollerArrowsDefaultSetting
+//TODO		self.scrollbar.arrowsPosition = NSScrollArrowPosition.ScrollerArrowsDefaultSetting
 		self.scrollbar.translatesAutoresizingMaskIntoConstraints = false
 
-		contentView.addSubview(self.nhspinb)
-		contentView.addSubview(self.nvspinb)
+		self.doubleValue = newLabel("")
+
+		contentView.addSubview(container1)
 		contentView.addSubview(self.scrollbar)
-
-		var views: [String: NSView] = [
-			"nhspinb":	nhspinb,
-			"nvspinb":		nvspinb,
-			"scrollbar":	scrollbar,
+		contentView.addSubview(self.doubleValue)
+		views = [
+			"container1":		container1,
+			"scrollbar":		scrollbar,
+			"doubleValue":		doubleValue,
 		]
-		addConstraint(contentView, "V:|-[nhspinb]-[scrollbar]-|", views)
-		addConstraint(contentView, "V:|-[nvspinb]-[scrollbar]-|", views)
-		addConstraint(contentView, "H:|-[nhspinb]-[nvspinb]-|", views)
+		addConstraint(contentView, "V:|-[container1]-[scrollbar]-[doubleValue]-|", views)
+		addConstraint(contentView, "H:|-[container1]-|", views)
 		addConstraint(contentView, "H:|-[scrollbar]-|", views)
-	}
+		addConstraint(contentView, "H:|-[doubleValue]-|", views)
+
+		self.nhformatter = newNumberFormatter(0, 100000)
+
+		super.init()
+
+		self.nhspinb.formatter = self.nhformatter
+		self.nhspinb.integerValue = 0
+		self.nhspinb.delegate = self
+
+		self.scrollbar.target = self
+		self.scrollbar.action = "onScroll:"
+
+		var nc = NSNotificationCenter.defaultCenter()
+		nc.addObserver(self,
+			selector: "scrollbarSizeChanged:",
+			name: NSViewFrameDidChangeNotification,
+			object: self.scrollbar)
+		// this will post a notification, causing an update
+		self.scrollbar.postsFrameChangedNotifications = true
+	}
+
+	override func controlTextDidChange(note: NSNotification) {
+		update()
+	}
+
+	func scrollbarSizeChanged(note: NSNotification) {
+		update()
+	}
+
+	func update() {
+		var swidth = self.scrollbar.frame.width
+		var max = CGFloat(self.nhspinb.integerValue)
+		if max == 0 {
+			self.scrollbar.knobProportion = 0
+			// this hides the knob
+			self.scrollbar.enabled = false
+			self.updateLabels()
+			return
+		}
+		self.scrollbar.knobProportion = swidth / max
+		self.scrollbar.enabled = true
+		self.updateLabels()
+	}
+
+	@IBAction func onScroll(sender: AnyObject) {
+		println("got \(self.scrollbar.hitPart)")
+		self.updateLabels()
+	}
+
+	func updateLabels() {
+		self.proportion.stringValue = "Proportion: \(self.scrollbar.knobProportion)"
+		self.doubleValue.stringValue = "Double Value: \(self.scrollbar.doubleValue)"
+	}
+}
+
+func newNumberFormatter(min: Int, max: Int) -> NSNumberFormatter {
+	var nf = NSNumberFormatter()
+	nf = NSNumberFormatter()
+	nf.formatterBehavior = NSNumberFormatterBehavior.Behavior10_4
+	nf.localizesFormat = false
+	nf.usesGroupingSeparator = false
+	nf.hasThousandSeparators = false
+	nf.allowsFloats = false
+	nf.minimum = min
+	nf.maximum = max
+	return nf
+}
+
+func newContainerView() -> NSView {
+	var v = NSView(frame: NSZeroRect)
+	v.translatesAutoresizingMaskIntoConstraints = false
+	return v
 }
 
 class intrinsicWidthTextField : NSTextField {

	}
}

class program : NSObject {
	private var nhspinb: NSTextField
	private var nvspinb: NSTextField
	private var scrollbar: NSScroller

	init(_ contentView: NSView) {
		self.nhspinb = newTextField()
		self.nvspinb = newTextField()

		var ss = NSScroller.preferredScrollerStyle()
		var ccs = NSScroller.scrollerWidthForControlSize(

	cell.lineBreakMode = NSLineBreakMode.ByClipping
	cell.scrollable = true
	tf.translatesAutoresizingMaskIntoConstraints = false
	tf.setContentHuggingPriority(250, forOrientation: NSLayoutConstraintOrientation.Horizontal)
	return tf
}

