Fixed broken build.

This commit is contained in:
Joey Lawrance 2016-03-14 11:25:58 -04:00
parent 77d0ce0d8c
commit f7e0636446
10 changed files with 1408 additions and 7 deletions

View File

@ -6,7 +6,7 @@ apply plugin: 'sonar-runner'
if (System.properties['os.name'].toLowerCase().contains('mac')) {
apply plugin: 'macAppBundle'
macAppBundle {
mainClassName = "com.cburch.logisim.Main"
icon = "LogisimApp.icns"
@ -65,18 +65,14 @@ buildscript {
repositories {
mavenCentral()
maven {
url 'http://nexus.gephi.org/nexus/content/repositories/public'
}
}
dependencies {
compile \
'javax.help:javahelp:2.0.05',
'com.connectina.swing:fontchooser:1.0',
'net.sourceforge.collections:collections-generic:4.01',
'org.apache.xmlgraphics:batik-svggen:1.7',
'org.apache.xmlgraphics:batik-swing:1.7',
'org.apache.xmlgraphics:batik-swing:1.7',
// Native JDK logger (java.util.logging)
//'org.slf4j:slf4j-jdk14:1.7.5',
@ -135,4 +131,3 @@ processResources << {
}
}
}

View File

@ -0,0 +1,169 @@
/*
* A font chooser JavaBean component.
* Copyright (C) 2009 Dr Christos Bohoris
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 3 as published by the Free Software Foundation;
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* swing@connectina.com
*/
package com.connectina.swing.fontchooser;
import java.awt.Font;
import java.awt.GraphicsEnvironment;
import java.util.ArrayList;
import java.util.List;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.EventListenerList;
/**
* A generic implementation of <code>FontSelectionModel</code>.
*
* @author Christos Bohoris
* @see java.awt.Font
*/
public class DefaultFontSelectionModel implements FontSelectionModel {
/**
* Only one <code>ChangeEvent</code> is needed per model instance
* since the event's only (read-only) state is the source property.
* The source of events generated here is always "this".
*/
protected transient ChangeEvent changeEvent = null;
/**
* A list of registered event listeners.
*/
protected EventListenerList listenerList = new EventListenerList();
private Font selectedFont;
private List availableFontNames = new ArrayList();
/**
* Creates a <code>DefaultFontSelectionModel</code> with the
* current font set to <code>new Font(Font.SANS_SERIF, Font.PLAIN, 12)
* </code>. This is the default constructor.
*/
public DefaultFontSelectionModel() {
this(new Font(JFontChooser.SANS_SERIF, Font.PLAIN, 12));
}
/**
* Creates a <code>DefaultFontSelectionModel</code> with the
* current font set to <code>font</code>, which should be
* non-<code>null</code>. Note that setting the font to
* <code>null</code> is undefined and may have unpredictable
* results.
*
* @param font the new <code>Font</code>
*/
public DefaultFontSelectionModel(Font font) {
selectedFont = font;
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
String[] families = ge.getAvailableFontFamilyNames();
for(int i = 0; i < families.length; i++) {
availableFontNames.add(families[i]);
}
}
/**
* Returns the selected <code>Font</code> which should be
* non-<code>null</code>.
*
* @return the selected <code>Font</code>
*/
public Font getSelectedFont() {
return selectedFont;
}
/**
* Sets the selected font to <code>font</code>.
* Note that setting the font to <code>null</code>
* is undefined and may have unpredictable results.
* This method fires a state changed event if it sets the
* current font to a new non-<code>null</code> font;
* if the new font is the same as the current font,
* no event is fired.
*
* @param font the new <code>Font</code>
*/
public void setSelectedFont(Font font) {
if (font != null && !selectedFont.equals(font)) {
selectedFont = font;
fireStateChanged();
}
}
/**
* Gets the available font names.
* Returns a list containing the names of all font families in this
* <code>GraphicsEnvironment</code> localized for the default locale,
* as returned by <code>Locale.getDefault()</code>.
*
* @return a list of String containing font family names localized for the
* default locale, or a suitable alternative name if no name exists
* for this locale
*/
public List getAvailableFontNames() {
return availableFontNames;
}
/**
* Adds a <code>ChangeListener</code> to the model.
*
* @param l the <code>ChangeListener</code> to be added
*/
public void addChangeListener(ChangeListener l) {
listenerList.add(ChangeListener.class, l);
}
/**
* Removes a <code>ChangeListener</code> from the model.
* @param l the <code>ChangeListener</code> to be removed
*/
public void removeChangeListener(ChangeListener l) {
listenerList.remove(ChangeListener.class, l);
}
/**
* Returns an array of all the <code>ChangeListener</code>s added
* to this <code>DefaultFontSelectionModel</code> with
* <code>addChangeListener</code>.
*
* @return all of the <code>ChangeListener</code>s added, or an empty
* array if no listeners have been added
*/
public ChangeListener[] getChangeListeners() {
return (ChangeListener[]) listenerList.getListeners(
ChangeListener.class);
}
/**
* Runs each <code>ChangeListener</code>'s
* <code>stateChanged</code> method.
*/
protected void fireStateChanged() {
Object[] listeners = listenerList.getListenerList();
for (int i = listeners.length - 2; i >= 0; i -= 2) {
if (listeners[i] == ChangeListener.class) {
if (changeEvent == null) {
changeEvent = new ChangeEvent(this);
}
((ChangeListener) listeners[i + 1]).stateChanged(changeEvent);
}
}
}
}

View File

@ -0,0 +1,110 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="0"/>
<Property name="title" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="" key="window.title" replaceFormat="bundle.getString(&quot;{key}&quot;)"/>
</Property>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,1,-112"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="basePanel">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Center"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="chooserPanel">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
<EmptyBorder bottom="0" left="12" right="11" top="12"/>
</Border>
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_AddingCodePost" type="java.lang.String" value="chooserPanel.add(chooserPane, java.awt.BorderLayout.CENTER);"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Center"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout">
<Property name="verticalGap" type="int" value="12"/>
</Layout>
<SubComponents>
<Component class="javax.swing.JSeparator" name="chooserSeparator">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Last"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="controlPanel">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
<EmptyBorder bottom="6" left="7" right="6" top="7"/>
</Border>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="South"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout">
<Property name="alignment" type="int" value="2"/>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="okButton">
<Properties>
<Property name="mnemonic" type="int" editor="org.netbeans.modules.i18n.form.FormI18nMnemonicEditor">
<ResourceString bundle="" key="" replaceFormat="bundle.getString(&quot;{key}&quot;)"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="" key="action.ok" replaceFormat="bundle.getString(&quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="cancelButton">
<Properties>
<Property name="mnemonic" type="int" editor="org.netbeans.modules.i18n.form.FormI18nMnemonicEditor">
<ResourceString bundle="" key="" replaceFormat="bundle.getString(&quot;{key}&quot;)"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="" key="action.cancel" replaceFormat="bundle.getString(&quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Form>

View File

@ -0,0 +1,162 @@
/*
* A font chooser JavaBean component.
* Copyright (C) 2009 Dr Christos Bohoris
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 3 as published by the Free Software Foundation;
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* swing@connectina.com
*/
package com.connectina.swing.fontchooser;
import java.awt.HeadlessException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.HashMap;
import java.util.Locale;
import java.util.ResourceBundle;
import javax.swing.JDialog;
import javax.swing.JFrame;
/**
* A dialog containing a <code>JFontChooser</code> as well as OK and
* Cancel buttons.
*
* @author Christos Bohoris
*/
class FontChooserDialog extends javax.swing.JDialog {
private static final long serialVersionUID = -953666562985797384L;
private static final HashMap<Locale,ResourceBundle> bundles
= new HashMap<Locale,ResourceBundle>();
private static ResourceBundle getBundle() {
Locale loc = Locale.getDefault();
ResourceBundle ret = bundles.get(loc);
if (ret == null) {
ret = ResourceBundle.getBundle("resources/connectina/FontChooserDialog");
bundles.put(loc, ret);
}
return ret;
}
private JFontChooser chooserPane;
FontChooserDialog(JFrame owner, boolean modal,
JFontChooser chooserPane, ActionListener selectionListener)
throws HeadlessException {
super(owner, modal);
initDialog(chooserPane, selectionListener);
}
FontChooserDialog(JDialog owner, boolean modal,
JFontChooser chooserPane, ActionListener selectionListener)
throws HeadlessException {
super(owner, modal);
initDialog(chooserPane, selectionListener);
}
private void initDialog(JFontChooser chooserPane, ActionListener selectionListener) {
this.chooserPane = chooserPane;
initComponents(getBundle());
okButton.addActionListener(selectionListener);
okButton.addActionListener(new OKActionListener());
cancelButton.addActionListener(new CancelActionListener());
addWindowListener(new FontChooserDialogAdapter());
getRootPane().setDefaultButton(okButton);
okButton.requestFocusInWindow();
}
private class FontChooserDialogAdapter extends WindowAdapter {
// @Override
public void windowClosing(WindowEvent event) {
dispose();
}
}
private class OKActionListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
dispose();
}
}
private class CancelActionListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
dispose();
}
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// @SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents(ResourceBundle bundle) {
basePanel = new javax.swing.JPanel();
chooserPanel = new javax.swing.JPanel();
chooserSeparator = new javax.swing.JSeparator();
controlPanel = new javax.swing.JPanel();
okButton = new javax.swing.JButton();
cancelButton = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
setTitle(bundle.getString("window.title"));
basePanel.setLayout(new java.awt.BorderLayout());
chooserPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(12, 12, 0, 11));
chooserPanel.setLayout(new java.awt.BorderLayout(0, 12));
chooserPanel.add(chooserSeparator, java.awt.BorderLayout.PAGE_END);
basePanel.add(chooserPanel, java.awt.BorderLayout.CENTER);
chooserPanel.add(chooserPane, java.awt.BorderLayout.CENTER);
controlPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(7, 7, 6, 6));
controlPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));
okButton.setMnemonic(bundle.getString("action.ok.mnemonic").charAt(0));
okButton.setText(bundle.getString("action.ok"));
controlPanel.add(okButton);
cancelButton.setMnemonic(bundle.getString("action.cancel.mnemonic").charAt(0));
cancelButton.setText(bundle.getString("action.cancel"));
controlPanel.add(cancelButton);
basePanel.add(controlPanel, java.awt.BorderLayout.SOUTH);
getContentPane().add(basePanel, java.awt.BorderLayout.CENTER);
pack();
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel basePanel;
private javax.swing.JButton cancelButton;
private javax.swing.JPanel chooserPanel;
private javax.swing.JSeparator chooserSeparator;
private javax.swing.JPanel controlPanel;
private javax.swing.JButton okButton;
// End of variables declaration//GEN-END:variables
}

