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 vertical and horizontal {@link Scrollbar}s to 014 the right and bottom edges of an {@link InteractiveFrame} window. 015*/ 016@SuppressWarnings("serial") 017public class InteractiveFrame_HV extends InteractiveFrame 018{ 019 public Scrollbar sbV; 020 public Scrollbar sbH; 021 022 /** 023 Add vertical and horizontal {@link Scrollbar}s to the right 024 and bottom edges of an {@link InteractiveFrame} window. Use 025 the {@link Scrollbar}'s {@link AdjustmentEvent}s to update 026 a {@link renderer.scene.Scene} 027 028 @param title title for the {@link javax.swing.JFrame} window 029 @param fbWidth width for the initial {@link FrameBuffer} used by this {@link javax.swing.JFrame} 030 @param fbHeight height for the initial {@link FrameBuffer} used by this {@link javax.swing.JFrame} 031 */ 032 public InteractiveFrame_HV(String title, int fbWidth, int fbHeight) 033 { 034 super(title, fbWidth, fbHeight); 035 036 // Create Scrollbars for this JFrame. 037 sbV = new Scrollbar(Scrollbar.VERTICAL, 50, 2, 0, 100); 038 sbH = new Scrollbar(Scrollbar.HORIZONTAL, 50, 2, 0, 100); 039 // Place the Scrollbars in this JFrame. 040 this.getContentPane().add(sbV, BorderLayout.EAST ); 041 this.getContentPane().add(sbH, BorderLayout.SOUTH ); 042 this.pack(); 043 this.setVisible(true); 044 045 // Make this object the event listener for the scrollbar events. 046 sbV.addAdjustmentListener(this); 047 sbH.addAdjustmentListener(this); 048 } 049 050 051 /** 052 Implement the {@link java.awt.event.AdjustmentListener} interface for the {@link Scrollbar}s. 053 <p> 054 Override this method to specify how an application updates its 055 {@link renderer.scene.Scene} object in response to the firing 056 of an {@link AdjustmentEvent} from one of the {@link Scrollbar}s. 057 058 @param e {@link AdjustmentEvent} from either of this application's {@link Scrollbar}s 059 */ 060 @Override public void adjustmentValueChanged(AdjustmentEvent e) 061 { 062 System.out.println(e); 063 } 064}