C-screen is a text-base UI on java console, you can now easily design your console program using c-screen with the help of several components.
download here: https://github.com/soybean15/CScreen/releases
Update as of August 4 2022, 1:20pm
Since Box-window is not working on default on some OS, I added a method where you can choose between normal character and box-window character
Normal Characters:
//normal character
Screen screen = new Screen(20,40,true);
//screen.useBoxSet();
screen.addTitle("Sample Screen",Position.START);
screen.display();
/*
sample output
+--------------------------------------+
|Sample Screen |
|+------------------------------------+|
*/
Box-Window Characters:
//box-window character
Screen screen = new Screen(20,40,true);
screen.useBoxSet();
screen.addTitle("Sample Screen",Position.START);
screen.display();
/*
sample output
╭┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈╮
│Sample Screen │
│╭┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈╮│
*/
C-Screen features:
1. Screen: a framelike interface where you can put multiple components.
Sample code:
Screen screen = new Screen(20,40,true);
screen.addTitle("Sample Screen",Position.START);
screen.display();
/*the 3 parameters on the constructor are the following:
-width - width of screen
-height - height of screen
-hasBorder - add inner border if true
*/
Sample output:
2. Box: a rectangular component you can Put inside the Screen.
Sample code:
Screen screen = new Screen(20,40,true);
screen.addTitle("Sample Screen",Position.START);
Box box = new Box(3,3);
box.setHeight(5);
box.setWidth(30);
//place component inside the screen
box.place(screen);
//display screen
screen.display();
Sample output:
3.TextBox: A box component with String inside
Sample code:
Screen screen = new Screen(20,40,true);
screen.addTitle("Sample Screen",Position.START);
TextBox textBox = new TextBox(3,3);
textBox.setText("Sample text");
textBox.setHeight(5);
textBox.setWidth(30);
//place component inside the screen
textBox.place(screen);
//display screen
screen.display();
Sample output:
4. Label : String you can put inside the screen.
Sample code:
Screen screen = new Screen(20,40,true);
screen.addTitle("Sample Screen",Position.START);
Label label = new Label(3,3);
label.setText("Sample Label");
//place component inside the screen
label.place(screen);
//display screen
screen.display();
Sample output:
5. Button: Buttonlike component which is good to have if you have multiple option in your code.
Sample code:
Screen screen = new Screen(20,40,true);
screen.addTitle("Sample Screen",Position.START);
Button button1 = new Button(3,3);
button1.setText("Button1");
//place component inside the screen
button1.place(screen);
Button button2 = new Button(6,3, "Button2");
//place component inside the screen
button2.place(screen);
//display screen
screen.display();
Sample output:
6. CList: component to help your list looks more neat
Sample code:
String[] list1 = {"Banana", "Apple", "Potato", "Orange"};
CList cList1 = new CList(list1, 30);
cList1.setTitle("Fruits",Position.CENTER);
cList1.display();
String[] list2 = {"Apple Button jeans boots with a fur", "Apple", "Potato", "Orange"};
CList cList2 = new CList(list2, 0);
cList2.setTitle("Fruits",Position.START);
cList2.display();
Sample output:
7. CTable: easiest way to output your data on console, just pass your 2d array and you got yourself a neat and instant table.
Sample code:
String[][] arr = {{"Marilyn Monroe", "21", "March", "1993"},
{"Robert De Niro", "22", "August", "1945"},
{"Malcolm X", "23", "June", "1944"},
{"Mohammad Ali", "24", "March", "1970"}
};
CTable table = new CTable(null,arr);
table.display();
String[] header = {"Name", "Id", "Month", "Year"};
CTable table2 = new CTable(header,arr);
table2.hasSeparator(true);
table2.setAlignment(Position.CENTER);
table2.display();
Sample output:
Update table without calling the constructor
Sample code
String[][] menu = {
{"f011", "Fries", "10", "70.00"},
{"b212", "Burger", "10", "30.00"},
{"sp01", "Spagetti", "30", "60.00"},
{"fc11", "Fried Chicken", "10", "110.00"},
{"s930", "Sundae", "10", "30.00"},
{"s930", "Sundae", "10", "30.00"},
};
System.out.println("View Menu:");
String[] header = {"Id", "Product Name", "Quantity", "Price"};
CTable table = new CTable(header, menu);
table.useBoxSet();
table.setAlignment(Position.CENTER);
table.hasSeparator(true);
table.display();
String[][] menu2 = {
{"f011", "Fries", "10", "70.00"},
{"b212", "Burger", "10", "30.00"},
};
//uupdate or pass a new 2d array
table.update(menu2);
table.display();
Sample output:
Hope you like it..enjoy.