diff --git a/designer/src/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java b/designer/src/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java index ba2371421..a008258fe 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java +++ b/designer/src/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java @@ -4,6 +4,7 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel; import com.fr.design.mainframe.alphafine.cell.model.MoreModel; +import com.fr.general.IOUtils; import javax.swing.*; import java.awt.*; @@ -33,7 +34,7 @@ public class ContentCellRender implements ListCellRenderer { AlphaCellModel model = (AlphaCellModel) value; name.setText(model.getName()); String iconUrl = "/com/fr/design/mainframe/alphafine/images/alphafine" + model.getType().getTypeValue() + ".png"; - name.setIcon(new ImageIcon(getClass().getResource(iconUrl))); + name.setIcon(IOUtils.readIcon(iconUrl)); name.setFont(AlphaFineConstants.MEDIUM_FONT); name.setForeground(AlphaFineConstants.BLACK); name.setVerticalTextPosition(SwingConstants.CENTER); diff --git a/designer/src/com/fr/design/mainframe/alphafine/cell/render/TitleCellRender.java b/designer/src/com/fr/design/mainframe/alphafine/cell/render/TitleCellRender.java index 84784ecdb..5926d4e21 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/cell/render/TitleCellRender.java +++ b/designer/src/com/fr/design/mainframe/alphafine/cell/render/TitleCellRender.java @@ -3,6 +3,8 @@ package com.fr.design.mainframe.alphafine.cell.render; import com.fr.design.gui.ilable.UILabel; import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.cell.model.MoreModel; +import com.fr.general.IOUtils; + import javax.swing.*; import java.awt.*; @@ -35,8 +37,8 @@ public class TitleCellRender implements ListCellRenderer { panel.add(this.more, BorderLayout.EAST); } if (moreModel.isLoading()) { - ImageIcon imageIcon = new ImageIcon(getClass().getResource("/com/fr/design/mainframe/alphafine/images/loading.gif")); - + ImageIcon imageIcon = (ImageIcon) IOUtils.readIcon("/com/fr/design/mainframe/alphafine/images/loading.gif"); + //设置cell的加载动画 imageIcon.setImageObserver(list); UILabel loadingLabel = new UILabel(imageIcon); diff --git a/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java b/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java index 00e1744fc..169f1a492 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java +++ b/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java @@ -10,8 +10,8 @@ import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.cell.CellModelHelper; -import com.fr.design.mainframe.alphafine.cell.render.ContentCellRender; import com.fr.design.mainframe.alphafine.cell.model.*; +import com.fr.design.mainframe.alphafine.cell.render.ContentCellRender; import com.fr.design.mainframe.alphafine.listener.ComponentHandler; import com.fr.design.mainframe.alphafine.listener.DocumentAdapter; import com.fr.design.mainframe.alphafine.model.SearchListModel; @@ -26,6 +26,7 @@ import com.fr.form.main.Form; import com.fr.form.main.FormIO; import com.fr.general.ComparatorUtils; import com.fr.general.FRLogger; +import com.fr.general.IOUtils; import com.fr.general.Inter; import com.fr.general.http.HttpClient; import com.fr.io.TemplateWorkBookIO; @@ -45,7 +46,7 @@ import javax.swing.event.ListSelectionListener; import java.awt.*; import java.awt.event.*; import java.awt.image.BufferedImage; -import java.io.*; +import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; @@ -82,7 +83,7 @@ public class AlphaFineDialog extends UIDialog { searchTextField.setBorderPainted(false); searchTextField.initKeyListener(this); JPanel topPane = new JPanel(new BorderLayout()); - UILabel iconLabel = new UILabel(new ImageIcon(getClass().getResource("/com/fr/design/mainframe/alphafine/images/bigsearch.png"))); + UILabel iconLabel = new UILabel(IOUtils.readIcon("/com/fr/design/mainframe/alphafine/images/bigsearch.png")); iconLabel.setPreferredSize(AlphaFineConstants.ICON_LABEL_SIZE); iconLabel.setOpaque(true); iconLabel.setBackground(Color.white); @@ -98,7 +99,7 @@ public class AlphaFineDialog extends UIDialog { }; closeButton.setContentAreaFilled(false); closeButton.setPreferredSize(AlphaFineConstants.CLOSE_BUTTON_SIZE); - closeButton.setIcon(new ImageIcon(getClass().getResource("/com/fr/design/mainframe/alphafine/images/alphafine_close.png"))); + closeButton.setIcon(IOUtils.readIcon("/com/fr/design/mainframe/alphafine/images/alphafine_close.png")); closeButton.set4ToolbarButton(); closeButton.addActionListener(new ActionListener() { @Override @@ -370,11 +371,7 @@ public class AlphaFineDialog extends UIDialog { try { bufferedImage = ImageIO.read(new URL(((PluginModel) selectedValue).getImageUrl())); } catch (IOException e) { - try { - bufferedImage = ImageIO.read(getClass().getResource("/com/fr/design/mainframe/alphafine/images/default_product.png")); - } catch (IOException e1) { - FRLogger.getLogger().error(e.getMessage()); - } + bufferedImage = IOUtils.readImage("/com/fr/design/mainframe/alphafine/images/default_product.png"); } return bufferedImage; } @@ -417,7 +414,7 @@ public class AlphaFineDialog extends UIDialog { private void showDefaultPreviewPane() { rightSearchResultPane.removeAll(); - UILabel label = new UILabel(new ImageIcon(getClass().getResource("/com/fr/design/mainframe/alphafine/images/opening.gif"))); + UILabel label = new UILabel(IOUtils.readIcon("/com/fr/design/mainframe/alphafine/images/opening.gif")); label.setBorder(BorderFactory.createEmptyBorder(120,0,0,0)); rightSearchResultPane.add(label, BorderLayout.CENTER); validate(); diff --git a/designer/src/com/fr/design/mainframe/bbs/BBSConstants.java b/designer/src/com/fr/design/mainframe/bbs/BBSConstants.java index 121929e09..21d815727 100644 --- a/designer/src/com/fr/design/mainframe/bbs/BBSConstants.java +++ b/designer/src/com/fr/design/mainframe/bbs/BBSConstants.java @@ -3,6 +3,7 @@ */ package com.fr.design.mainframe.bbs; +import com.fr.general.IOUtils; import com.fr.stable.StringUtils; import java.util.Properties; @@ -43,7 +44,7 @@ public class BBSConstants { if (PROP == null) { PROP = new Properties(); try { - PROP.load(BBSConstants.class.getResourceAsStream("/com/fr/design/mainframe/bbs/bbs.properties")); + PROP.load(IOUtils.getResourceAsStream("/com/fr/design/mainframe/bbs/bbs.properties", BBSConstants.class)); } catch (Exception e) { } } diff --git a/designer/src/com/fr/design/module/DesignerModule.java b/designer/src/com/fr/design/module/DesignerModule.java index 9e0837ac0..58e00fa0e 100644 --- a/designer/src/com/fr/design/module/DesignerModule.java +++ b/designer/src/com/fr/design/module/DesignerModule.java @@ -32,7 +32,6 @@ import com.fr.general.xml.GeneralXMLTools; import com.fr.io.importer.Excel2007ReportImporter; import com.fr.io.importer.ExcelReportImporter; import com.fr.main.impl.WorkBook; -import com.fr.plugin.ExtraClassManager; import com.fr.quickeditor.ChartQuickEditor; import com.fr.quickeditor.cellquick.*; import com.fr.quickeditor.floatquick.FloatImageQuickEditor; @@ -47,7 +46,6 @@ import com.fr.stable.ParameterProvider; import com.fr.stable.StringUtils; import com.fr.stable.bridge.StableFactory; import com.fr.stable.fun.LogProvider; -import com.fr.stable.plugin.PluginSimplify; import com.fr.stable.script.CalculatorProviderContext; import com.fr.stable.script.ValueConverter; import com.fr.stable.web.ServletContext; @@ -99,7 +97,7 @@ public class DesignerModule extends DesignModule { InformationCollector.getInstance().collectStartTime(); ExtraDesignClassManager.getInstance().getFeedback().didFeedback(); - ExtraClassManager.getInstance().addMutable(LogProvider.MARK_STRING, DesignerLogImpl.getInstance(), PluginSimplify.NULL); + StableFactory.registerMarkedObject(LogProvider.MARK_STRING, DesignerLogImpl.getInstance()); } private void registerOtherPane() { diff --git a/designer_base/src/com/fr/design/extra/QQLoginWebPane.java b/designer_base/src/com/fr/design/extra/QQLoginWebPane.java index f3c96d219..096f9bb25 100644 --- a/designer_base/src/com/fr/design/extra/QQLoginWebPane.java +++ b/designer_base/src/com/fr/design/extra/QQLoginWebPane.java @@ -1,10 +1,7 @@ package com.fr.design.extra; import com.fr.base.FRContext; -import com.fr.general.ComparatorUtils; -import com.fr.general.FRLogger; -import com.fr.general.Inter; -import com.fr.general.SiteCenter; +import com.fr.general.*; import javafx.application.Platform; import javafx.beans.property.BooleanProperty; import javafx.beans.property.SimpleBooleanProperty; @@ -74,7 +71,7 @@ public class QQLoginWebPane extends JFXPanel { try { primaryStage.initStyle(StageStyle.TRANSPARENT); primaryStage.setScene(new Scene(layout)); - webView.getScene().getStylesheets().add(getClass().getResource("modal-dialog.css").toExternalForm()); + webView.getScene().getStylesheets().add(IOUtils.getResource("modal-dialog.css", getClass()).toExternalForm()); primaryStage.initStyle(StageStyle.UTILITY); primaryStage.setScene(new Scene(new Group(), DEFAULT_PRIMARYSTAGE_WIDTH, DEFAULT_PRIMARYSTAGE_HEIGHT)); primaryStage.setX(0); @@ -193,7 +190,7 @@ public class QQLoginWebPane extends JFXPanel { ); configDrag(dialog); // style and show the dialog. - dialog.getScene().getStylesheets().add(getClass().getResource("modal-dialog.css").toExternalForm()); + dialog.getScene().getStylesheets().add(IOUtils.getResource("modal-dialog.css", getClass()).toExternalForm()); dialog.setOnCloseRequest(new EventHandler() { @Override public void handle(WindowEvent event) { diff --git a/designer_base/src/com/fr/design/extra/plugindependence/DownLoadDependenceUI.java b/designer_base/src/com/fr/design/extra/plugindependence/DownLoadDependenceUI.java deleted file mode 100644 index 29097a5ee..000000000 --- a/designer_base/src/com/fr/design/extra/plugindependence/DownLoadDependenceUI.java +++ /dev/null @@ -1,281 +0,0 @@ -package com.fr.design.extra.plugindependence; - -import com.fr.base.FRContext; -import com.fr.design.extra.PluginHelper; -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.mainframe.DesignerContext; -import com.fr.general.IOUtils; -import com.fr.general.Inter; -import com.fr.general.SiteCenter; -import com.fr.general.http.HttpClient; -import com.fr.plugin.dependence.PluginDependenceException; -import com.fr.plugin.dependence.PluginDependenceUnit; -import com.fr.stable.StableUtils; -import com.fr.stable.StringUtils; -import com.fr.stable.plugin.PluginConstants; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.awt.image.BufferedImage; -import java.io.File; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.net.HttpURLConnection; -import java.util.List; - -/** - * Created by hufan on 2016/9/5. - */ -public class DownLoadDependenceUI implements ActionListener { - //进度显示界面 - private JDialog frame = null; - //进度条 - private JProgressBar progressbar; - //进度信息 - private JLabel label; - //进度条更新时钟 - private Timer timer; - //是否继续下载 - private boolean flag = true; - - // 定义加载窗口大小 - private static final int LOAD_WIDTH = 455; - - private static final int INCIDENT_WIDTH = 15; - - private static final int LOAD_HEIGHT = 295; - - - //安装环境相关信息 - private String currentID; - private List list = null; - //安装结果 - private boolean result = false; - //链接服务器的客户端 - private HttpClient httpClient; - //已读文件字节数 - private int totalBytesRead = 0; - //文件总长度 - private int totalSize = 0; - - public DownLoadDependenceUI() { - } - public DownLoadDependenceUI(String currentID, List list) { - this.currentID = currentID; - this.list = list; - this.totalSize = getFileLength(); - init(); - } - - private void init() { - // 创建标签,并在标签上放置一张图片 - BufferedImage image = IOUtils.readImage("/com/fr/design/extra/plugindependence/image/background.png"); - ImageIcon imageIcon = new ImageIcon(image); - label = new UILabel(imageIcon); - label.setBounds(0, 0, LOAD_WIDTH, LOAD_HEIGHT - INCIDENT_WIDTH); - - progressbar = new JProgressBar(); - // 显示当前进度值信息 - progressbar.setStringPainted(true); - // 设置进度条边框不显示 - progressbar.setBorderPainted(false); - // 设置进度条的前景色 - progressbar.setForeground(new Color(0x38aef5)); - // 设置进度条的背景色 - progressbar.setBackground(new Color(188, 190, 194)); - progressbar.setBounds(0, LOAD_HEIGHT - INCIDENT_WIDTH, LOAD_WIDTH, INCIDENT_WIDTH); - progressbar.setMinimum(0); - progressbar.setMaximum(totalSize); - progressbar.setValue(0); - - timer = new Timer(100, this); - - frame = new JDialog(DesignerContext.getDesignerFrame(), true); - frame.setTitle(Inter.getLocText("FR-Designer-Dependence_Install_Online")); - frame.setSize(LOAD_WIDTH, LOAD_HEIGHT); - Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - frame.setLocation(screenSize.width / 2 - LOAD_WIDTH / 2, screenSize.height / 2 - LOAD_HEIGHT / 2); - frame.setResizable(false); - // 设置布局为空 - frame.setLayout(new BorderLayout(0, 0)); - frame.getContentPane().add(label, BorderLayout.CENTER); - frame.getContentPane().add(progressbar, BorderLayout.SOUTH); - - frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); - frame.addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent e) { - //取消下载 - flag = false; - frame.dispose(); - } - }); - } - - - //是否可以连接服务器 - private boolean connectToServer() { - for (int i = 0; i < list.size(); i++) { - PluginDependenceUnit dependenceUnit = list.get(i); - httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind(dependenceUnit.getDependenceID())); - if (httpClient.getResponseCode() != HttpURLConnection.HTTP_OK){ - return false; - } - } - return true; - } - - //获取依赖文件大小 - private int getFileLength(){ - int size = 0; - for (int i = 0; i < list.size(); i++) { - PluginDependenceUnit dependenceUnit = list.get(i); - HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind(dependenceUnit.getDependenceID())); - if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) { - size += httpClient.getContentLength(); - }else { - return -1; - } - } - return size; - } - - //安装 - private boolean install() { - //开始时钟 - timer.start(); - //开始下载 - Thread thread = new Thread(new Runnable() { - @Override - public void run() { - installDependenceOnline(); - } - }); - thread.start(); - - frame.setVisible(true); - //等待下载线程处理结束 - try { - thread.join(); - } catch (InterruptedException e) { - FRContext.getLogger().error(e.getMessage()); - return false; - } - //停止时钟 - timer.stop(); - return result; - } - - /** - * 下载和安装不分开是因为,本地如果只安装好了一个依赖,下次就不需要重复下载了 - * 如果下载依赖后不安装,则后面的插件会把前面的插件覆盖,故而下载好了一个安装一个 - * @return - * @throws Exception - */ - private void downloadAndInstallPluginDependenceFile() throws Exception { - totalBytesRead = 0; - for (int i = 0; i < list.size(); i++) { - PluginDependenceUnit dependenceUnit = list.get(i); - httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind(dependenceUnit.getDependenceID())); - if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) { - InputStream reader = httpClient.getResponseStream(); - String temp = StableUtils.pathJoin(PluginHelper.DEPENDENCE_DOWNLOAD_PATH, PluginHelper.TEMP_FILE); - StableUtils.makesureFileExist(new File(temp)); - FileOutputStream writer = new FileOutputStream(temp); - byte[] buffer = new byte[PluginConstants.BYTES_NUM]; - int bytesRead = 0; - while ((bytesRead = reader.read(buffer)) > 0 && flag) { - writer.write(buffer, 0, bytesRead); - buffer = new byte[PluginConstants.BYTES_NUM]; - totalBytesRead += bytesRead; - } - reader.close(); - writer.flush(); - writer.close(); - - //下载被取消 - if (flag == false) { - result = false; - throw new PluginDependenceException(Inter.getLocText("FR-Designer-Dependence_Install_Failed")); - } - - //安装文件 - IOUtils.unZipFilesGBK(temp, FRContext.getCurrentEnv().getPath() + dependenceUnit.getDependenceDir()); - - } else { - result = false; - throw new PluginDependenceException(Inter.getLocText("FR-Designer-Dependence_Install_Failed")); - } - } - //所有依赖都正常安装下载完毕,则结果为true - result = true; - } - - public void installDependenceOnline() { - try { - //下载并安装文件 - downloadAndInstallPluginDependenceFile(); - } catch (Exception e) { - result = false; - FRContext.getLogger().error(e.getMessage()); - } - } - - //安装已经下载好的文件,如果是服务文件,则需要复制一份到安装目录下, - //以便切换远程时,使用本地的服务 - //如果是服务器环境,则只会安装一份 - private void installPluginDependenceFile(List filePathList){ - if (filePathList.isEmpty()){ - result = false; - return; - } - for(int i = 0; i < filePathList.size(); i++) { - if (StringUtils.EMPTY.equals(filePathList.get(i))){ - result = false; - return; - } - PluginDependenceUnit dependenceUnit = list.get(i); - IOUtils.unzip(new File(filePathList.get(i)), FRContext.getCurrentEnv().getPath() + dependenceUnit.getDependenceDir()); - result = true; - } - } - - public void actionPerformed(ActionEvent e) { - if (e.getSource() == timer) { - int value = progressbar.getValue(); - if (value < totalSize) { - progressbar.setValue(totalBytesRead); - } else { - timer.stop(); - frame.dispose(); - } - } - } - - public void installOnline()throws PluginDependenceException { - - int choose = JOptionPane.showConfirmDialog(null, Inter.getLocText("FR-Designer-Plugin_DownLoadMessage", showFileLength()), "install tooltip", JOptionPane.YES_NO_OPTION); - if (choose == 0) {//下载安装 - if (!connectToServer()) { - throw new PluginDependenceException(Inter.getLocText("FR-Designer-Dependence_Connect_Server_Error")); - } - //安装依赖环境 - if (install()) { - JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Dependence_Install_Succeed") + "!!"); - } else { - throw new PluginDependenceException(Inter.getLocText("FR-Designer-Dependence_Install_Failed")); - } - }else {//不选择下载,则不安装图标插件 - throw new PluginDependenceException(Inter.getLocText("FR-Designer-Dependence_Install_Failed")); - } - } - - private String showFileLength(){ - double len = totalSize / Math.pow(10, 6); - String lenStr = String.format("%.2f", len); - return totalSize == -1 ? "NAN" : lenStr; - } -} diff --git a/designer_base/src/com/fr/design/extra/plugindependence/image/background.png b/designer_base/src/com/fr/design/extra/plugindependence/image/background.png deleted file mode 100644 index 45bf328e3..000000000 Binary files a/designer_base/src/com/fr/design/extra/plugindependence/image/background.png and /dev/null differ diff --git a/designer_base/src/com/fr/design/gui/UILookAndFeel.java b/designer_base/src/com/fr/design/gui/UILookAndFeel.java index 3bdf14d31..205abed29 100644 --- a/designer_base/src/com/fr/design/gui/UILookAndFeel.java +++ b/designer_base/src/com/fr/design/gui/UILookAndFeel.java @@ -3,10 +3,12 @@ package com.fr.design.gui; import com.fr.base.BaseUtils; import com.fr.design.gui.borders.*; import com.fr.design.gui.frpane.UIBasicOptionPaneUI; +import com.fr.design.gui.ibutton.UIBasicButtonUI; import com.fr.design.gui.ibutton.UIButtonBorder; import com.fr.design.gui.ibutton.UIRadioButtonMenuItemUI; import com.fr.design.gui.ibutton.UIRadioButtonUI; import com.fr.design.gui.icheckbox.UICheckBoxUI; +import com.fr.design.gui.icombobox.UIBasicComboBoxUI; import com.fr.design.gui.icontainer.UIScrollPaneBorder; import com.fr.design.gui.icontainer.UIScrollPaneUI; import com.fr.design.gui.icontainer.UITableScrollPaneBorder; @@ -16,6 +18,7 @@ import com.fr.design.gui.imenu.UIPopupMenuBorder; import com.fr.design.gui.imenu.UIPopupMenuSeparatorUI; import com.fr.design.gui.iprogressbar.UIProgressBarBorder; import com.fr.design.gui.iprogressbar.UIProgressBarUI; +import com.fr.design.gui.iscrollbar.UIBasicScrollBarUI; import com.fr.design.gui.ispinner.UISpinnerUI; import com.fr.design.gui.isplitpanedivider.UISplitPaneUI; import com.fr.design.gui.itable.UIBasicTableUI; @@ -23,10 +26,8 @@ import com.fr.design.gui.itoolbar.UIToolBarBorder; import com.fr.design.gui.itoolbar.UIToolBarSeparatorUI; import com.fr.design.gui.itooltip.UIToolTipBorder; import com.fr.design.gui.itree.UITreeUI; -import com.fr.design.gui.iscrollbar.UIBasicScrollBarUI; -import com.fr.design.gui.icombobox.UIBasicComboBoxUI; -import com.fr.design.gui.ibutton.UIBasicButtonUI; import com.fr.general.FRLogger; +import com.fr.general.IOUtils; import javax.swing.*; import javax.swing.border.Border; @@ -187,8 +188,8 @@ public class UILookAndFeel extends MetalLookAndFeel { if (url == null) { // Another try - url = UILookAndFeel.class.getResource( - "com/fr/design/images/lookandfeel/" + fileName); + url = IOUtils.getResource( + "com/fr/design/images/lookandfeel/" + fileName, UILookAndFeel.class); if (url == null) { FRLogger.getLogger().error("Icon directory could not be resolved."); diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/type/ChartImagePane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/type/ChartImagePane.java index f56146b8b..7b35b8d8d 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/type/ChartImagePane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/type/ChartImagePane.java @@ -3,6 +3,7 @@ package com.fr.design.mainframe.chart.gui.type; import com.fr.design.chart.series.PlotStyle.ChartSelectDemoPane; import com.fr.design.constants.UIConstants; import com.fr.design.gui.ilable.UILabel; +import com.fr.general.IOUtils; import javax.swing.*; import java.awt.*; @@ -14,9 +15,9 @@ public class ChartImagePane extends ChartSelectDemoPane { public boolean isDoubleClicked = false; public ChartImagePane(String iconPath, String tipName) {// 建立太复杂? 耗费内存.. - UILabel image = new UILabel(new ImageIcon(getClass().getResource(iconPath))); - this.setLayout(new BorderLayout()); - this.add(image, BorderLayout.CENTER); + UILabel image = new UILabel(IOUtils.readIcon(iconPath)); + this.setLayout(new BorderLayout()); + this.add(image, BorderLayout.CENTER); addMouseListener(this); this.setToolTipText(tipName); @@ -28,7 +29,8 @@ public class ChartImagePane extends ChartSelectDemoPane { } private void constructImagePane(String fullIconPath, String tipName, boolean isDrawRightLine){ - UILabel image = new UILabel(new ImageIcon(getClass().getResource(fullIconPath))); + + UILabel image = new UILabel(IOUtils.readIcon(fullIconPath)); this.setLayout(new BorderLayout()); this.add(image, BorderLayout.CENTER); addMouseListener(this);