Scrollable Label : Label « Swing JFC « Java

Java
1. 2D Graphics GUI
2. 3D
3. Advanced Graphics
4. Ant
5. Apache Common
6. Chart
7. Collections Data Structure
8. Database SQL JDBC
9. Design Pattern
10. Development Class
11. Email
12. Event
13. File Input Output
14. Game
15. Hibernate
16. J2EE
17. J2ME
18. JDK 6
19. JSP
20. JSTL
21. Language Basics
22. Network Protocol
23. PDF RTF
24. Regular Expressions
25. Security
26. Servlets
27. Spring
28. Swing Components
29. Swing JFC
30. SWT JFace Eclipse
31. Threads
32. Tiny Application
33. Velocity
34. Web Services SOA
35. XML
Microsoft Office Word 2007 Tutorial
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Java » Swing JFC » LabelScreenshots 
Scrollable Label
Scrollable Label



import java.awt.Dimension;
import java.awt.Rectangle;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.Scrollable;

public class ScrollableLabel extends JLabel implements Scrollable {
  public ScrollableLabel(ImageIcon i) {
    super(i);
  }

  public Dimension getPreferredScrollableViewportSize() {
    return getPreferredSize();
  }

  public int getScrollableBlockIncrement(Rectangle r, int orietation,
      int direction) {
    return 10;
  }

  public boolean getScrollableTracksViewportHeight() {
    return false;
  }

  public boolean getScrollableTracksViewportWidth() {
    return false;
  }

  public int getScrollableUnitIncrement(Rectangle r, int orientation,
      int direction) {
    return 10;
  }

  public static void main(String[] args) {
    JFrame f = new JFrame("JScrollPane Demo");

    ImageIcon ii = new ImageIcon("largeJava2sLogo.gif");
    JScrollPane jsp = new JScrollPane(new ScrollableLabel(ii));
    f.getContentPane().add(jsp);
    f.setSize(300250);
    f.setVisible(true);

  }

}

           
       
Related examples in the same category
1. Putting HTML text on Swing componentsPutting HTML text on Swing components
2. Shows how displayed Mnemonic and labelFor properties work togetherShows how displayed Mnemonic and labelFor properties work together
3. A quick application to show a simple JLabelA quick application to show a simple JLabel
4. A JLabel that uses inline HTML to format its textA JLabel that uses inline HTML to format its text
5. Variations on a text and icon labelVariations on a text and icon label
6. A simple demonstration of text alignment in JLabelsA simple demonstration of text alignment in JLabels
7. Label with Image Label with Image
8. Label with HTML SampleLabel with HTML Sample
9. Label Text PositionLabel Text Position
10. LabelFor DemoLabelFor Demo
11. Label with IconLabel with Icon
12. Active Label SampleActive Label Sample
13. Swing Label DemoSwing Label Demo
14. Label alignmentLabel alignment
15. HTML labelHTML label
16. Label background, icon, alignLabel background, icon, align
17. Grab and Drag image scroll labelGrab and Drag image scroll label
18. Animation label
19. Label with various effectsLabel with various effects
20. Label for Label for
21. LabelFocusSample: setLabelForLabelFocusSample: setLabelFor
w__w_w_.__java_2_s___.__c___o__m___ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.