View File

@ -0,0 +1,82 @@
/*
* A font chooser JavaBean component.
* Copyright (C) 2009 Dr Christos Bohoris
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 3 as published by the Free Software Foundation;
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* swing@connectina.com
*/
package com.connectina.swing.fontchooser;
import java.awt.Font;
import java.util.List;
import javax.swing.event.ChangeListener;
/**
* A model that supports selecting a <code>Font</code>.
*
* @author Christos Bohoris
* @see java.awt.Font
*/
public interface FontSelectionModel {
/**
* Returns the selected <code>Font</code> which should be
* non-<code>null</code>.
*
* @return the selected <code>Font</code>
* @see #setSelectedFont
*/
Font getSelectedFont();
/**
* Sets the selected font to <code>font</code>.
* Note that setting the font to <code>null</code>
* is undefined and may have unpredictable results.
* This method fires a state changed event if it sets the
* current font to a new non-<code>null</code> font.
*
* @param font the new <code>Font</code>
* @see #getSelectedFont
* @see #addChangeListener
*/
void setSelectedFont(Font font);
/**
* Gets the available font names.
* Returns a list containing the names of all font families in this
* <code>GraphicsEnvironment</code> localized for the default locale,
* as returned by <code>Locale.getDefault()</code>.
*
* @return a list of String containing font family names localized for the
* default locale, or a suitable alternative name if no name exists
* for this locale
*/
List getAvailableFontNames();
/**
* Adds <code>listener</code> as a listener to changes in the model.
*
* @param listener the <code>ChangeListener</code> to be added
*/
void addChangeListener(ChangeListener listener);
/**
* Removes <code>listener</code> as a listener to changes in the model.
*
* @param listener the <code>ChangeListener</code> to be removed
*/
void removeChangeListener(ChangeListener listener);
}

