diff --git a/diylc/diylc-swing/src/org/diylc/swing/gui/TranslatedPanel.java b/diylc/diylc-swing/src/org/diylc/swing/gui/TranslatedPanel.java new file mode 100644 index 00000000..a612054c --- /dev/null +++ b/diylc/diylc-swing/src/org/diylc/swing/gui/TranslatedPanel.java @@ -0,0 +1,48 @@ +/* + * + * DIY Layout Creator (DIYLC). Copyright (c) 2009-2018 held jointly by the individual authors. + * + * This file is part of DIYLC. + * + * DIYLC is free software: you can redistribute it and/or modify it under the terms of the GNU + * General Public License as published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * DIYLC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU General Public License along with DIYLC. If not, see + * . + */ +package org.diylc.swing.gui; + +import java.awt.Component; + +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; + +import org.diylc.lang.LangUtil; + +public class TranslatedPanel extends JPanel { + + private static final long serialVersionUID = 1L; + + @Override + public Component add(Component comp) { + if (comp instanceof JButton) { + JButton button = (JButton)comp; + String name = button.getText(); + if (name != null) + button.setText(LangUtil.translate(name)); + } + if (comp instanceof JLabel) { + JLabel button = (JLabel)comp; + String name = button.getText(); + if (name != null) + button.setText(LangUtil.translate(name)); + } + return super.add(comp); + } +} diff --git a/diylc/diylc-swing/src/org/diylc/swing/loadline/LoadlineEditorFrame.java b/diylc/diylc-swing/src/org/diylc/swing/loadline/LoadlineEditorFrame.java index f08c7c07..fefc03f8 100644 --- a/diylc/diylc-swing/src/org/diylc/swing/loadline/LoadlineEditorFrame.java +++ b/diylc/diylc-swing/src/org/diylc/swing/loadline/LoadlineEditorFrame.java @@ -62,6 +62,7 @@ import org.diylc.images.IconLoader; import org.diylc.lang.LangUtil; import org.diylc.presenter.Presenter; import org.diylc.swing.gui.DialogFactory; +import org.diylc.swing.gui.TranslatedPanel; import org.diylc.swing.gui.editor.PropertyEditorDialog; import org.diylc.swing.plugins.canvas.CanvasPanel; import org.diylc.swing.plugins.file.FileFilterEnum; @@ -172,7 +173,7 @@ public class LoadlineEditorFrame extends JFrame implements IView { public JPanel getToolbar() { if (toolbar == null) { - toolbar = new JPanel(); + toolbar = new TranslatedPanel(); toolbar.add(new JButton(new ClearAction())); toolbar.add(new JButton(new LoadAction())); toolbar.add(new JButton(new SaveAction())); @@ -253,7 +254,7 @@ public class LoadlineEditorFrame extends JFrame implements IView { public JPanel getControlPanel() { if (controlPanel == null) { - controlPanel = new JPanel(); + controlPanel = new TranslatedPanel(); controlPanel.add(new JLabel("Name: ")); controlPanel.add(getNameEditor());