PDA

View Full Version : Jscroll pane....



andrewking
April 26th, 2007, 05:38 AM
Hi,

I am Andrews, I want to include my JPanel with a null layout in a JScrollPane, and it doesn't display the scrollbars. Why? If any one know about this reply me

Thanks in advance

Voetsjoeba
April 26th, 2007, 08:33 AM
I'm guessing it's because the way JScrollPane "knows" how big its content is is by asking its layout manager for getPreferredSize(). But since you have no layout, the scrollpane won't display the bars as it thinks its content has no size. So try doing a panel.setPreferredSize( new Dimension( yourwidth , yourheight ) ) before you add the panel to the ScrollPane.

andrewking
May 14th, 2007, 11:21 AM
Thanks for your reply,
I have another question can you tell me the difference between endl and '\n' and why I cant convert ** to a const char ** and * to a const char *&? If you know about this reply me

Voetsjoeba
May 14th, 2007, 01:15 PM
Are we still talking Java here ? It sounds to me like you're talking about C++.

andrewking
June 13th, 2007, 10:48 AM
ya iam talking about c++

taron
June 27th, 2007, 05:43 PM
Thanks for your reply,
I have another question can you tell me the difference between endl and '\n' and why I cant convert ** to a const char ** and * to a const char *&? If you know about this reply me
\n starts a newline and clears some kind of a buffer, and endl does the same except it doesn't clear that buffer.
If you try to display something to the screen it doesn't matter what you use, if you are writing something in a file and you want to start a newline, do not use \n, it will erase the full file, but endl doesn't, that's the difference.
so:
#include <fstream>
#include <iostream>
using namespace std;
int main(){
ofstream file("newfile.txt");
file << "test \n";
file << "test2";
return 0;
}
would create a file with "test2" in it.
but:
#include <fstream>
#include <iostream>
using namespace std;
int main(){
ofstream file("newfile.txt");
file << "test " << endl;
file << "test2";
return 0;
}
would create a file with:
"test
test2"
in it.

andrewking
August 14th, 2007, 04:39 AM
Hi,taron thanks for your info...