<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FSwing_Components%2FButton</id>
		<title>Java/Swing Components/Button - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FSwing_Components%2FButton"/>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Swing_Components/Button&amp;action=history"/>
		<updated>2026-04-24T04:26:23Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java/Swing_Components/Button&amp;diff=8197&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Swing_Components/Button&amp;diff=8197&amp;oldid=prev"/>
				<updated>2010-06-01T06:56:17Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 06:56, 1 июня 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java/Swing_Components/Button&amp;diff=8196&amp;oldid=prev</id>
		<title> в 18:01, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Swing_Components/Button&amp;diff=8196&amp;oldid=prev"/>
				<updated>2010-05-31T18:01:46Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== A button which paints on it one or more scaled arrows in one of the cardinal directions ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
//Revised from greef ui;&lt;br /&gt;
import java.awt.BorderLayout;&lt;br /&gt;
import java.awt.ruponent;&lt;br /&gt;
import java.awt.Graphics;&lt;br /&gt;
import javax.swing.Icon;&lt;br /&gt;
import javax.swing.JLabel;&lt;br /&gt;
import javax.swing.JPanel;&lt;br /&gt;
import javax.swing.JScrollPane;&lt;br /&gt;
import javax.swing.JTable;&lt;br /&gt;
import javax.swing.SwingConstants;&lt;br /&gt;
import javax.swing.table.DefaultTableCellRenderer;&lt;br /&gt;
import javax.swing.table.DefaultTableModel;&lt;br /&gt;
import javax.swing.table.TableColumnModel;&lt;br /&gt;
/**&lt;br /&gt;
 * A button which paints on it one or more scaled arrows in one of the cardinal directions.&lt;br /&gt;
 * @author Adrian BER&lt;br /&gt;
 */&lt;br /&gt;
