如何将一个链接放在带引导程序的按钮上?
bootstrap文档中有4种方法:
<a href="#" class="btn btn-info" role="button">Link Button</a>
<button type="button" class="btn btn-info">Button</button>
<input type="button" class="btn btn-info" value="Input Button">
<input type="submit" class="btn btn-info" value="Submit Button">
Run Code Online (Sandbox Code Playgroud)
第一个对我不起作用,没有按钮显示,只有带链接的文本,感觉它的主题即时使用.
第二个显示按钮,这是我想要的,但是什么代码使按钮链接到另一个页面时单击?
干杯
我有两个ListViews,allStudentsList已经填充了其中的项目,currentStudentList没有.当用户选择项目时,我的目标allStudentList是移动到该项目currentStudentList.我通过在一个选择模型上放置一个监听器来做到这一点allStudentList.
我得到了一个IndexOutOfBoundsException,我不知道为什么会这样.从测试来看,似乎这个问题被隔离到这个方法的最后4行,但我不知道为什么.
allStudentsList.getSelectionModel().selectedItemProperty()
.addListener((observableValue, oldValue, newValue) -> {
if (allStudentsList.getSelectionModel().getSelectedItem() != null) {
ArrayList<String> tempCurrent = new ArrayList<>();
for (String s : currentStudentList.getItems()) {
tempCurrent.add(s);
}
ArrayList<String> tempAll = new ArrayList<>();
for (String s : allStudentsList.getItems()) {
tempAll.add(s);
}
tempAll.remove(newValue);
tempCurrent.add(newValue);
// clears current studentlist and adds the new list
if (currentStudentList.getItems().size() != 0) {
currentStudentList.getItems().clear();
}
currentStudentList.getItems().addAll(tempCurrent);
// clears the allStudentList and adds the new …Run Code Online (Sandbox Code Playgroud) 我试图从文件选择器中选择后立即显示图像文件.文件选择器仅限于.png和.jpg文件,所选文件存储在File类型的变量中.要做到这一点,我已经设置了一个ImageView,我希望用这个新文件设置图像只是问题是它是File not Image类型.
怎么能实现这一目标?代码到目前为止......
public void fileSelection(){
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Select Profile Picture");
fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("Image Files", "*.png", "*jpg"));
File selectedFile = fileChooser.showOpenDialog(null);
File selectedFileInput = selectedFile;
if(selectedFile != null) {
selectedFileOutput.setText("File selected: " + selectedFile.getName());
previewPicture.setImage();
} else {
selectedFileOutput.setText("Please select a profile picture...");
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试获取表视图中的所有项目并将它们放在数组列表中以供进一步处理。这就是我想要实现的目标,但显然它行不通。
ArrayList<Consultation> showing = consultationTable.getItems();
Run Code Online (Sandbox Code Playgroud) 我试图根据条件设置列表视图中各个单元格的样式。列表视图的类型是Label,在列表视图中插入标签时,条件是根据另一个类确定的。
目前,我尝试设置列表视图中每个标签的背景颜色,但它没有覆盖整个区域(见图)。
我也研究了这篇文章,但它不适合我的情况,因为字符串中不包含用于突出显示列表视图单元格的标识符。
到目前为止的当前代码:
for (Consultation c : notifications){
Label l = new Label(": consult reminder - " + c.getReminderTime());
if(c.getReminderRead() == 1){ //if the consultation reminder hasn't been read
l.setStyle("-fx-background-color: #33CEFF");
counter = counter + 1;
}
notificationList.getItems().add(l);
}
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?