小编Sla*_*law的帖子

如何使单选按钮和复选框相对于系统分辨率改变大小?

我知道有很多解决方案可以帮助更改单选按钮或复选框的大小,但是我需要一种方法来在我的 .css 文件或其他一些内联解决方案中使用 em 使大小相对。

我试图让我的控件在 720p、1080p 和 4K 中显示相同的大小。除了 RadioButton 和 CheckBox 之外的所有其他控件都通过将 em 用于任何选择器控件大小来工作。我将在下面为每个控件包含一些相关的代码片段。

RadioButton.css基本字体大小在另一个文件中定义

.RadioButton {
    -fx-font-size: 1em;
}

.RadioButton .radio  {
    -fx-background-insets: 0em;
    -fx-background-radius: 0.833333em;
    -fx-border-insets: 0em;
    -fx-border-radius: 0.833333em;
    -fx-padding: 0.5em;
}

.RadioButton:focused .radio {
    -fx-background-insets: 0em;
    -fx-background-radius: 0.833333em;
    -fx-border-insets: 0em;
    -fx-border-radius: 0.833333em;
    -fx-padding: 0.5em;
}

.RadioButton:hover .radio {
    -fx-background-insets: 0em;
    -fx-background-radius: 0.833333em;
    -fx-border-insets: 0em;
    -fx-border-radius: 0.833333em;
    -fx-padding: 0.5em;
}
.RadioButton:armed .radio {
    -fx-background-insets: 0em;
    -fx-background-radius: 0.833333em;
    -fx-border-insets: 0em;
    -fx-border-radius: 0.833333em;
    -fx-padding: 0.5em; …
Run Code Online (Sandbox Code Playgroud)

css javafx screen-resolution javafx-css

5
推荐指数
1
解决办法
399
查看次数

带有颜色的 Unicode 表情符号

我正在尝试使用 JavaFX 构建即时消息应用程序。我想通过使用 unicode 来实现表情符号支持,但是,当使用 Google 的 Noto Color Emoji 等字体时,表情符号仅显示为灰度。像这样:

表情符号

我已经像这样应用了字体,并且可以确认它加载正确。

@font-face {
font-family: 'Noto Color Emoji';
src: url('/fonts/NotoColorEmoji.ttf');
}

.message-widget-font {
-fx-font-family: Noto Color Emoji;
}
Run Code Online (Sandbox Code Playgroud)

将 CSS 应用到Text对象:

messageText.getStyleClass().add("message-widget-font");
Run Code Online (Sandbox Code Playgroud)

有没有办法让表情符号有颜色?

java unicode javafx emoji

5
推荐指数
0
解决办法
490
查看次数

为什么我应该避免在 JavaFX 中使用 PropertyValueFactory?

PropertyValueFactory对于与建议避免该课程和其他类似课程相关的问题的许多答案(和评论) 。使用这个类有什么问题?

javafx

5
推荐指数
1
解决办法
1156
查看次数

这是JavaFX SceneBuilder的错误吗?

在 JavaFX SceneBuilder 中,我希望将 Pane 的边框样式设置为仅位于右侧,因此我将以下内容放入 JavaFX CSS 样式框中: -fx-border-style: none Solid none none ,但它使整个边框可见。然后我发现,如果我将“none”作为第一个值,则边界将始终是完整的。

有人可以告诉我如何修复它,或者是否有其他方法可以做到这一点?

JavaFX CSS 视图

java javafx scenebuilder

5
推荐指数
1
解决办法
118
查看次数

如何将 IntStream 转换为 List<Character>?

我有一个对象,我将其限制为 30 个元素,并且我喜欢从流中的所有元素中IntStream获取一个。List<Character>int

提前致谢

java java-stream

4
推荐指数
1
解决办法
1899
查看次数

TableView的样式如何?

在此处输入图片说明

如图所示,问题出在表的右下角。我想将白色方块的颜色更改为蓝色,但是我不能。我尝试为设置样式ScrollPane,但似乎没有用。白色方块的样式是否受ScrollPane

CSS:

/*******************************************************************************
 *                                                                             *
 * ScrollPane                                                                  *
 *                                                                             *
 ******************************************************************************/
.scroll-pane{
    -fx-background-color: #30466B;
}
.scroll-pane > .viewport {
    -fx-background-color: #30466B;
}
.scroll-pane > .scroll-bar:horizontal {
    -fx-background-insets: 0 1 1 1, 1;
    -fx-padding: 0 1 0 1;
    -fx-background-color: #30466B;

}
.scroll-pane > .scroll-bar:horizontal > .increment-button,
.scroll-pane > .scroll-bar:horizontal > .decrement-button {
    -fx-padding: 0.166667em 0.25em 0.25em  0.25em; /* 2 3 3 3 */
    -fx-background-color: #30466B;

}
.scroll-pane > .scroll-bar:vertical > .increment-button,
.scroll-pane > .scroll-bar:vertical > .decrement-button { …
Run Code Online (Sandbox Code Playgroud)

java javafx javafx-8

3
推荐指数
1
解决办法
37
查看次数

javafx中是否可以制作线性渐变的百分比?

考虑以下线性渐变“A”。通常,如果您指定该画笔作为矩形的背景,它将用整个渐变填充整个区域,无论大小如何。(见“B”)。

我们试图说“对于这个特定的控件,仅使用画笔的前 xx% 进行填充”,这样我们就可以实现基于百分比的渐变填充,就像“C”中一样。

梯度图像示例

javafx

3
推荐指数
1
解决办法
482
查看次数

如果使用Stream.allMatch(),如何为空列表返回false?

我想对Java流使用一条语句。

我要筛选所有要求为“ true”的Servicework对象,然后检查所有Servicework对象的状态是否为“完成”。

但是,如果serviceworkList ist为空,则变量“ validate”为false。我知道allMatch的规范,即如果list为空,则返回true。

关于如何重建流的任何建议,如果list ist为空,我将得到false?

public class Service{

    List<ServiceWork> serviceWorkList = new ArrayList<>();


    boolean validate = serviceWorkList
        .stream()
        .filter(ServiceWork::isRequirement)
        .allMatch(a -> a.getStatus() == Status.DONE);

}
Run Code Online (Sandbox Code Playgroud)

class ServiceWork {

    private Status status;
    private boolean isRequirement;

    public Status getStatus() {
        return status;
    }

    public void setStatus(Status status) {
        this.status = status;
    }

    public boolean isRequirement() {
        return isRequirement;
    }

    public void setRequirement(boolean requirement) {
        isRequirement = requirement;
    }
}
Run Code Online (Sandbox Code Playgroud)

enum Status {
    DONE, NOT_DONE
}
Run Code Online (Sandbox Code Playgroud)

java java-stream

2
推荐指数
1
解决办法
498
查看次数

How can I find the number of lines that contain a certain word in java using Java Stream?

My method would read from a text file and find the word "the" inside of each line and count how many lines contain the word. My method does work but the issue is that I need only lines that contain the word by itself, not a substring of the word as well

For example, I wouldn't want "therefore" even though it contains "the" it's not by itself.

I'm trying to find a way to limit the lines to those that …

java java-stream

2
推荐指数
1
解决办法
58
查看次数

仅在某些情况下从 java 中的值列表抛出异常

我有一个值列表,最多包含四个元素。我需要循环遍历列表,并且仅在某些情况下才需要抛出异常。需要抛出异常的不同场景如下。

  1. 当空值出现在列表中间时。一些例子是:
 List<String> values = ["test1","test2",null,"test4"];
 List<String> values = ["test1",null,"test3","test4"];
 List<String> values = ["test1",null,null,"test4"];
Run Code Online (Sandbox Code Playgroud)
  1. 当空值出现在列表的开头时。一些例子是:
List<String> values = [null,"test2","test3","test4"];
List<String> values = [null,null,"test3","test4"];
List<String> values = [null,null,null,"test4"];
Run Code Online (Sandbox Code Playgroud)

所有其他情况都是有效的,不应引发异常。有效案例有:

List<String> values = ["test1","test2","test3","test4"];
List<String> values = ["test1","test2","test3",null];
List<String> values = ["test1","test2",null,null];
List<String> values = ["test1",null,null,null];
List<String> values = [null,null,null,null];
Run Code Online (Sandbox Code Playgroud)

有人可以帮忙吗?

java null loops list arraylist

1
推荐指数
1
解决办法
1300
查看次数