View File

@ -0,0 +1,209 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,1,-112"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="fontPanel">
<AuxValues>
<AuxValue name="JavaCodeGenerator_AddingCodePost" type="java.lang.String" value="familyLabel.setDisplayedMnemonic(bundle.getString(&quot;font.family.mnemonic&quot;).charAt(0));&#xd;&#xa;familyLabel.setText(bundle.getString(&quot;font.family&quot;));&#xd;&#xa;styleLabel.setDisplayedMnemonic(bundle.getString(&quot;font.style.mnemonic&quot;).charAt(0));&#xd;&#xa;styleLabel.setText(bundle.getString(&quot;font.style&quot;));&#xd;&#xa;sizeLabel.setDisplayedMnemonic(bundle.getString(&quot;font.size.mnemonic&quot;).charAt(0));&#xd;&#xa;sizeLabel.setText(bundle.getString(&quot;font.size&quot;));&#xd;&#xa;previewLabel.setDisplayedMnemonic(bundle.getString(&quot;font.preview.mnemonic&quot;).charAt(0));&#xd;&#xa;previewLabel.setText(bundle.getString(&quot;font.preview&quot;));"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Center"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Component class="javax.swing.JLabel" name="familyLabel">
<Properties>
<Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
<ComponentRef name="familyList"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="5" insetsRight="11" anchor="17" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JLabel" name="styleLabel">
<Properties>
<Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
<ComponentRef name="styleList"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="5" insetsRight="11" anchor="17" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JLabel" name="sizeLabel">
<Properties>
<Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
<ComponentRef name="sizeList"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="5" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Container class="javax.swing.JScrollPane" name="familyScrollPane">
<Properties>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[80, 50]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[240, 150]"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="-1" gridY="1" gridWidth="1" gridHeight="2" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="11" insetsRight="11" anchor="17" weightX="1.0" weightY="1.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JList" name="familyList">
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JScrollPane" name="styleScrollPane">
<Properties>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[60, 120]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[80, 150]"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="-1" gridY="1" gridWidth="1" gridHeight="2" fill="3" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="11" insetsRight="11" anchor="17" weightX="0.0" weightY="1.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JList" name="styleList">
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JSpinner" name="sizeSpinner">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="12" maximum="128" minimum="6" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_CreateCodePost" type="java.lang.String" value="int spinnerHeight = (int)sizeSpinner.getPreferredSize().getHeight();&#xd;&#xa;sizeSpinner.setPreferredSize(new Dimension(60, spinnerHeight));"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="2" gridY="1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="5" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Container class="javax.swing.JScrollPane" name="sizeScrollPane">
<Properties>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[50, 120]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[60, 150]"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="-1" gridY="2" gridWidth="1" gridHeight="1" fill="3" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="11" insetsRight="0" anchor="17" weightX="0.0" weightY="1.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JList" name="sizeList">
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="previewPanel">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="South"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Component class="javax.swing.JLabel" name="previewLabel">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="5" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Container class="javax.swing.JPanel" name="previewAreaPanel">
<Properties>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="ff" green="ff" red="ff" type="rgb"/>
</Property>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo">
<EtchetBorder/>
</Border>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[200, 80]"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="-1" gridY="1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
<Component class="javax.swing.JLabel" name="previewAreaLabel">
<Properties>
<Property name="horizontalAlignment" type="int" value="0"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Center"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Form>

