1.修复IDEA中无法加载resources文件夹的Bug;2.修改多语言Demo
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package cn.edu.scau.biubiusuisui.example.languageDemo;
|
||||
package cn.edu.scau.biubiusuisui.example.langDemo;
|
||||
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXController;
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXRedirect;
|
||||
@@ -15,7 +15,7 @@ import javafx.fxml.FXML;
|
||||
* @since JDK1.8
|
||||
*/
|
||||
@FXWindow(mainStage = true, title = "languageDemo")
|
||||
@FXController(path = "fxml/languageDemo/languageDemo.fxml", locale = FXPlusLocale.SIMPLIFIED_CHINESE)
|
||||
@FXController(path = "fxml/langDemo/langDemo.fxml", locale = FXPlusLocale.SIMPLIFIED_CHINESE)
|
||||
public class ChineseController extends FXBaseController {
|
||||
@FXML
|
||||
public void clickToChinese() {
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.edu.scau.biubiusuisui.example.languageDemo;
|
||||
package cn.edu.scau.biubiusuisui.example.langDemo;
|
||||
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXController;
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXRedirect;
|
||||
@@ -14,7 +14,7 @@ import javafx.fxml.FXML;
|
||||
* @since JDK1.8
|
||||
*/
|
||||
@FXWindow(mainStage = false, title = "languageDemo")
|
||||
@FXController(path = "fxml/languageDemo/languageDemo.fxml", locale = FXPlusLocale.ENGLISH)
|
||||
@FXController(path = "fxml/langDemo/langDemo.fxml", locale = FXPlusLocale.ENGLISH)
|
||||
public class EnglishController extends FXBaseController {
|
||||
@FXML
|
||||
public void clickToChinese() {
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.edu.scau.biubiusuisui.example.languageDemo;
|
||||
package cn.edu.scau.biubiusuisui.example.langDemo;
|
||||
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXController;
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXRedirect;
|
||||
@@ -14,7 +14,7 @@ import javafx.fxml.FXML;
|
||||
* @since JDK1.8
|
||||
*/
|
||||
@FXWindow(mainStage = false, title = "languageDemo")
|
||||
@FXController(path = "fxml/languageDemo/languageDemo.fxml", locale = FXPlusLocale.KOREAN)
|
||||
@FXController(path = "fxml/langDemo/langDemo.fxml", locale = FXPlusLocale.KOREAN)
|
||||
public class KoreanController extends FXBaseController {
|
||||
@FXML
|
||||
public void clickToChinese() {
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.edu.scau.biubiusuisui.example.languageDemo;
|
||||
package cn.edu.scau.biubiusuisui.example.langDemo;
|
||||
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXScan;
|
||||
import cn.edu.scau.biubiusuisui.config.FXPlusApplication;
|
||||
@@ -11,7 +11,7 @@ import javafx.stage.Stage;
|
||||
* @date 2020/5/3 09:57
|
||||
* @since JDK1.8
|
||||
*/
|
||||
@FXScan(base = "cn.edu.scau.biubiusuisui.example.languageDemo")
|
||||
@FXScan(base = "cn.edu.scau.biubiusuisui.example.langDemo")
|
||||
public class LanguageDemo extends Application {
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
@@ -34,8 +34,12 @@ public class FileUtil {
|
||||
* @description 读取resources文件夹下的file,相对于resources的文件路径,如 resources/config.conf 则只需 config.conf
|
||||
*/
|
||||
public static String readFileFromResources(String filePath) {
|
||||
String path = StringUtil.getRootPath(FileUtil.class.getClassLoader().getResource(filePath));
|
||||
return readFile(path);
|
||||
URL url = FileUtil.class.getClassLoader().getResource(filePath);
|
||||
if (url != null) {
|
||||
String path = StringUtil.getRootPath(url);
|
||||
return readFile(path);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -119,7 +119,7 @@ public class StringUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* cn/edu/scau/biubiusuisui/resources/fxml/languageDemo/languageDemo.fxml -> fxml/languageDemo/languageDemo.fxml
|
||||
* cn/edu/scau/biubiusuisui/resources/fxml/languageDemo/langDemo.fxml -> fxml/languageDemo/langDemo.fxml
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
@@ -135,7 +135,7 @@ public class StringUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* cn/edu/scau/biubiusuisui/resources/fxml/languageDemo/languageDemo.fxml -> languageDemo
|
||||
* cn/edu/scau/biubiusuisui/resources/fxml/languageDemo/langDemo.fxml -> languageDemo
|
||||
*
|
||||
* @param name 文件名
|
||||
* @return
|
||||
@@ -144,7 +144,7 @@ public class StringUtil {
|
||||
public static String getFileBaseName(String name) {
|
||||
String result = "";
|
||||
String[] tempStrs = name.split("/");
|
||||
if (1 == tempStrs.length) { //只有文件名,即name: languageDemo.fxml
|
||||
if (1 == tempStrs.length) { //只有文件名,即name: langDemo.fxml
|
||||
result = StringUtil.trimExtension(name);
|
||||
} else {
|
||||
result = StringUtil.trimExtension(tempStrs[tempStrs.length - 1]);
|
||||
|
||||
Reference in New Issue
Block a user