-
-
Notifications
You must be signed in to change notification settings - Fork 8
#08.2 Checkbox
Valkryst edited this page Oct 31, 2017
·
16 revisions
import com.valkryst.VTerminal.Panel;
import com.valkryst.VTerminal.builder.PanelBuilder;
import com.valkryst.VTerminal.builder.component.CheckBoxBuilder;
import com.valkryst.VTerminal.font.Font;
import com.valkryst.VTerminal.font.FontLoader;
import java.io.IOException;
import java.net.URISyntaxException;
public class Driver {
public static void main(final String[] args) throws IOException, URISyntaxException, InterruptedException {
final Font font = FontLoader.loadFontFromJar("Fonts/DejaVu Sans Mono/20pt/bitmap.png",
"Fonts/DejaVu Sans Mono/20pt/data.fnt",
1);
final PanelBuilder builder = new PanelBuilder();
builder.setFont(font);
final Panel panel = builder.build();
final CheckBoxBuilder checkBoxBuilder = new CheckBoxBuilder();
checkBoxBuilder.setColumnIndex(10);
checkBoxBuilder.setRowIndex(10);
checkBoxBuilder.setText("Click Me");
panel.addComponents(checkBoxBuilder.build());
Thread.sleep(50);
panel.draw();
}
}
final CheckBoxBuilder checkBoxBuilder = new CheckBoxBuilder();
Constructs a new CheckBoxBuilder. You can view the documentation here.
You can reuse the builder, so you won't need to create a new CheckBoxBuilder every time you want to create a new check box.
checkBoxBuilder.setColumnIndex(10);
checkBoxBuilder.setRowIndex(10);
This tells the builder to place the check box at position (10x, 10y).
checkBoxBuilder.setText("Click Me");
This sets the text on the check box, so this check box will display "Click Me".
panel.addComponents(checkBoxBuilder.build());
This builds the check box and adds it to the panel.