View File

@ -0,0 +1,537 @@
/*
* A font chooser JavaBean component.
* Copyright (C) 2009 Dr Christos Bohoris
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 3 as published by the Free Software Foundation;
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* swing@connectina.com
*/
package com.connectina.swing.fontchooser;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.HeadlessException;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
import java.util.ResourceBundle;
import javax.swing.DefaultListModel;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.ListSelectionModel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
/**
* Provides a pane of controls designed to allow a user to
* select a <code>Font</code>.
*
* @author Christos Bohoris
* @see java.awt.Font
*/
public class JFontChooser extends JPanel {
static final String SANS_SERIF = "SansSerif";
private static final long serialVersionUID = 5157499702004637097L;
private static final HashMap<Locale,ResourceBundle> bundles
= new HashMap<Locale,ResourceBundle>();
private static ResourceBundle getBundle() {
Locale loc = Locale.getDefault();
ResourceBundle ret = bundles.get(loc);
if (ret == null) {
ret = ResourceBundle.getBundle("resources/connectina/JFontChooser");
bundles.put(loc, ret);
}
return ret;
}
private FontSelectionModel selectionModel;
/**
* The selection model property name.
*/
public static final String SELECTION_MODEL_PROPERTY = "selectionModel";
/**
* Creates a FontChooser pane with an initial default Font
* (Sans Serif, Plain, 12).
*/
public JFontChooser() {
this(new Font(SANS_SERIF, Font.PLAIN, 12));
}
/**
* Creates a FontChooser pane with the specified initial Font.
*
* @param initialFont the initial Font set in the chooser
*/
public JFontChooser(Font initialFont) {
this(new DefaultFontSelectionModel(initialFont));
}
/**
* Creates a FontChooser pane with the specified
* <code>FontSelectionModel</code>.
*
* @param model the <code>FontSelectionModel</code> to be used
*/
public JFontChooser(FontSelectionModel model) {
this.selectionModel = model;
ResourceBundle bundle = getBundle();
initComponents(bundle);
initPanel(bundle);
}
/**
* Gets the current Font value from the FontChooser.
* By default, this delegates to the model.
*
* @return the current Font value of the FontChooser
*/
public Font getSelectedFont() {
return selectionModel.getSelectedFont();
}
/**
* Sets the current Font of the FontChooser to the specified Font.
* The <code>FontSelectionModel</code> will fire a <code>ChangeEvent</code>
* @param Font the Font to be set in the Font chooser
* @see JComponent#addPropertyChangeListener
*/
public void setSelectedFont(Font Font) {
selectionModel.setSelectedFont(Font);
}
/**
* Returns the data model that handles Font selections.
*
* @return a <code>FontSelectionModel</code> object
*/
public FontSelectionModel getSelectionModel() {
return selectionModel;
}
/**
* Sets the model containing the selected Font.
*
* @param newModel the new <code>FontSelectionModel</code> object
*/
public void setSelectionModel(FontSelectionModel newModel) {
FontSelectionModel oldModel = selectionModel;
selectionModel = newModel;
firePropertyChange(JFontChooser.SELECTION_MODEL_PROPERTY, oldModel, newModel);
}
/**
* Shows a modal FontChooser dialog and blocks until the
* dialog is hidden. If the user presses the "OK" button, then
* this method hides/disposes the dialog and returns the selected Font.
* If the user presses the "Cancel" button or closes the dialog without
* pressing "OK", then this method hides/disposes the dialog and returns
* <code>null</code>.
*
* @param parent the parent <code>JFrame</code> for the dialog
* @param initialFont the initial Font set when the FontChooser is shown
* @return the selected Font or <code>null</code> if the user opted out
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
* returns true.
* @see java.awt.GraphicsEnvironment#isHeadless
*/
public static Font showDialog(Window parent, Font initialFont) throws HeadlessException {
final JFontChooser pane = new JFontChooser(initialFont != null ? initialFont : new Font(SANS_SERIF, Font.PLAIN, 12));
FontSelectionActionListener selectionListener = new FontSelectionActionListener(pane);
JDialog dialog = createDialog(parent, true, pane, selectionListener);
dialog.setLocationRelativeTo(parent);
dialog.setVisible(true);
return selectionListener.getFont();
}
/**
* Shows a modal FontChooser dialog and blocks until the
* dialog is hidden. If the user presses the "OK" button, then
* this method hides/disposes the dialog and returns the selected Font.
* If the user presses the "Cancel" button or closes the dialog without
* pressing "OK", then this method hides/disposes the dialog and returns
* <code>null</code>.
*
* @param parent the parent <code>JFrame</code> for the dialog
* @param fontChooser the FontChooser to be use in this dialog
* @param initialFont the initial Font set when the FontChooser is shown
* @return the selected Font or <code>null</code> if the user opted out
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
* returns true.
* @see java.awt.GraphicsEnvironment#isHeadless
*/
public static Font showDialog(Window parent, JFontChooser fontChooser, Font initialFont) throws HeadlessException {
fontChooser.setSelectedFont(initialFont != null ? initialFont : new Font(SANS_SERIF, Font.PLAIN, 12));
FontSelectionActionListener selectionListener = new FontSelectionActionListener(fontChooser);
JDialog dialog = createDialog(parent, true, fontChooser, selectionListener);
dialog.setLocationRelativeTo(parent);
dialog.setVisible(true);
return selectionListener.getFont();
}
/**
* Creates and returns a new dialog containing the specified
* <code>FontChooser</code> pane along with "OK" and "Cancel"
* buttons. If the "OK" or "Cancel" buttons are pressed, the dialog is
* automatically hidden (but not disposed).
*
* @param parent the parent component for the dialog
* @param modal a boolean. When true, the remainder of the program
* is inactive until the dialog is closed.
* @param chooserPane the Font-chooser to be placed inside the dialog
* @param okListener the ActionListener invoked when "OK" is pressed
* @return a new dialog containing the FontChooser pane
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
* returns true.
* @see java.awt.GraphicsEnvironment#isHeadless
*/
public static JDialog createDialog(Window parent, boolean modal,
JFontChooser chooserPane, ActionListener okListener) throws HeadlessException {
if (parent instanceof JDialog) {
return new FontChooserDialog((JDialog) parent, modal, chooserPane,
okListener);
} else if (parent instanceof JFrame) {
return new FontChooserDialog((JFrame) parent, modal, chooserPane,
okListener);
} else {
throw new IllegalArgumentException("JFrame or JDialog parent is required.");
}
}
/**
* Adds a <code>ChangeListener</code> to the model.
*
* @param l the <code>ChangeListener</code> to be added
*/
public void addChangeListener(ChangeListener l) {
selectionModel.addChangeListener(l);
}
/**
* Removes a <code>ChangeListener</code> from the model.
* @param l the <code>ChangeListener</code> to be removed
*/
public void removeChangeListener(ChangeListener l) {
selectionModel.removeChangeListener(l);
}
private void initPanel(ResourceBundle bundle) {
// Set the font family names
DefaultListModel listModel = new DefaultListModel();
for(Iterator it = selectionModel.getAvailableFontNames().iterator();
it.hasNext(); ) {
listModel.addElement(it.next());
}
familyList.setModel(listModel);
familyList.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
familyList.setSelectedValue(selectionModel.getSelectedFont().getName(), true);
familyList.addListSelectionListener(new FamilyListSelectionListener());
// Set the font styles
listModel = new DefaultListModel();
listModel.addElement(getFontStyleName(Font.PLAIN, bundle));
listModel.addElement(getFontStyleName(Font.BOLD, bundle));
listModel.addElement(getFontStyleName(Font.ITALIC, bundle));
listModel.addElement(getFontStyleName(Font.BOLD + Font.ITALIC, bundle));
styleList.setModel(listModel);
styleList.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
styleList.setSelectedIndex(selectionModel.getSelectedFont().getStyle());
styleList.addListSelectionListener(new StyleListSelectionListener());
// Set the font sizes
listModel = new DefaultListModel();
int size = 6;
int step = 1;
int ceil = 14;
do {
listModel.addElement(Integer.valueOf(size));
if (size == ceil) {
ceil += ceil;
step += step;
}
size = size + step;
} while (size <= 128);
sizeList.setModel(listModel);
sizeList.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
Integer selectedSize = Integer.valueOf(selectionModel.getSelectedFont().getSize());
if (listModel.contains(selectedSize)) {
sizeList.setSelectedValue(selectedSize, true);
}
sizeList.addListSelectionListener(new SizeListSelectionListener());
sizeSpinner.addChangeListener(new SizeSpinnerListener());
sizeSpinner.setValue(selectedSize);
previewAreaLabel.setFont(selectionModel.getSelectedFont());
previewAreaLabel.setText(bundle.getString("font.preview.text"));
}
private String getFontStyleName(int index, ResourceBundle bundle) {
String result = null;
switch (index) {
case 0:
result = bundle.getString("style.plain");
break;
case 1:
result = bundle.getString("style.bold");
break;
case 2:
result = bundle.getString("style.italic");
break;
case 3:
result = bundle.getString("style.bolditalic");
break;
default:
result = bundle.getString("style.plain");
}
return result;
}
private class FamilyListSelectionListener implements ListSelectionListener {
public void valueChanged(ListSelectionEvent e) {
if (!e.getValueIsAdjusting()) {
Font sel = new Font(familyList.getSelectedValue().toString(),
styleList.getSelectedIndex(),
Integer.parseInt(sizeSpinner.getValue().toString()));
selectionModel.setSelectedFont(sel);
previewAreaLabel.setFont(selectionModel.getSelectedFont());
}
}
}
private class StyleListSelectionListener implements ListSelectionListener {
public void valueChanged(ListSelectionEvent e) {
if (!e.getValueIsAdjusting()) {
selectionModel.setSelectedFont(selectionModel.getSelectedFont().deriveFont(styleList.getSelectedIndex()));
previewAreaLabel.setFont(selectionModel.getSelectedFont());
}
}
}
private class SizeListSelectionListener implements ListSelectionListener {
public void valueChanged(ListSelectionEvent e) {
if (!e.getValueIsAdjusting()) {
int index = ((DefaultListModel) sizeList.getModel()).indexOf(sizeList.getSelectedValue());
if (index > -1) {
sizeSpinner.setValue((Integer) sizeList.getSelectedValue());
}
float newSize = Float.parseFloat(sizeSpinner.getValue().toString());
Font newFont = selectionModel.getSelectedFont().deriveFont(newSize);
selectionModel.setSelectedFont(newFont);
previewAreaLabel.setFont(selectionModel.getSelectedFont());
}
}
}
private class SizeSpinnerListener implements ChangeListener {
public void stateChanged(ChangeEvent e) {
Integer value = (Integer) sizeSpinner.getValue();
int index = ((DefaultListModel) sizeList.getModel()).indexOf(value);
if (index > -1) {
sizeList.setSelectedValue(value, true);
} else {
sizeList.clearSelection();
}
}
}
private static class FontSelectionActionListener implements ActionListener, Serializable {
private static final long serialVersionUID = 8141913945783951693L;
private JFontChooser chooser;
private Font font;
public FontSelectionActionListener(JFontChooser c) {
chooser = c;
}
public void actionPerformed(ActionEvent e) {
font = chooser.getSelectedFont();
}
public Font getFont() {
return font;
}
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
//Java5 @SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents(ResourceBundle bundle) {
java.awt.GridBagConstraints gridBagConstraints;
fontPanel = new javax.swing.JPanel();
familyLabel = new javax.swing.JLabel();
styleLabel = new javax.swing.JLabel();
sizeLabel = new javax.swing.JLabel();
familyScrollPane = new javax.swing.JScrollPane();
familyList = new javax.swing.JList();
styleScrollPane = new javax.swing.JScrollPane();
styleList = new javax.swing.JList();
sizeSpinner = new javax.swing.JSpinner();
int spinnerHeight = (int)sizeSpinner.getPreferredSize().getHeight();
sizeSpinner.setPreferredSize(new Dimension(60, spinnerHeight));
sizeScrollPane = new javax.swing.JScrollPane();
sizeList = new javax.swing.JList();
previewPanel = new javax.swing.JPanel();
previewLabel = new javax.swing.JLabel();
previewAreaPanel = new javax.swing.JPanel();
previewAreaLabel = new javax.swing.JLabel();
setLayout(new java.awt.BorderLayout());
fontPanel.setLayout(new java.awt.GridBagLayout());
familyLabel.setLabelFor(familyList);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 11);
fontPanel.add(familyLabel, gridBagConstraints);
styleLabel.setLabelFor(styleList);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 11);
fontPanel.add(styleLabel, gridBagConstraints);
sizeLabel.setLabelFor(sizeList);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 0);
fontPanel.add(sizeLabel, gridBagConstraints);
familyScrollPane.setMinimumSize(new java.awt.Dimension(80, 50));
familyScrollPane.setPreferredSize(new java.awt.Dimension(240, 150));
familyScrollPane.setViewportView(familyList);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridy = 1;
gridBagConstraints.gridheight = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
fontPanel.add(familyScrollPane, gridBagConstraints);
styleScrollPane.setMinimumSize(new java.awt.Dimension(60, 120));
styleScrollPane.setPreferredSize(new java.awt.Dimension(80, 150));
styleScrollPane.setViewportView(styleList);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridy = 1;
gridBagConstraints.gridheight = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.weighty = 1.0;
gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
fontPanel.add(styleScrollPane, gridBagConstraints);
sizeSpinner.setModel(new javax.swing.SpinnerNumberModel(12, 6, 128, 1));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 0);
fontPanel.add(sizeSpinner, gridBagConstraints);
sizeScrollPane.setMinimumSize(new java.awt.Dimension(50, 120));
sizeScrollPane.setPreferredSize(new java.awt.Dimension(60, 150));
sizeScrollPane.setViewportView(sizeList);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.weighty = 1.0;
gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 0);
fontPanel.add(sizeScrollPane, gridBagConstraints);
add(fontPanel, java.awt.BorderLayout.CENTER);
familyLabel.setDisplayedMnemonic(bundle.getString("font.family.mnemonic").charAt(0));
familyLabel.setText(bundle.getString("font.family"));
styleLabel.setDisplayedMnemonic(bundle.getString("font.style.mnemonic").charAt(0));
styleLabel.setText(bundle.getString("font.style"));
sizeLabel.setDisplayedMnemonic(bundle.getString("font.size.mnemonic").charAt(0));
sizeLabel.setText(bundle.getString("font.size"));
previewLabel.setDisplayedMnemonic(bundle.getString("font.preview.mnemonic").charAt(0));
previewLabel.setText(bundle.getString("font.preview"));
previewPanel.setLayout(new java.awt.GridBagLayout());
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 0);
previewPanel.add(previewLabel, gridBagConstraints);
previewAreaPanel.setBackground(new java.awt.Color(255, 255, 255));
previewAreaPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
previewAreaPanel.setPreferredSize(new java.awt.Dimension(200, 80));
previewAreaPanel.setLayout(new java.awt.BorderLayout());
previewAreaLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
previewAreaPanel.add(previewAreaLabel, java.awt.BorderLayout.CENTER);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridy = 1;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.weightx = 1.0;
previewPanel.add(previewAreaPanel, gridBagConstraints);
add(previewPanel, java.awt.BorderLayout.SOUTH);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel familyLabel;
private javax.swing.JList familyList;
private javax.swing.JScrollPane familyScrollPane;
private javax.swing.JPanel fontPanel;
private javax.swing.JLabel previewAreaLabel;
private javax.swing.JPanel previewAreaPanel;
private javax.swing.JLabel previewLabel;
private javax.swing.JPanel previewPanel;
private javax.swing.JLabel sizeLabel;
private javax.swing.JList sizeList;
private javax.swing.JScrollPane sizeScrollPane;
private javax.swing.JSpinner sizeSpinner;
private javax.swing.JLabel styleLabel;
private javax.swing.JList styleList;
private javax.swing.JScrollPane styleScrollPane;
// End of variables declaration//GEN-END:variables
}

