Last active
August 29, 2015 14:00
-
-
Save ulmangt/11264961 to your computer and use it in GitHub Desktop.
JScrollPaneExample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.awt.Dimension; | |
| import java.lang.reflect.InvocationTargetException; | |
| import javax.swing.JFrame; | |
| import javax.swing.JScrollPane; | |
| import javax.swing.SwingUtilities; | |
| import com.jogamp.opengl.util.FPSAnimator; | |
| import com.metsci.glimpse.canvas.SwingLightweightGlimpseCanvas; | |
| import com.metsci.glimpse.examples.stacked.CollapsibleTimelinePlotExample; | |
| import com.metsci.glimpse.layout.GlimpseLayout; | |
| import com.metsci.glimpse.support.settings.SwingLookAndFeel; | |
| public class JScrollPaneExample | |
| { | |
| public static void main( String[] args ) throws InvocationTargetException, InterruptedException | |
| { | |
| /// boilerplate setup code /// | |
| final SwingLightweightGlimpseCanvas canvas = new SwingLightweightGlimpseCanvas( ); | |
| GlimpseLayout layout = new CollapsibleTimelinePlotExample( ).getLayout( ); | |
| canvas.addLayout( layout ); | |
| canvas.setLookAndFeel( new SwingLookAndFeel( ) ); | |
| new FPSAnimator( canvas.getGLDrawable( ), 120 ).start( ); | |
| final JFrame frame = new JFrame( "Glimpse Example" ); | |
| frame.setSize( 800, 800 ); | |
| frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); | |
| frame.setVisible( true ); | |
| SwingUtilities.invokeAndWait( new Runnable( ) | |
| { | |
| @Override | |
| public void run( ) | |
| { | |
| // set the preferred size of the canvas to larger than the size of the window | |
| canvas.setPreferredSize( new Dimension( 800, 1600 ) ); | |
| // add the GlimpseCanvas to the scroll pane | |
| JScrollPane scroll = new JScrollPane( canvas ); | |
| // add the scroll pane to the frame | |
| frame.add( scroll ); | |
| frame.validate( ); | |
| } | |
| } ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment