我知道有很多关于如何获得的问题,但我想要和使用新的Java 8 Date api的例子.我也知道JodaTime库,但我想要一种没有外部库的工作方式.
功能需要抱怨这些限制:
我需要检测一行的双击TableView.
如何双击该行的任何部分并获取该行的所有数据以将其打印到控制台?
这个问题与此类似,但我需要访问父成员(不是控件).我不知道是否可以不使用依赖注入.
例如,我有一个父有一个成员调用用户,我需要从子控制器访问用户.
I try to use Afterburner.fx for DI in my project. I take followme.fx example and I try to apply to my project. But I don't know what's wrong because I follow example but when I run app, I get these exception:
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:497)
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:497)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$151(LauncherImpl.java:182)
at com.sun.javafx.application.LauncherImpl$$Lambda$50/1030870354.run(Unknown …Run Code Online (Sandbox Code Playgroud) 我需要将文本转换为图像。图像必须具有:
我创建了这个函数,它执行上述一些要求:
public static Image crearImagenDesdeTexto(String texto) throws IOException {
BufferedImage img = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2d = img.createGraphics();
FontMetrics fm = g2d.getFontMetrics();
int width = fm.stringWidth(texto);
int height = fm.getHeight();
g2d.setColor(java.awt.Color.WHITE);
g2d.fillRect(0, 0, width, height);
g2d.setColor(java.awt.Color.BLACK);
Font font = new Font("Arial", Font.PLAIN, 12);
g2d.setFont(font);
g2d.dispose();
img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
g2d = img.createGraphics();
g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
g2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE);
g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
g2d.setFont(font);
fm …Run Code Online (Sandbox Code Playgroud) java ×2
javafx ×2
javafx-8 ×2
controller ×1
days ×1
fxml ×1
fxmlloader ×1
graphics2d ×1
java-8 ×1
java-time ×1
tableview ×1