View File

@ -0,0 +1,39 @@
/*
* A font chooser JavaBean component.
* Copyright (C) 2009 Dr Christos Bohoris
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 3 as published by the Free Software Foundation;
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* swing@connectina.com
*/
package com.connectina.swing.fontchooser;
import java.beans.BeanDescriptor;
/**
* The bean descriptor for the <code>JFontChooser</code> JavaBean.
*
* @author Christos Bohoris
* @see JFontChooser
*/
public class JFontChooserBeanDescriptor extends BeanDescriptor {
public JFontChooserBeanDescriptor() {
super(JFontChooser.class);
setShortDescription("<html>com.connectina.fontchooser.JFontChooser<br>A font selection pane.</html>");
setDisplayName("Font Chooser");
setPreferred(true);
}
}

View File

@ -0,0 +1,76 @@
/*
* A font chooser JavaBean component.
* Copyright (C) 2009 Dr Christos Bohoris
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 3 as published by the Free Software Foundation;
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* swing@connectina.com
*/
package com.connectina.swing.fontchooser;
import java.awt.Image;
import java.beans.*;
/**
* The bean information for the <code>JFontChooser</code> JavaBean.
*
* @author Christos Bohoris
* @see JFontChooser
*/
public class JFontChooserBeanInfo extends SimpleBeanInfo {
/* 16x16 color icon. */
private final Image iconColor16 = loadImage("resources/connectina/FontChooser16Color.png");
/* 32x32 color icon. */
private final Image iconColor32 = loadImage("resources/connectina/FontChooser32Color.png");
/* 16x16 mono icon. */
private final Image iconMono16 = loadImage("resources/connectina/FontChooser16Mono.png");
/* 32x32 mono icon. */
private final Image iconMono32 = loadImage("resources/connectina/FontChooser32Mono.png");
/* The bean descriptor. */
private JFontChooserBeanDescriptor descriptor = new JFontChooserBeanDescriptor();
/**
* Get the bean descriptor.
*
* @return the bean descriptor
*/
//Java5 @Override
public BeanDescriptor getBeanDescriptor() {
return descriptor;
}
/**
* Get the appropriate icon.
*
* @param iconKind the icon kind
* @return the image
*/
//Java5 @Override
public Image getIcon(int iconKind) {
switch (iconKind) {
case ICON_COLOR_16x16:
return iconColor16;
case ICON_COLOR_32x32:
return iconColor32;
case ICON_MONO_16x16:
return iconMono16;
case ICON_MONO_32x32:
return iconMono32;
}
return null;
}
}

View File

@ -0,0 +1,22 @@
/**
* <pre> Provides a Swing font chooser JavaBean component.
*
* Copyright (C) 2009 Dr Christos Bohoris
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 3 as published by the Free Software Foundation;
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* swing@connectina.com</pre>
*/
package com.connectina.swing.fontchooser;