小编abd*_*mer的帖子

Javafx css按钮图形调整大小

我想更改按钮内图标的大小。图像的大小为 512 x 512,我想调整为 16x16。那么,使用 javaFX CSS 实现这一目标的最佳方法是什么。

这是我到目前为止所做的:

#btnCancel.button {
    -fx-graphic: url("/img/close.png") ;
    -fx-graphic-size:16px 16px ; ( I think this property not exist in javafx css)

}
Run Code Online (Sandbox Code Playgroud)

但这对我不起作用。

css java javafx

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

Spring Data JPA无法实例化持久器org.hibernate.persister.entity.JoinedSubclassEntityPersister

我使用 @Inheritance(strategy = InheritanceType.JOINED) 遇到了一个问题,我有四个类涉及这个问题,Person(超类)、Supplier(子类)、Client(子类)、Transaction(与 Client 和Supplier 有关系)类)。

现在,我想知道是什么导致了这个小问题:当我删除供应商类时,一切都正常,

这是堆栈跟踪:

Exception in Application init method
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
    at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application init method
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:912)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] …
Run Code Online (Sandbox Code Playgroud)

java hibernate hibernate-mapping spring-data-jpa

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

Hibernate H2 数据库相对路径

我有一个名为“test.db”的 H2 数据库文件。该文件位于我的应用程序目录中:“myApp/resources/test.db”。我无法为我解决这个问题。所以,引用相对路径的正确方法是什么。

这里是我的 hibernate.cfg.xml 的配置。

 <property name="connection.driver_class">org.h2.Driver</property>
        <property name="connection.url">jdbc:h2:file:/test</property>
        <property name="connection.username">test</property>
        <property name="connection.password">1234</property>


        <!-- SQL dialect -->
        <property name="dialect">org.hibernate.dialect.H2Dialect</property>
Run Code Online (Sandbox Code Playgroud)

发生的错误是:

Caused by: org.h2.jdbc.JdbcSQLException: A file path that is implicitly relative to the current working directory is not allowed in the database URL "jdbc:h2:file:/test2". Use an absolute path, ~/name, ./name, or the baseDir setting instead. [90011-191]
Run Code Online (Sandbox Code Playgroud)

java hibernate h2

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

JavaFx菜单项加速器Javafx CSS

我试图图标化JavaFX菜单项标签。我为菜单项标签和加速器标签复制了图标。这是一张说明我的问题的图像。

在此处输入图片说明

这是Javafs css代码:

.menu-item > .label {

}

#miRestore .label{
    -fx-graphic: url("/img/Upload_16x16.png");
}
#miBackup .label {
    -fx-graphic: url("/img/Flash%20Disk_16x16.png");
}
#miClose .label {
    -fx-graphic: url("/img/Delete_16x16.png");
}

#miSettings .label {
    -fx-graphic: url("/img/Settings_16x16.png");
}

#miRegistre . label{
    -fx-graphic: url("/img/Help_16x16.png");
}
Run Code Online (Sandbox Code Playgroud)

java javafx javafx-css

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

ControlsFX 字体 Awesome 不显示图标

为了图标化我的应用程序,我决定使用 ControlFX 的出色字体支持。

我尝试在 Code 和 FXML 中使用它,结果只有“GEAR”图标有效。

那么,是什么原因导致其他图标不显示呢?

她是 FXML 文件的代码:

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.layout.AnchorPane?>


<?import org.controlsfx.glyphfont.Glyph?>
<fx:root maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" type="AnchorPane" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1" fx:controller="testController">
   <children>
      <Button mnemonicParsing="false" text="Button" >
          <graphic>
            // The Gear icon works perfectly 
            <Glyph fontFamily="FontAwesome" icon="GEAR"/>  
            <Glyph fontFamily="FontAwesome" icon="SEARCH"/>
          </graphic>
      </Button>
   </children>
</fx:root>
Run Code Online (Sandbox Code Playgroud)

我还想在工作后更改图标的颜色。

fxml font-awesome javafx-8 controlsfx

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

不能在 BigDecimal 变量中放入双精度数

我正在使用一个保存商品价格的 Double 变量。该变量存储在 postgresql 数据库中的货币类型列下。我使用 setBigDecimal(position,value) SQL 函数。在其他部分,我使用 JSpinner 作为输入。

Double current = 0.0;
Double min = (double) Integer.MIN_VALUE;
Double max = (double) Integer.MAX_VALUE;
Double step = 0.1;

JSpinner priceSpinner = new JSpinner(new SpinnerNumberModel(current, min, max, step));
Run Code Online (Sandbox Code Playgroud)

当用户单击按钮时,我会获取用户输入的值并通过 SQL 查询将其放入数据库中。

 insertStmt.setBigDecimal(position,BigDecimal.valueOf((double) priceSpinner.getValue()));
Run Code Online (Sandbox Code Playgroud)

但是,我得到了这个小错误,

Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: java.math.BigDecimal cannot be cast to java.lang.Double
Run Code Online (Sandbox Code Playgroud)

java double bigdecimal jspinner classcastexception

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

Hibernate和Postgresql负主键ID问题

我将Hibernate 5.0.7与Postgresql DBMS一起使用。一切正常,但我在postgresql数据库中遇到主键问题(负值)。

这是我的代码:

package model;

import javafx.beans.property.*;
import javax.persistence.*;


@Entity
@Table(name = "Product")
@Access(AccessType.PROPERTY)
public class Product {
    private LongProperty idProduct;
    private StringProperty nameFr;
    private DoubleProperty qtyInHand;
    private DoubleProperty sellPrice;


 public Product() {
        idProduct = new SimpleLongProperty();      
        nameFr = new SimpleStringProperty();
        qtyInHand = new SimpleDoubleProperty();
        sellPrice = new SimpleDoubleProperty();

    }

@Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "product_seq_gen")
    @SequenceGenerator(name = "product_seq_gen", sequenceName = "product_idproduct_seq")
    @Column(name = "idproduct", unique = true, nullable = false)
    public Long getIdProduct() {
        return idProduct.get();
    } …
Run Code Online (Sandbox Code Playgroud)

java database postgresql orm hibernate

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