public class ArrowIcon implements Icon {&lt;br /&gt;
    /** The cardinal direction of the arrow(s). */&lt;br /&gt;
    private int direction;&lt;br /&gt;
    /** The number of arrows. */&lt;br /&gt;
    private int arrowCount;&lt;br /&gt;
    /** The arrow size. */&lt;br /&gt;
    private int arrowSize;&lt;br /&gt;
    public ArrowIcon(int direction, int arrowCount, int arrowSize) {&lt;br /&gt;
        this.direction = direction;&lt;br /&gt;
        this.arrowCount = arrowCount;&lt;br /&gt;
        this.arrowSize = arrowSize;&lt;br /&gt;
    }&lt;br /&gt;
    /** Returns the cardinal direction of the arrow(s).&lt;br /&gt;
     * @see #setDirection(int)&lt;br /&gt;
     */&lt;br /&gt;
    public int getDirection() {&lt;br /&gt;
        return direction;&lt;br /&gt;
    }&lt;br /&gt;
    /** Sets the cardinal direction of the arrow(s).&lt;br /&gt;
     * @param direction the direction of the arrow(s), can be SwingConstants.NORTH,&lt;br /&gt;
     * SwingConstants.SOUTH, SwingConstants.WEST or SwingConstants.EAST&lt;br /&gt;
     * @see #getDirection()&lt;br /&gt;
     */&lt;br /&gt;
    public void setDirection(int direction) {&lt;br /&gt;
        this.direction = direction;&lt;br /&gt;
    }&lt;br /&gt;
    /** Returns the number of arrows. */&lt;br /&gt;
    public int getArrowCount() {&lt;br /&gt;
        return arrowCount;&lt;br /&gt;
    }&lt;br /&gt;
    /** Sets the number of arrows. */&lt;br /&gt;
    public void setArrowCount(int arrowCount) {&lt;br /&gt;
        this.arrowCount = arrowCount;&lt;br /&gt;
    }&lt;br /&gt;
    /** Returns the arrow size. */&lt;br /&gt;
    public int getArrowSize() {&lt;br /&gt;
        return arrowSize;&lt;br /&gt;
    }&lt;br /&gt;
    /** Sets the arrow size. */&lt;br /&gt;
    public void setArrowSize(int arrowSize) {&lt;br /&gt;
        this.arrowSize = arrowSize;&lt;br /&gt;
    }&lt;br /&gt;
    public void paintIcon(Component c, Graphics g, int x, int y) {&lt;br /&gt;
        // paint the arrows&lt;br /&gt;
        int w = getIconWidth();&lt;br /&gt;
        int h = getIconHeight();&lt;br /&gt;
        for (int i = 0; i &amp;lt; arrowCount; i++) {&lt;br /&gt;
            paintArrow(g,&lt;br /&gt;
                    (x + w - arrowSize * (direction == SwingConstants.EAST&lt;br /&gt;
                            || direction == SwingConstants.WEST ? arrowCount : 1)) / 2&lt;br /&gt;
                            + arrowSize * (direction == SwingConstants.EAST&lt;br /&gt;
                            || direction == SwingConstants.WEST ? i : 0),&lt;br /&gt;
                    (y + h - arrowSize * (direction == SwingConstants.EAST&lt;br /&gt;
                            || direction == SwingConstants.WEST ? 1 : arrowCount)) / 2&lt;br /&gt;
                            + arrowSize * (direction == SwingConstants.EAST&lt;br /&gt;
                            || direction == SwingConstants.WEST ? 0 : i)&lt;br /&gt;
                    );&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    public int getIconWidth() {&lt;br /&gt;
        return arrowSize * (direction == SwingConstants.EAST&lt;br /&gt;
                || direction == SwingConstants.WEST ? arrowCount : 3);&lt;br /&gt;
    }&lt;br /&gt;
    public int getIconHeight() {&lt;br /&gt;
        return arrowSize * (direction == SwingConstants.NORTH&lt;br /&gt;
                || direction == SwingConstants.SOUTH ? arrowCount : 3);&lt;br /&gt;
    }&lt;br /&gt;
    private void paintArrow(Graphics g, int x, int y) {&lt;br /&gt;
        int mid, i, j;&lt;br /&gt;
        j = 0;&lt;br /&gt;
        arrowSize = Math.max(arrowSize, 2);&lt;br /&gt;
        mid = (arrowSize / 2) - 1;&lt;br /&gt;
        g.translate(x, y);&lt;br /&gt;
        switch (direction) {&lt;br /&gt;
            case SwingConstants.NORTH:&lt;br /&gt;
                for (i = 0; i &amp;lt; arrowSize; i++) {&lt;br /&gt;
                    g.drawLine(mid - i, i, mid + i, i);&lt;br /&gt;
                }&lt;br /&gt;
                break;&lt;br /&gt;
            case SwingConstants.SOUTH:&lt;br /&gt;
                j = 0;&lt;br /&gt;
                for (i = arrowSize - 1; i &amp;gt;= 0; i--) {&lt;br /&gt;
                    g.drawLine(mid - i, j, mid + i, j);&lt;br /&gt;
                    j++;&lt;br /&gt;
                }&lt;br /&gt;
                break;&lt;br /&gt;
            case SwingConstants.WEST:&lt;br /&gt;
                for (i = 0; i &amp;lt; arrowSize; i++) {&lt;br /&gt;
                    g.drawLine(i, mid - i, i, mid + i);&lt;br /&gt;
                }&lt;br /&gt;
                break;&lt;br /&gt;
            case SwingConstants.EAST:&lt;br /&gt;
                j = 0;&lt;br /&gt;
                for (i = arrowSize - 1; i &amp;gt;= 0; i--) {&lt;br /&gt;
                    g.drawLine(j, mid - i, j, mid + i);&lt;br /&gt;
                    j++;&lt;br /&gt;
                }&lt;br /&gt;
                break;&lt;br /&gt;
        }&lt;br /&gt;
        g.translate(-x, -y);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Arrow Button ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
import javax.swing.*;&lt;br /&gt;
import java.awt.*;&lt;br /&gt;
/**&lt;br /&gt;
 * A button which paints on it one or more scaled arrows in one of the cardinal directions.&lt;br /&gt;
 * @author Adrian BER&lt;br /&gt;
 */&lt;br /&gt;
public class ArrowButton extends JButton {&lt;br /&gt;
    /** The cardinal direction of the arrow(s). */&lt;br /&gt;
    private int direction;&lt;br /&gt;
    /** The number of arrows. */&lt;br /&gt;
    private int arrowCount;&lt;br /&gt;
    /** The arrow size. */&lt;br /&gt;
    private int arrowSize;&lt;br /&gt;
    public ArrowButton(int direction, int arrowCount, int arrowSize) {&lt;br /&gt;
        setMargin(new Insets(0, 2, 0, 2));&lt;br /&gt;
        setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));&lt;br /&gt;
        this.direction = direction;&lt;br /&gt;
        this.arrowCount = arrowCount;&lt;br /&gt;
        this.arrowSize = arrowSize;&lt;br /&gt;
    }&lt;br /&gt;
    /** Returns the cardinal direction of the arrow(s).&lt;br /&gt;
     * @see #setDirection(int)&lt;br /&gt;
     */&lt;br /&gt;
    public int getDirection() {&lt;br /&gt;
        return direction;&lt;br /&gt;
    }&lt;br /&gt;
    /** Sets the cardinal direction of the arrow(s).&lt;br /&gt;
     * @param direction the direction of the arrow(s), can be SwingConstants.NORTH,&lt;br /&gt;
     * SwingConstants.SOUTH, SwingConstants.WEST or SwingConstants.EAST&lt;br /&gt;
     * @see #getDirection()&lt;br /&gt;
     */&lt;br /&gt;
    public void setDirection(int direction) {&lt;br /&gt;
        this.direction = direction;&lt;br /&gt;
    }&lt;br /&gt;
    /** Returns the number of arrows. */&lt;br /&gt;
    public int getArrowCount() {&lt;br /&gt;
        return arrowCount;&lt;br /&gt;
    }&lt;br /&gt;
    /** Sets the number of arrows. */&lt;br /&gt;
    public void setArrowCount(int arrowCount) {&lt;br /&gt;
        this.arrowCount = arrowCount;&lt;br /&gt;
    }&lt;br /&gt;
    /** Returns the arrow size. */&lt;br /&gt;
    public int getArrowSize() {&lt;br /&gt;
        return arrowSize;&lt;br /&gt;
    }&lt;br /&gt;
    /** Sets the arrow size. */&lt;br /&gt;
    public void setArrowSize(int arrowSize) {&lt;br /&gt;
        this.arrowSize = arrowSize;&lt;br /&gt;
    }&lt;br /&gt;
    public Dimension getPreferredSize() {&lt;br /&gt;
        return getMinimumSize();&lt;br /&gt;
    }&lt;br /&gt;
    public Dimension getMinimumSize() {&lt;br /&gt;
        return new Dimension(&lt;br /&gt;
                arrowSize * (direction == SwingConstants.EAST&lt;br /&gt;
                        || direction == SwingConstants.WEST ? arrowCount : 3)&lt;br /&gt;
                + getBorder().getBorderInsets(this).left&lt;br /&gt;
                + getBorder().getBorderInsets(this).right&lt;br /&gt;
                ,&lt;br /&gt;
                arrowSize * (direction == SwingConstants.NORTH&lt;br /&gt;
                        || direction == SwingConstants.SOUTH ? arrowCount : 3)&lt;br /&gt;
                + getBorder().getBorderInsets(this).top&lt;br /&gt;
                + getBorder().getBorderInsets(this).bottom&lt;br /&gt;
                );&lt;br /&gt;
    }&lt;br /&gt;
    public Dimension getMaximumSize() {&lt;br /&gt;
        return getMinimumSize();&lt;br /&gt;
    }&lt;br /&gt;
    protected void paintComponent(Graphics g) {&lt;br /&gt;
        // this will paint the background&lt;br /&gt;
        super.paintComponent(g);&lt;br /&gt;
        Color oldColor = g.getColor();&lt;br /&gt;
        g.setColor(isEnabled() ? getForeground() : getForeground().brighter());&lt;br /&gt;
        // paint the arrows&lt;br /&gt;
        int w = getSize().width;&lt;br /&gt;
        int h = getSize().height;&lt;br /&gt;
        for (int i = 0; i &amp;lt; arrowCount; i++) {&lt;br /&gt;
            paintArrow(g,&lt;br /&gt;
                    (w - arrowSize * (direction == SwingConstants.EAST&lt;br /&gt;
                            || direction == SwingConstants.WEST ? arrowCount : 1)) / 2&lt;br /&gt;
                            + arrowSize * (direction == SwingConstants.EAST&lt;br /&gt;
                            || direction == SwingConstants.WEST ? i : 0),&lt;br /&gt;
                    (h - arrowSize * (direction == SwingConstants.EAST&lt;br /&gt;
                            || direction == SwingConstants.WEST ? 1 : arrowCount)) / 2&lt;br /&gt;
                            + arrowSize * (direction == SwingConstants.EAST&lt;br /&gt;
                            || direction == SwingConstants.WEST ? 0 : i),&lt;br /&gt;
                            g.getColor());&lt;br /&gt;
        }&lt;br /&gt;
        g.setColor(oldColor);&lt;br /&gt;
    }&lt;br /&gt;
    private void paintArrow(Graphics g, int x, int y, Color highlight) {&lt;br /&gt;
        int mid, i, j;&lt;br /&gt;
        Color oldColor = g.getColor();&lt;br /&gt;
        boolean isEnabled = isEnabled();&lt;br /&gt;
        j = 0;&lt;br /&gt;
        arrowSize = Math.max(arrowSize, 2);&lt;br /&gt;
        mid = (arrowSize / 2) - 1;&lt;br /&gt;
        g.translate(x, y);&lt;br /&gt;
        switch (direction) {&lt;br /&gt;
            case NORTH:&lt;br /&gt;
                for (i = 0; i &amp;lt; arrowSize; i++) {&lt;br /&gt;
                    g.drawLine(mid - i, i, mid + i, i);&lt;br /&gt;
                }&lt;br /&gt;
                if(!isEnabled)  {&lt;br /&gt;
                    g.setColor(highlight);&lt;br /&gt;
                    g.drawLine(mid-i+2, i, mid+i, i);&lt;br /&gt;
                }&lt;br /&gt;
                break;&lt;br /&gt;
            case SOUTH:&lt;br /&gt;
                if (!isEnabled) {&lt;br /&gt;
                    g.translate(1, 1);&lt;br /&gt;
                    g.setColor(highlight);&lt;br /&gt;
                    for (i = arrowSize - 1; i &amp;gt;= 0; i--) {&lt;br /&gt;
                        g.drawLine(mid - i, j, mid + i, j);&lt;br /&gt;
                        j++;&lt;br /&gt;
                    }&lt;br /&gt;
                    g.translate(-1, -1);&lt;br /&gt;
                    g.setColor(oldColor);&lt;br /&gt;
                }&lt;br /&gt;
                j = 0;&lt;br /&gt;
                for (i = arrowSize - 1; i &amp;gt;= 0; i--) {&lt;br /&gt;
                    g.drawLine(mid - i, j, mid + i, j);&lt;br /&gt;
                    j++;&lt;br /&gt;
                }&lt;br /&gt;
                break;&lt;br /&gt;
            case WEST:&lt;br /&gt;
                for (i = 0; i &amp;lt; arrowSize; i++) {&lt;br /&gt;
                    g.drawLine(i, mid - i, i, mid + i);&lt;br /&gt;
                }&lt;br /&gt;
                if(!isEnabled)  {&lt;br /&gt;
                    g.setColor(highlight);&lt;br /&gt;
                    g.drawLine(i, mid-i+2, i, mid+i);&lt;br /&gt;
                }&lt;br /&gt;
                break;&lt;br /&gt;
            case EAST:&lt;br /&gt;
                if(!isEnabled)  {&lt;br /&gt;
                    g.translate(1, 1);&lt;br /&gt;
                    g.setColor(highlight);&lt;br /&gt;
                    for(i = arrowSize-1; i &amp;gt;= 0; i--)   {&lt;br /&gt;
                        g.drawLine(j, mid-i, j, mid+i);&lt;br /&gt;
                        j++;&lt;br /&gt;
                    }&lt;br /&gt;
                    g.translate(-1, -1);&lt;br /&gt;
                    g.setColor(oldColor);&lt;br /&gt;
                }&lt;br /&gt;
                j = 0;&lt;br /&gt;
                for (i = arrowSize - 1; i &amp;gt;= 0; i--) {&lt;br /&gt;
                    g.drawLine(j, mid - i, j, mid + i);&lt;br /&gt;
                    j++;&lt;br /&gt;
                }&lt;br /&gt;
                break;&lt;br /&gt;
        }&lt;br /&gt;
        g.translate(-x, -y);&lt;br /&gt;
        g.setColor(oldColor);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
			</entry>

	</feed>