Thursday

No Java Coding for JSlider and JTextfield

Objective: Bind JTextfield to JSlider for 'rho' values of 0.0, 0.1, 0.2, ..., 1.0 without any Java coding at all.

Final Result:


Step 1: Set JSlider Properties Visually
Swing Controls: JSlider
Code
Variable Name: sldRho
Properties
majorTickSpacing: 1
maximum: 10
minimum: 0
minorTickSpacing: 1
paintTicks: True
snapToTicks: True
value: 5  // 5 divides 10 is 0.5, to be scaled down by division operator

Step 2: Set JTextfield Properties Visually
Swing Controls: JTextfield
Code
Variable Name: jtfRho
Properties
text: 0.5 (default value)

Step 3:


Step 4:

No comments:

Measure execution time with Julia, example using sorting algorithms

# random integers between 1 and 100 inclusive, generate thousands of them x = rand ( 1 : 100 , 100000 ) @time sort (x; alg=InsertionSort, r...