001/* 002 003*/ 004 005package renderer.gui; 006import renderer.framebuffer.FrameBuffer; 007 008import java.awt.event.AdjustmentEvent; 009import java.awt.Scrollbar; 010import java.awt.BorderLayout; 011 012/** 013 This class adds a vertical {@link Scrollbar} to the right edge 014 of an {@link InteractiveFrame} window. 015*/ 016@SuppressWarnings("serial") 017public class InteractiveFrame_V extends InteractiveFrame 018{ 019 public Scrollbar sb; 020 021 /** 022 Add a vertical {@link Scrollbar} to the right edge of an 023 {@link InteractiveFrame} window. Use the {@link Scrollbar}'s 024 {@link AdjustmentEvent}s to update a {@link renderer.scene.Scene} 025 026 @param title title for the {@link javax.swing.JFrame} window 027 @param fbWidth width for the initial {@link FrameBuffer} used by this {@link javax.swing.JFrame} 028 @param fbHeight height for the initial {@link FrameBuffer} used by this {@link javax.swing.JFrame} 029 */ 030 public InteractiveFrame_V(String title, int fbWidth, int fbHeight) 031 { 032 super(title, fbWidth, fbHeight); 033 034 // Create a Scrollbar for this JFrame. 035 sb = new Scrollbar(Scrollbar.VERTICAL, 50, 2, 0, 100); 036 // Place the Scrollbar in this JFrame. 037 this.getContentPane().add(sb, BorderLayout.EAST ); 038 this.pack(); 039 this.setVisible(true); 040 041 // Make this object the event listener for the scrollbar's events. 042 sb.addAdjustmentListener(this); 043 } 044 045 046 /** 047 Implement the {@link java.awt.event.AdjustmentListener} interface for the {@link Scrollbar}. 048 <p> 049 Override this method to specify how an application updates its 050 {@link renderer.scene.Scene} object in response to the firing 051 of an {@link AdjustmentEvent} from the {@link Scrollbar}. 052 053 @param e {@link AdjustmentEvent} from this application's {@link Scrollbar} 054 */ 055 @Override public void adjustmentValueChanged(AdjustmentEvent e) 056 { 057 System.out.println(e); 058 } 059}