Fandom

Wikianswers

Welcome! Enter your question below. Please use words like "Who, What, Where, When, Why, How, etc..." in your question. Nothing to ask? Click here for a random, un-answered question.

How do you create table in FX?

1,062,879questions on
Wikianswers
Add New Page
Talk0 Share

Newer versions look here: http://www.jvr.de/blog

/*

* Main.fx
* Version 0.3
*/

/**

* Simple Table
* @author jvr.de
*/

package tabledemo;

import javafx.scene.*; import javafx.scene.shape.*; import javafx.scene.paint.*; import javafx.scene.text.*;

def maxRow = 10; def maxCol = 5;

var cellWidth_default = 85.0; var cellHeight_default = 20.0;

var cellWidth = for (i in [0..maxCol]) cellWidth_default + i * 6; //increase (Demo) var cellHeight = for (j in [0..maxRow]) cellHeight_default + j * 4; //increase (Demo)

var colSum = 0.0; var rowSum = 0.0;

var colStart = for (i in [0..maxCol]) {

   colSum += cellWidth[i];colSum};

var rowStart = for (j in [0..maxRow]) {

   rowSum += cellHeight[j];rowSum};

var rows = for (i in [0..maxRow]) "Row: {i}"; var cols = for (j in [0..maxCol]) "Col: {j}";

def tabStartX = 5; def tabStartY = 5;

def textmargin_left = 2; def textmargin_top = 6;


var scene = Scene {

   fill: Color.WHITE
   width: 800
   height: 600
   content: [
   for (row in rows, col in cols)
       Group {
           translateX: tabStartX + colStart[indexof col]
           translateY: tabStartY + rowStart[indexof row]
           
           content: [
           Rectangle {
                   width: cellWidth[indexof col]
                   height: cellHeight[indexof row]
                   fill: Color.WHITE
                   stroke: Color.BLACK
                   strokeWidth: 0.0
               },
               Text {
                   //textOrigin: TextOrigin.BASELINE
                   x: textmargin_left
                   y: cellHeight[indexof row] - textmargin_top
                   content: "{row} / {col}"
                   font: Font {name: "Arial", size: 12}
                   fill: Color.BLACK
               }
           ]}
       ]

};

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.