JavaFX – 在tableview中移动列

在(JavaFX)表视图中,您可以自动移动列(更改列的顺序)。 但这不会存储在List中。 那么如何保存它,还是有更好的方法来移动列并将其保存在DataList中?

为什么Java在这里抛出NullPointerException?

public class Test { public int [] x; public Test(int N) { int[] x = new int [N]; for (int i=0;i<x.length;i++) { x[i]=i; StdOut.println(x[i]); } } public static void main(String[] args) { String path = "/Users/alekscooper/Desktop/test.txt"; In reader = new In(path); int size=reader.readInt(); StdOut.println("Size = "+size); Test N = new Test(size); StdOut.println(Nx[3]); } /* ADD […]

如何在Java Application中播放音频

我正在制作一个java应用程序,我需要播放音频。 我正在播放我的大炮射击的小声音文件(它是一个大炮射击游戏)和射弹爆炸,虽然我打算循环播放背景音乐。 我找到了两种不同的方法来实现这一目标,但两种方法都无法实现我想要的效果。 第一种方法实际上是一种方法: public void playSoundFile(File file) {//http://java.ittoolbox.com/groups/technical-functional/java-l/sound-in-an-application-90681 try { //get an AudioInputStream AudioInputStream ais = AudioSystem.getAudioInputStream(file); //get the AudioFormat for the AudioInputStream AudioFormat audioformat = ais.getFormat(); System.out.println(“Format: ” + audioformat.toString()); System.out.println(“Encoding: ” + audioformat.getEncoding()); System.out.println(“SampleRate:” + audioformat.getSampleRate()); System.out.println(“SampleSizeInBits: ” + audioformat.getSampleSizeInBits()); System.out.println(“Channels: ” + audioformat.getChannels()); System.out.println(“FrameSize: ” + audioformat.getFrameSize()); System.out.println(“FrameRate: ” + audioformat.getFrameRate()); […]

正则表达式中^和$的含义是什么?

“\\w+@\\w+[.]\\w+”和”^\\w+@\\w+[.]\\w+$”之间有什么区别? 我试图谷歌,但没有运气。

从jar自动检测Hibernate中的类

我有一个带有以下persistence.xml文件的几个实体的JavaEE项目: … … 它似乎工作。 然后将该项目作为JAR部署到两个不同的项目中。 在其中一个中, persistence.xml文件与上面的文件基本相同,即使用Hibernate的autodetectionfunction。 但是,它似乎不起作用(因为我认为它需要加载搜索jar中的实体)。 当我尝试手动列出两个xml文件中的所有实体时,一切正常。 编辑:它适用于jar文件,但只能使用jar的绝对路径。 对团队项目来说相当无用。

如何深度复制不规则的2D数组

如何在Java中深度复制不规则形状的2D数组? IE浏览器。 int[][] nums = {{5}, {9,4}, {1,7,8}, {8,3,2,10}} 我出于某种原因无法使用Arrays.arrayCopy() (版本化?)

如何从Swing应用程序中的Logback链接日志?

我必须向应用程序添加一个面板,该面板将记录应用程序的错误。 我已经创建了一个扩展AppenderBase的类,我已经配置了xml文件来使用这个类。 因此,当我在应用程序中记录某些内容时,他会调用它。 但目前我不知道如何将我的appender链接到我的面板。 你能指导我吗?

Java数据传输对象命名约定?

在这种情况下,您有一个客户端库传递给API的“传输对象”(POJO只有getter / setter),命名传输对象的最佳方法是什么? package com.x.core; public class Car { private String make; private String model; public Car(com.x.clientapi.Car car) { this.make = car.getMake(); this.model = car.getModel(); } } 在此示例中,您的主类和传输对象都具有名称Car 。 它们有不同的包装,但我认为拥有相同的名称令人困惑。 有关如何命名传输对象的最佳实践吗?

在Spring Boot 1.4中测试安全性

我正在尝试使用SecurityConfig类中定义的自定义安全设置来测试@WebMvcTest : @Configuration @EnableWebSecurity public class SecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { http.authorizeRequests().antMatchers(“/admin*”).access(“hasRole(‘ADMIN’)”).antMatchers(“/**”).permitAll().and().formLogin(); } @Autowired public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { auth.inMemoryAuthentication().withUser(“user”).password(“password”).roles(“ADMIN”); } } 测试类是: @RunWith(SpringRunner.class) @WebMvcTest(value = ExampleController.class) public class ExampleControllerMockMVCTest { @Autowired private MockMvc mockMvc; @Test public void indexTest() throws Exception { mockMvc.perform(get(“/”)) .andExpect(status().isOk()) .andExpect(view().name(“index”)); } […]

启动画面进度条不绘图

我正试图在我的启动画面上创建自己的进度条。 创建我的启动画面很简单: java -splash:EaseMailMain.jpg Main.class(来自Eclipse) 我的main方法的第一行称为: new Thread(new Splash()).start(); 这是泼水类: public class Splash implements Runnable { public volatile static int percent = 0; @Override public void run() { System.out.println(“Start”); final SplashScreen splash = SplashScreen.getSplashScreen(); if (splash == null) { System.out.println(“SplashScreen.getSplashScreen() returned null”); return; } Graphics2D g = splash.createGraphics(); if (g == null) { System.out.println(“g is […]