Package org.hxzon.netprotocol.ui.statistics

Source Code of org.hxzon.netprotocol.ui.statistics.StatisticsPanel

package org.hxzon.netprotocol.ui.statistics;

import java.awt.event.AdjustmentEvent;
import java.awt.event.AdjustmentListener;

import javax.swing.JPanel;
import javax.swing.JScrollPane;

import org.hxzon.swing.layout.simple.SimpleLayout;
import org.hxzon.swing.layout.simple.SimpleLayoutData;

public class StatisticsPanel extends JPanel {
    private static final long serialVersionUID = 1L;
    private final StatisticsPaintPanel paintPanel;
    private final StatisticsControlPanel controlPanel;

    public StatisticsPanel() {
        paintPanel = new StatisticsPaintPanel();
        //
        final JScrollPane jsp = new JScrollPane(paintPanel);
        jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
        jsp.getHorizontalScrollBar().addAdjustmentListener(new AdjustmentListener() {

            @Override
            public void adjustmentValueChanged(AdjustmentEvent e) {
//        if (!e.getValueIsAdjusting()) {
                paintPanel.setViewSize(jsp.getViewport().getViewRect());
//        }
            }
        });
        jsp.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() {

            @Override
            public void adjustmentValueChanged(AdjustmentEvent e) {
//        if (!e.getValueIsAdjusting()) {
                paintPanel.setViewSize(jsp.getViewport().getViewRect());
//        }
            }
        });
        setLayout(new SimpleLayout(true));
        add(jsp, SimpleLayoutData.fillPercent(100));
        controlPanel = new StatisticsControlPanel(paintPanel);
        add(controlPanel, SimpleLayoutData.fixedSize(110));
    }

}
TOP

Related Classes of org.hxzon.netprotocol.ui.statistics.StatisticsPanel

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.