JScrollPane Doesn;t appear in JScrollPane?

hi Following is the code of JPanel that contains JScrollPane.
And JScrollPane adds again CompareView Panel
CompareViewPanel is using custom defined Layout CompareViewLayout .
But this as a output this panel is not showing the proper JScrollPane when outer frame size is lesser then the current panel(which contains JScrollPane).
public class GalleryViewRightPanel extends JPanel {
* Layout Manager
private List <CapturedScreenControl> students;
* Scroll Container.
private final JScrollPane compareScrollPane;
private final CompareView screenCtlContainerPanel;
public GalleryViewRightPanel(List <CapturedScreenControl> students)
//TODO - Add in super() Your Own Made Layout that will take care
// of all the selected elements.
//super();
final int unitIncr = 96;
final int blockIncr = 192;
this.students = students;
this.screenCtlContainerPanel = new CompareView(new CompareViewLayout());
this.screenCtlContainerPanel.addComponentArray(this.students);
compareScrollPane = new JScrollPane(screenCtlContainerPanel,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
compareScrollPane.getVerticalScrollBar().setUnitIncrement(unitIncr);
compareScrollPane.getVerticalScrollBar().setBlockIncrement(blockIncr);
compareScrollPane.getHorizontalScrollBar().setUnitIncrement(unitIncr);
compareScrollPane.getHorizontalScrollBar().setBlockIncrement(blockIncr);
//setSize(compareScrollPane.getPreferredSize());
add(compareScrollPane,BorderLayout.CENTER);
setBorder(BorderFactory.createLineBorder(new Color(0,0,255,2)));
public List<CapturedScreenControl> getStudentList()
return students;
public void setStudentList(final List<CapturedScreenControl> screenControl)
students = screenControl;
screenCtlContainerPanel.addComponentArray(students);
//setSize(compareScrollPane.getPreferredSize());
public void SetInfo()
class CompareView extends JPanel
public CompareView(LayoutManager layout)
super(layout);
public void addComponentArray(List <CapturedScreenControl> screens)
removeComponentList();
//Add Here All Components.
for(CapturedScreenControl s: screens)
//add(s);
Rectangle rect = s.getBounds();
add(new CompareImage(null,null,false,false,rect));
updateUI();
public void singleComponentArray(CapturedScreenControl screen)
//removeComponentList();
//Add here this screen component.
//if(screen != null)
// add(screen);
public void removeComponentList()
removeAll();
class CompareViewLayout implements LayoutManager
private int leftGap,topGap,middleGap,rightGap,bottomGap;
* @param left : Left Gap before arranging Components.
* @param top : Top Gap before arranging Components.
* @param middle : Middle Gap between Components.
* @param right : Right Gap before arranging Components.
* @param bottom : Bottom Gap before arranging Components.
public void setGaps(int left,int top,int middle, int right,int bottom)
this.leftGap = left;
this.topGap = top;
this.middleGap = middle;
this.rightGap = right;
this.bottomGap = bottom;
@Override
public void addLayoutComponent(String name, Component comp)
// TODO Auto-generated method stub
// No need.
@Override
public void layoutContainer(Container parent)
Dimension max = calculateSize(parent);
Dimension size = parent.getSize();
int compCount = parent.getComponentCount();
if ((max.width == 0) || (max.height == 0)) {
return;
int rowCount = compCount/ScreenCaptureConstant.GALLERY_TWO_COMPONENT_SCREEN;
int colCount = 1;
if(rowCount == 0)
rowCount = 1;
if(compCount > ScreenCaptureConstant.GALLERY_MIN_COMPONENT_SCREEN)
colCount = ScreenCaptureConstant.GALLERY_TWO_COMPONENT_SCREEN;
int x = leftGap;
int y = topGap;
int row = 0;
int col = 0;
for(int count=0;count<compCount;count++)
//Here Set XY-position and Size for all the controls.
Component c = parent.getComponent(count);
c.setLocation(x, y);
c.setSize(max);
col++;
if(col >= colCount)
col = 0;
row++;
//Set here other Controls.
x = (col * (max.width + leftGap)) + middleGap;
y = (row * (max.height + topGap)) + middleGap;
@Override
public Dimension minimumLayoutSize(Container parent)
Dimension componentDim = new Dimension(0,0);
int componentCount = parent.getComponentCount();
//Only one component.
if(componentCount == ScreenCaptureConstant.GALLERY_MIN_COMPONENT_SCREEN)
//Considering that device types are of NSpire Device.
componentDim.height = ScreenCaptureConstant.SINGLE_NSPIRE_COMONENT_HEIGHT + topGap + bottomGap;
componentDim.width = ScreenCaptureConstant.SINGLE_NSPIRE_COMPONENT_WIDTH + leftGap + rightGap;
//Two Components.
else if(componentCount == ScreenCaptureConstant.GALLERY_TWO_COMPONENT_SCREEN)
componentDim.height = ScreenCaptureConstant.MULTIPLE_NSPIRE_COMONENT_HEIGHT + topGap + bottomGap;
componentDim.width = (2*ScreenCaptureConstant.MULTIPLE_NSPIRE_COMPONENT_WIDTH) + leftGap + rightGap + middleGap;
//More than Two Components.
else if(componentCount > ScreenCaptureConstant.GALLERY_TWO_COMPONENT_SCREEN &&
componentCount <= ScreenCaptureConstant.GALLERY_MAX_COMPONENT_SCREEN )
componentDim.height = (2*ScreenCaptureConstant.MULTIPLE_NSPIRE_COMONENT_HEIGHT) + topGap + bottomGap + middleGap;
componentDim.width = (2*ScreenCaptureConstant.MULTIPLE_NSPIRE_COMPONENT_WIDTH) + leftGap + rightGap + middleGap;
return componentDim;
@Override
public Dimension preferredLayoutSize(Container parent)
Dimension singleScreenSize = calculateSize(parent);
int cnt = parent.getComponentCount();
if(cnt <= 0)
return new Dimension();
int cols = 1;
if(cnt > ScreenCaptureConstant.GALLERY_MIN_COMPONENT_SCREEN)
cols = ScreenCaptureConstant.GALLERY_MAX_COMPONENT_SCREEN;
int rows = cnt / cols;
if (cnt == 0)
return new Dimension();
else
Dimension ret = new Dimension(singleScreenSize);
ret.width = cols*(ret.width) + leftGap + rightGap + (cols-1)*middleGap;
ret.height = rows*(ret.height) + topGap + bottomGap + (rows-1)*middleGap;
return ret;
@Override
public void removeLayoutComponent(Component comp)
// TODO Auto-generated method stub
* @return
private Dimension getBestFitSize(Dimension crntSize,Dimension maxsize,int nDeviceType)
//Calculate here best fit.
//This will say the best size of the component.
int minWidth = crntSize.width;
int minHeight = crntSize.height;
while(minWidth+4<=maxsize.width && minHeight+3<=maxsize.height)
minWidth = minWidth + 4;
minHeight = minHeight + 3;
return new Dimension(minWidth,minHeight);
* @param parent : Calculate Each Component Size.
* @return
private Dimension calculateSize(Container parent)
int componentCount = parent.getComponentCount();
Dimension parSize = parent.getSize();
Dimension comSize = new Dimension();
if(componentCount == ScreenCaptureConstant.GALLERY_MIN_COMPONENT_SCREEN)
//Logic to get the zoom
//Only For NSpire Device.
comSize.height = ScreenCaptureConstant.SINGLE_NSPIRE_COMONENT_HEIGHT;
comSize.width = ScreenCaptureConstant.SINGLE_NSPIRE_COMPONENT_WIDTH;
parSize.width -= (leftGap + rightGap);
if((parSize.width > comSize.width) &&
(parSize.height > comSize.height))
//Here We Get the size for the One Image.
return getBestFitSize(comSize,parSize,0);
else if(componentCount > ScreenCaptureConstant.GALLERY_MIN_COMPONENT_SCREEN)
//Only Considering for NSpire Devices.
comSize.height = ScreenCaptureConstant.MULTIPLE_NSPIRE_COMONENT_HEIGHT + middleGap;
comSize.width = ScreenCaptureConstant.MULTIPLE_NSPIRE_COMPONENT_WIDTH + middleGap;
//Logic to get the zoom for multiple screens.
parSize.width -= (leftGap + rightGap + middleGap);
parSize.width = parSize.width/2 ;
//Calculate Here the Size of Each Component.
return new Dimension(parSize.width,getHeightFromWidth(parSize.width,0));
return comSize;
private int getHeightFromWidth(int nWidth,int nDeviceType)
int nHeight = (nWidth*3)/4;
return nHeight;
class CompareImage extends Component {
private static final Logger log = Logger.getLogger("gui.capturedScreen.CompareImageComponent");
private Image lastGoodScreenImage;
private Image screenImage;
private boolean loaded;
private boolean hasErrored;
private Rectangle rect;
* @param lastGoodImage
* @param screenImage
* @param loaded
* @param error
* @param rect
public CompareImage(Image lastGoodImage,Image screenImage,boolean loaded, boolean error,Rectangle rect)
super();
this.lastGoodScreenImage = lastGoodImage;
this.screenImage = screenImage;
this.loaded = loaded;
this.hasErrored = error;
this.rect = rect;
public synchronized void paint(Graphics g)
String msg = "Image is Coming soon..." + rect.x + "," + rect.y + "," + rect.width + "," + rect.height;
g.drawString(msg, 20, 20);
Please help me to identify why this is not working??
Thank you.
Ajit.

Hi,
I Had created "class CompareViewLayout implements LayoutManager".
Now you can see its implementation in code. This CompareViewLayout is used in CompareView Panel.
And In compareScrollPane (JScrollPane) takes CompareView Panel as an argument in constructor.
And compareScrollPane is added in Container(Top Level Panel) class.
Now here,
Whenever preferredLayoutSize() function of the LayoutManager is called, that will set the Components.
But this functions is several time not called on resize of the frame..... normally this function called on each resize operation.
In short Anyone Having idea what are the cases when preferredLayoutSize() function of the LayoutManager is not called ??
And what to take care to avoid it??

Similar Messages

  • JTable in JScrollpane doesn't appear

    Hi,
    Maybe, it's already asked 1000 times on this forum but I didn't found the right solution.
    My problem :
    I've created a JPanel with a JScrollpane.
    When I create the JScrollpane immediately with a JTable it works fine, the JTable appears.
    Now I try to add the JTable dynamically to the JScrollpane.
    The JTable doesn't appear.
    I've tried already the repaint, validate methods but that changes nothing.
    Can anyone tell me how I can solve my problem ?
    Thanx in advance,
    Piet

    I trust you are adding it like this:
    myJScrollPane.getViewport().add(myJTable);
    not like this:
    myJScrollPane.add(myJTable);

  • JScrollPane doesn't think

    Hi,
    I am trying to display a histogram on a JPanel and place that on a JScrollPane.
    My problem is that the JScrollPane doesn't seem to think it is needed when it is. I have not set any sizes and the histogram(Graphics 2D) is not being fully shown in my Frame and no scrollBars are appearing.
    Anybody know a solution to this?
    Thanks in advance,
    L.

    Don't make multiple posts.
    I've already answered to your question in your previous post.
    http://forum.java.sun.com/thread.jsp?forum=57&thread=352148&tstart=0&trange=30
    Denis

  • After upgrading to IOS5, iphone doesn't appear on Itunes, and i cann't transfer pjhotos on iphoto, .., after upgrading to IOS5, iphone doesn't appear on Itunes, and i cann't transfer pjhotos on iphoto, ..

    after upgrading my iphone 4 to IOS5, it doesn't appear on "Itunes", and also i cann't transfer photos on "iphoto", .., so i cant load, save or erased anything now! 

    They are now in the videos app!

  • After I reset my Ipod (deleted all data and settings) windows 7 doesn't recognize by ipod touch, and it doesn't appear in the itunes library or in the device menu, but it does charge. How can I get my computer to recognize it again?

    After I reset my Ipod (deleted all data and settings) windows 7 doesn't recognize by ipod touch, and it doesn't appear in the itunes library or in the device menu, but it does charge. How can I get my computer to recognize it again?

    Refer to this article:
    iOS: Device not recognized in iTunes for Windows
    http://support.apple.com/kb/TS1538

  • HT1382 i got an iPad and all my app's, music,  and movies are on it, but when i try to download some apps to mi iPhone, they doesn't appear on the purchased tab, how could i move them back to itunes so i can access thru iCloud?

    i got an iPad and all my app's, music,  and movies are on it, but when i try to download some apps to mi iPhone, they doesn't appear on the purchased tab, how could i move them back to itunes so i can access thru iCloud? i have an 2nd generetion ipad and an iphone 5, thanks for you answers!

    (I think the daughter got he better end of the deal!)   I believe if you change the password and user id one of the devices it will stop that from occurring. But I'm not the one to tell you how to do it; someone like "Illaass" (Illaass seems to know how to correct / fix almost anything!) will know how if you don't. Just look for the "cat" icon.

  • Can't delete file from desktop. Can't get info. Doesn't appear in ls -a. What?

    Hi folks,
    I file has appeared on my desktop. I believe it's a temp file created while downloading something in Safari. When I try to delete it, I get "The item x can't be moved to the trash because it can't be deleted":
    I tried right click > Get Info, and nothing happens (the info dialog does not appear).
    I tried ls -al on my desktop, and the file doesn't appear in the list:
    How do I get rid of this thing? What is it?

    Weird. I guess if this were happening to me, I would see if the thing is still there after a reboot. If it is still there, I would boot with command-R and use Disk Utility to verify and repair the disk (not permissions).
    The file name indicates you were downloading something to run under windows. Do you have windows?
    charlie

  • If i selected to "Create a new backup" and then cancelled that option but want to go back and select "Inherit backup history"; how do i go back and do that since now when i plug in my HD, that option doesn't appear anymore?? Any Help?

    If i selected to "Create a new backup" and then canceled that option but want to go back and select "Inherit backup history"; how do I go back and do that since now when I plug in my external hard drive, that option doesn't appear anymore?? Any Help? I bought a MacBook Air, but decided to return it for the newest model, and I wanted to back it up so that I can then back it up on my new MacBook Air. I didn't understand the option to Inherit or start a new back up, and therefore selected the option to create a new backup. I believe I should have selected to Inherit backup history so that when i back it up on the new MackBook Air, it appears the same as the one I'm returning.... Is there anyway that i can re-select the option to Inherit backup history for time machine?

    Thanks for sharing this link.
    I've posted a question here https://discussions.apple.com/message/22049103#22049103 describing my situation. Are you able to suggest me the right option?

  • Save/open dialog box doesn't appear

    Hi,
    I have something strange. I can open and edit a project by double clicking on it, also start a new project. But when I want to save or open a project via "save as" of "open project" the dialog box doesn't appear. Saving an existing file trough "ctrl+s" works.
    Things I tried already are:
    - Restart my computer (windows)
    - Clear my AE cache
    - Reinstal AE
    Has anyone has this before? It would be great if it got solved because I can't complete work because of it.
    Tnx & grtz,

    Sorry, here the information that is required:
    Version 11.0.4.2 - CS6
    Installed recent updates: Yes
    OS: Windows 7 Pro (Service pack 1) 64 bit
    Model: HP Z420 Workstation
    Processor: Intel Xeon CPU E5-1620 @3.60Ghz
    Ram: 8Gb
    Has it worked before: yes. It started after I opened a project (trough "open project") because double clicking on this project gives the follwoing error: "The directory name is invalid". Via "Open project" I could open it.
    Do you have any third-party I/O hardware (e.g., AJA, Matrox, Blackmagic, MOTU)? No
    Quicktime 7 pro installed
    Do you have any third-party effects or codecs installed? Yes, Optical Flares & Trapcode. But is unrelated since it isn't a specific project.
    Are you using Render Multiple Frames Simultaneously multiprocessing? Yes
    Are you using the ray-traced 3D renderer? No
    Thanks for the help. If you need any other info, let me know

  • In Mail, Reply To and Subject area doesn't appear

    In Mail, Reply To and Subject area doesn't appear on an opened email.

    Hi
    Go to Mail / Preferences
    on the Viewing tab - Show header detail  - drop down box
    Select whatever suits you. - try default
    /Dennis

  • Pages 5.5: app doesn't appear in dock or tab bar when open

    We are seeing this issue on the two macs in our office we tested (mine and a coworkers). To reproduce it:
    Open pages
    Click "Done" on the open/new document window (or simply close all documents you have open)
    Click the desktop to send Pages to the background
    If you Cmd+Tab, Pages doesn't appear for us. It also doesn't appear in the dock. Activity Monitor shows the app is still running and using spotlight to "open" it again brings it back to the foreground.
    Is anyone else having this same problem?
    Pages 5.5 2109
    Yosemite 10.10
    MBP 13", 2.66 GHz Intel Core 2 Duo
    8 GB RAM
    256 GB SSD

    Newly downloaded apps will appear in the column on the left. The images on the right show what is installed on the device. Perphaps the logic has changed slightly with older builds also including what would be synced as well. Untick the box that says Automatically sync new apps and you can choose whether or not to include a new app instead of syncing, then removing.
    tt2

  • Report parameters doesn't appear correctly

    I have a report .rdl under Visual Studio2010 and sql server2008.
    the report language is arabic and all the fields appears correctly, but the parameters doesn't appear correct it shows stange characers(not question marks) and all the remaining fields show arabic characters correct.
    i run the report on internet explorer9.
    i don't know what is the problem, i searched alot and there is nothing new. what can i do??

    Hi nermo,
    You have mentioned that the report is work fine on Chrome. It may be a compatibility issue of IE9. At this time, I suggest that you first check this issue in IE9 Compatibility View mode. Please refer to the following steps:
    1. Launch the IE 9, and press Alt+T to select the Tools.
    2. Click Compatibility View settings.
    3. Check the “Display intranet sites in Compatibility View” option, and click Close.
    Reference:
    Fix site display problems with Compatibility View 
    Regards,
    Alisa Tang
    Alisa Tang
    TechNet Community Support

  • Trying to limit number of emails showing but when I go to "mail, contacts, calendars", "show" doesn't appear as an option.  What now?

    Suddenly I have over 300 emails appearing on my ipad2.  I know you are supposed to be able to change that by going to "Mail, Contacts, Calendars", then select "Show".  Well, when I do that, "Show" doesn't appear as an option.  Any thoughts on how I get "Show" back?

    Tap the blue + sign in the upper right corner of the Safari toolbar to open a new tab. Then look in the lower left portion of the screen for the word "Private". Tap that to turn off private browsing.

  • I am using Numbers app for the ipad and it has been working absolutely fine but now, when I want to email a spreadsheet as a PDF via the 'share and print' option, the file now doesn't appear as an attachment to the recipient. Any ideas please?

    I am using Numbers app for the ipad and it has been working absolutely fine but now, when I want to email a spreadsheet as a PDF via the 'share and print' option, the file now doesn't appear as an attachment to the recipient. Any ideas please?

    Hi mafiose15,
    Thanks for visiting Apple Support Communities.
    Restoring your iPod to factory settings is the best way to try and get it back to working order. You can use the instructions below to restore it:
    How to restore iPod
    Verify that you have an active Internet connection, because you may need to download new versions of the iTunes and iPod Software.
    Download and install the latest version of iTunes if necessary.
    Open iTunes. Connect your iPod to your computer using the USB or FireWire cable that came with your iPod.
    After a few moments, your iPod will appear in the Source panel in iTunes.
    Select your iPod in the Source panel. You will see information about your iPod appear in the Summary tab of the main iTunes window.
    Click Restore.
    If you are using a Mac, you will be asked to enter an administrator’s name and password.
    A progress bar will appear on the computer screen, indicating that stage one of the restore process has begun. When this stage is done, iTunes will present one of two messages with instructions specific to the iPod model you are restoring.
    Disconnect iPod and connect it to iPod Power Adapter (typically applies to older iPod models).
    Leave iPod connected to computer to complete restore (typically applies newer iPod models).
    During stage two of the restore process, the iPod displays an Apple logo as well as a progress bar at the bottom of the display. It is critical that the iPod remain connected to the computer or iPod power adapter during this stage.
    Note: The progress bar may be difficult to see, because the backlight on the iPod display may be off.
    After stage two of the restore process is complete, the iTunes Setup Assistant window will appear. It will ask you to name your iPod and choose your syncing preferences, as it did when you connected your iPod for the first time.
    You can find the instructions in this article:
    Restoring iPod to factory settings
    http://support.apple.com/kb/ht1339
    All the best,
    Jeremy

  • I open a file - playback - the audio is there - doesn't appear in timeline, but I hear it, after 1 edit, the audio disappears.  I have to reboot to get it back then it happens again.  All suggeswtions welcome.  Thank you, Randy

    I open a file - playback - the audio is there - doesn't appear in timeline, but I hear it, after 1 edit, the audio disappears.  I have to reboot to get it back then it happens again.  All suggeswtions welcome.  Thank you, Randy

    Is your Premiere Elements 12/12.1 running on a Windows 7, 8, or 8.1 64 bit computer or a Mac computer?
    What is the brand/model/settings of the camera recording your video?
    Windows 7 64 bit PC 
    Footage taken from DVD through Adobe Premiere Elements
    Are you sure about the Frame Width and Frame Height that you gave 720 x 484? Did you mean 720 x 480?
    Yes, my err.  720X480
    For the Frame Rate, was it really 29.97 frames per second and you rounded it off to 29 frames per second? Or,
    is the frame rate really 29 frames per second?
    If the properties that you just posted are representative of your source file, what project preset did you or the
    project set for the project preset? If you are not sure, please tell us the readings for Editing Mode, Timebase, Frame Size,
    and Pixel Aspect Ratio under Edit Menu/Project Settings/General.
    Still having problems - haven't been able to edit project. 
    Thank you for your help.
    Randy Klein

Maybe you are looking for