use of com.googlecode.lanterna.gui2.Button in project jbang-catalog by quintesse.
the class lanterna method main.
public static void main(String[] args) {
DefaultTerminalFactory terminalFactory = new DefaultTerminalFactory().setMouseCaptureMode(MouseCaptureMode.CLICK_RELEASE);
try (Screen screen = terminalFactory.createScreen()) {
screen.startScreen();
List<String> timezonesAsStrings = new ArrayList<>(Arrays.asList(TimeZone.getAvailableIDs()));
final WindowBasedTextGUI textGUI = new MultiWindowTextGUI(screen);
final Window window = new BasicWindow("My Root Window");
Panel contentPanel = new Panel().setLayoutManager(new GridLayout(2).setHorizontalSpacing(3)).addComponent(new Label("This is a label that spans two columns").setLayoutData(GridLayout.createLayoutData(// Horizontal alignment in the grid cell if the cell
GridLayout.Alignment.BEGINNING, // Vertical alignment in the grid cell if the cell
GridLayout.Alignment.BEGINNING, // Give the component extra horizontal space if available
true, // Give the component extra vertical space if available
false, // Horizontal span
2, // Vertical span
1))).addComponent(new Label("Text Box (aligned)")).addComponent(new TextBox().setLayoutData(GridLayout.createLayoutData(GridLayout.Alignment.BEGINNING, GridLayout.Alignment.CENTER))).addComponent(new Label("Password Box (right aligned)")).addComponent(new TextBox().setMask('*').setLayoutData(GridLayout.createLayoutData(GridLayout.Alignment.END, GridLayout.Alignment.CENTER))).addComponent(new Label("Read-only Combo Box (forced size)")).addComponent(new ComboBox<>(timezonesAsStrings).setReadOnly(true).setPreferredSize(new TerminalSize(20, 1))).addComponent(new Label("Editable Combo Box (filled)")).addComponent(new ComboBox<>("Item #1", "Item #2", "Item #3", "Item #4").setReadOnly(false).setLayoutData(GridLayout.createHorizontallyFilledLayoutData(1))).addComponent(new Label("Button (centered)")).addComponent(new Button("Button", () -> MessageDialog.showMessageDialog(textGUI, "MessageBox", "This is a message box", MessageDialogButton.OK)).setLayoutData(GridLayout.createLayoutData(GridLayout.Alignment.CENTER, GridLayout.Alignment.CENTER))).addComponent(new EmptySpace().setLayoutData(GridLayout.createHorizontallyFilledLayoutData(2))).addComponent(new Separator(Direction.HORIZONTAL).setLayoutData(GridLayout.createHorizontallyFilledLayoutData(2))).addComponent(new Button("Close", window::close).setLayoutData(GridLayout.createHorizontallyEndAlignedLayoutData(2)));
window.setComponent(contentPanel);
window.addWindowListener(new WindowListenerAdapter() {
public void onUnhandledInput(Window basePane, KeyStroke keyStroke, AtomicBoolean hasBeenHandled) {
if (keyStroke.getKeyType() == KeyType.Escape) {
window.close();
}
}
});
textGUI.addWindowAndWait(window);
} catch (IOException e) {
e.printStackTrace();
}
}
use of com.googlecode.lanterna.gui2.Button in project security-lib by ncsa.
the class GUIDemo method helloWorld.
public static void helloWorld(Screen screen) {
// Create panel to hold components
Panel panel = new Panel();
panel.setLayoutManager(new GridLayout(2));
panel.addComponent(new Label("Forename"));
panel.addComponent(new TextBox());
panel.addComponent(new Label("Surname"));
panel.addComponent(new TextBox());
// Empty space underneath labels
panel.addComponent(new EmptySpace(new TerminalSize(0, 0)));
panel.addComponent(new Button("Submit"));
// Create window to hold the panel
BasicWindow window = new BasicWindow();
window.setComponent(panel);
// Create gui and start gui
MultiWindowTextGUI gui = new MultiWindowTextGUI(screen, new DefaultWindowManager(), new EmptySpace(TextColor.ANSI.BLUE));
gui.addWindowAndWait(window);
}
use of com.googlecode.lanterna.gui2.Button in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ButtonIT method setup.
protected void setup() throws ClientException {
testPage = authorClient.createPage("testPage", "Test Page", rootPage, defaultPageTemplate, 200, 201).getSlingPath();
addPathtoComponentPolicy(responsiveGridPath, buttonRT);
cmpPath = Commons.addComponentWithRetry(authorClient, buttonRT, testPage + Commons.relParentCompPath, componentName);
editorPage = new PageEditorPage(testPage);
editorPage.open();
button = new Button();
}
use of com.googlecode.lanterna.gui2.Button in project sirix by sirixdb.
the class SunburstGUI method setup.
@Override
protected void setup() {
mOldSelectedRev = mDb.getRevisionNumber();
final Toggle toggleArc = getControlP5().addToggle("mUseArc", mUseArc, LEFT + 0, TOP + mPosY + 60, 15, 15);
toggleArc.setCaptionLabel("Arc / Rect");
mToggles.add(toggleArc);
final Toggle toggleFisheye = getControlP5().addToggle("mFisheye", mFisheye, LEFT + 0, TOP + mPosY + 80, 15, 15);
toggleFisheye.setCaptionLabel("Fisheye lense");
mToggles.add(toggleFisheye);
final Toggle togglePruning = getControlP5().addToggle("mUsePruning", mUsePruning, LEFT + 0, TOP + mPosY + 100, 15, 15);
togglePruning.setValue(true);
togglePruning.setCaptionLabel("Pruning");
mToggles.add(togglePruning);
final Toggle useAttribute = getControlP5().addToggle("mUseAttribute", mUseAttribute, LEFT + 0, TOP + mPosY + 120, 15, 15);
useAttribute.setCaptionLabel("Use attribute value");
mToggles.add(useAttribute);
final Toggle useMoveDetection = getControlP5().addToggle("mUseMoveDetection", mUseMoveDetection, LEFT + 0, TOP + mPosY + 140, 15, 15);
useMoveDetection.setCaptionLabel("Use move detection");
mToggles.add(useMoveDetection);
mXPathField = getControlP5().addTextfield("xpath", mParent.width - 250, TOP + 20, 200, 20);
mXPathField.setCaptionLabel("XPath expression");
mXPathField.setFocus(false);
mXPathField.setAutoClear(false);
// black
mXPathField.setColorBackground(mParent.color(0));
// white
mXPathField.setColorForeground(mParent.color(255));
mXPathField.setId(50);
mXPathField.plugTo(this);
// Add textfield for XML fragment input.
mCtrl = getControlP5().addGroup("add XML fragment", 150, 25, 115);
mCtrl.setVisible(false);
mCtrl.close();
mTextArea = getControlP5().addTextfield("Add XML fragment", 0, 20, 400, 100);
// black
mTextArea.setColorBackground(mParent.color(0));
// white
mTextArea.setColorForeground(mParent.color(255));
mTextArea.setGroup(mCtrl);
final Button submit = getControlP5().addButton("submit", 20, 0, 140, 80, 19);
submit.plugTo(this);
submit.setGroup(mCtrl);
final Button commit = getControlP5().addButton("commit", 20, 120, 140, 80, 19);
commit.plugTo(this);
commit.setGroup(mCtrl);
final Button cancel = getControlP5().addButton("cancel", 20, 240, 140, 80, 19);
cancel.plugTo(this);
cancel.setGroup(mCtrl);
}
use of com.googlecode.lanterna.gui2.Button in project aem-core-wcm-components by adobe.
the class ButtonIT method setup.
protected void setup() throws ClientException {
testPage = authorClient.createPage("testPage", "Test Page", rootPage, defaultPageTemplate, 200, 201).getSlingPath();
addPathtoComponentPolicy(responsiveGridPath, buttonRT);
cmpPath = Commons.addComponentWithRetry(authorClient, buttonRT, testPage + Commons.relParentCompPath, componentName);
editorPage = new PageEditorPage(testPage);
editorPage.open();
button = new Button();
}
Aggregations