58 lines
2.3 KiB
Plaintext
58 lines
2.3 KiB
Plaintext
package org.ka2ddo.yaac.gui.config;
|
|
/*
|
|
* Copyright (C) 2011-2012 Andrew Pavlin, KA2DDO
|
|
* This file is part of YAAC (Yet Another APRS Client).
|
|
*
|
|
* YAAC is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* YAAC 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
|
|
* and GNU Lesser General Public License along with YAAC. If not,
|
|
* see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
import javax.swing.*;
|
|
import java.awt.*;
|
|
import java.util.ArrayList;
|
|
|
|
/**
|
|
* This class renders a list of family-related Font object in a JList.
|
|
*/
|
|
class FontFamilyRenderer extends JLabel implements ListCellRenderer {
|
|
/**
|
|
* Return a component that has been configured to display the specified
|
|
* value. That component's <code>paint</code> method is then called to
|
|
* "render" the cell. If it is necessary to compute the dimensions
|
|
* of a list because the list cells do not have a fixed size, this method
|
|
* is called to generate a component on which <code>getPreferredSize</code>
|
|
* can be invoked.
|
|
*
|
|
* @param list The JList we're painting.
|
|
* @param value The value returned by list.getModel().getElementAt(index).
|
|
* @param index The cells index.
|
|
* @param isSelected True if the specified cell was selected.
|
|
* @param cellHasFocus True if the specified cell has the focus.
|
|
* @return A component whose paint() method will render the specified value.
|
|
* @see javax.swing.JList
|
|
* @see javax.swing.ListSelectionModel
|
|
* @see javax.swing.ListModel
|
|
*/
|
|
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
|
ArrayList<Font> fList = (ArrayList<Font>)value;
|
|
if (null != value) {
|
|
setText(fList.get(0).getFamily());
|
|
setFont(new Font(fList.get(0).getFamily(), Font.PLAIN, 12));
|
|
} else {
|
|
setText("");
|
|
}
|
|
return this;
|
|
}
|
|
}
|