• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Swing Problem

 
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need a small solution or clue for my current project. If you have any idea pls share with me.

I included a JPanel (which has some graph) in to JScrollPane, and it doesn't display the scrollbars. Why? Can you tell me what could be the reason?

Can we add a container(for ex. JPanel) into JScrollPane?

regards
Sreenivas
 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
small solution AND clue:

http://java.sun.com/docs/books/tutorial/uiswing/components/scrollpane.html
 
Sree Nivas
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's the code. Anything wrong in this code?

import java.awt.*;
import javax.swing.*;

public class Test2 extends JFrame{
public Test2() {
JInternalFrame jInternalFrame = new JInternalFrame("Test",true,true,true,true);
JPanel jPanel = new PanelTest();
JScrollPane jScrollPane = new JScrollPane(jPanel,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
jInternalFrame.getContentPane().add(jScrollPane);
getContentPane().add(jInternalFrame);
jInternalFrame.setVisible(true);
setSize(600,600);
setVisible(true);
}

public static void main(String[] args) {
new Test2();
}
}

class PanelTest extends JPanel {

public PanelTest(){}

public void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawString("Main Time(us)",30,99);

g.drawString(Integer.toString(1),200,100);
g.drawString(Integer.toString(2),300,100);
g.drawString(Integer.toString(3),400,100);
g.drawString(Integer.toString(4),500,100);
g.drawString(Integer.toString(5),700,100);
g.drawString(Integer.toString(6),900,100);
g.drawString(Integer.toString(7),1000,100);
g.drawString(Integer.toString(8),1100,100);
g.drawLine(100,100,100,900);


}

}
reply
    Bookmark Topic Watch Topic
  • New Topic