Skip to content

Instantly share code, notes, and snippets.

@darylwong
Last active August 29, 2015 14:19
Show Gist options
  • Save darylwong/00eee629949ee82dc765 to your computer and use it in GitHub Desktop.
Save darylwong/00eee629949ee82dc765 to your computer and use it in GitHub Desktop.
package inlinestatement;
import javafx.application.Application;
import static javafx.application.Application.launch;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
public class InLineStatement extends Application {
@Override
public void start(Stage stage) {
stage.setTitle("Codecrawl.com");
ListView<String> lv = new ListView<String>();
ObservableList<String> items = FXCollections.observableArrayList(
"Rock", "Country", "Pop", "Rap");
int row_height = 24; //default row height
lv.setMaxHeight(items.size() * row_height);
lv.setItems(items);
HBox hbox = new HBox(10); // spacing = 10
hbox.setId("hboxid");
Label lb = new Label("Selection:");
lb.setStyle("-fx-font-size: 15pt; -fx-background-color: lightblue; -fx-effect: dropshadow(one-pass-box, black, 8, 0.0, 2, 0 );");
hbox.getChildren().addAll(lb, lv);
Scene scene = new Scene(hbox, 450, 300);
scene.getStylesheets().add("inlinestatement/style.css");
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
.list-cell:odd {
-fx-background-color:bisque;
}
.list-cell:even {
-fx-background-color: darkkhaki;
}
#hboxid {
-fx-background-color: lightblue;
-fx-padding: 20;
-fx-spacing: 10;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment