You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
2.4 KiB
78 lines
2.4 KiB
package com.fr.design.style; |
|
|
|
import com.fr.base.Utils; |
|
import com.fr.design.gui.itextfield.UITextField; |
|
import com.fr.design.layout.FRGUIPaneFactory; |
|
import com.fr.design.utils.DesignUtils; |
|
import com.fr.design.utils.gui.GUICoreUtils; |
|
import com.fr.general.FRFont; |
|
|
|
import javax.swing.JList; |
|
import javax.swing.JPanel; |
|
import javax.swing.event.ListSelectionEvent; |
|
import javax.swing.event.ListSelectionListener; |
|
import java.awt.BorderLayout; |
|
|
|
public class FontFamilyPane extends JPanel { |
|
private UITextField familyField; |
|
private JList familyList; |
|
|
|
public FontFamilyPane() { |
|
this.init(); |
|
} |
|
|
|
private void init() { |
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
// 名字 |
|
familyField = new UITextField(); |
|
familyField.setEditable(false); |
|
|
|
familyList = new JList(DesignUtils.getAvailableFontFamilyNames4Report()); |
|
familyList.setVisibleRowCount(4); |
|
|
|
familyList.addListSelectionListener(listener); |
|
|
|
JPanel familyPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
// familyPane.setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
familyPane.add(FRFontPane.createTextFieldListPane("", familyField, familyList), BorderLayout.CENTER); |
|
familyPane.setBorder(GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FRFont_Family"),null)); |
|
|
|
this.add(familyPane); |
|
} |
|
|
|
ListSelectionListener listener = new ListSelectionListener() { |
|
public void valueChanged(ListSelectionEvent e) { |
|
Object source = e.getSource(); |
|
if (source == getFamilyList()) { |
|
String family = (String) getFamilyList().getSelectedValue(); |
|
if (family != null) getFamilyField().setText(family); |
|
} |
|
} |
|
}; |
|
|
|
public UITextField getFamilyField() { |
|
return this.familyField; |
|
} |
|
|
|
public JList getFamilyList() { |
|
return this.familyList; |
|
} |
|
|
|
public String getText() { |
|
return this.familyField.getText(); |
|
} |
|
|
|
public void addListSelectionListener(ListSelectionListener listSelectionListener) { |
|
familyList.addListSelectionListener(listSelectionListener); |
|
} |
|
|
|
public void populate(FRFont frFont) { |
|
familyList.setSelectedValue(frFont.getName(), true); |
|
familyField.setText(frFont.getName()); |
|
} |
|
|
|
public void update(FRFont font) { |
|
font.applyName(getText()); |
|
} |
|
} |