473,382 Members | 1,647 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

JScrollPane error

It displays the information off the left of the screen instead of in a line. Any ideas?
I'll post the code here too. I know it returns nothing at the moment, it's a work in progress.

public String main(ArrayListSerial list) {
JScrollPane scroll = new JScrollPane();
int r = 0;
x=0;
while(r<list.size()){
JPanel panel = new JPanel();
panel.add(getSingle(list.get(r)));
scroll.add(panel);
r++;
}
Panel panel = new Panel();
panel.add(new Label("Enter a new item"));

scroll.add(panel);
add(scroll, "North");
Button exit = new Button("Exit");
add(exit, "South");
setSize(500, 500);
setVisible(true);
while(x==0){

}
return "003";
}

public Panel getSingle(item i){
Panel uber = new Panel();
Panel panel1 = new Panel();
Label name = new Label("Name: "+i.name);
panel1.setLayout(new BorderLayout());
panel1.add(name, "North");
Label price = new Label("Price: $"+i.price);
panel1.add(price, "Center");
Label year = new Label("Year: "+i.year);
panel1.add(year, "South");

uber.setLayout(new BorderLayout());
uber.add(panel1);


Panel panel2 = new Panel();
panel2.setLayout(new BorderLayout());
Label desc = new Label("Description: "+i.description);
panel2.add(desc, "Center");
Label picLabel = new Label("Picture: "+i.picture);
panel2.add(picLabel, "South");

uber.add(panel2);

return uber;
}
Mar 31 '08 #1
2 1403
To be more clear, some of the info is displayed off of the left side of the screen, and not starting at the left side like it would if I jsut put raw panels in.
Mar 31 '08 #2
Nevermind, I needed to make a new JViewport in order to fix this problem. No adding straight to JScrollPane
Mar 31 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: hiwa | last post by:
When we put a lengthy line-wrapped String in a not-so-large JTextArea which is enclosed in a JScrollPane, it automatically scrolls down to the end of the string. That is, the string is displayed...
1
by: 123456prakash | last post by:
Does anyone know if it is possible to set programmatically the position of a JScrollPane vertical scrollbar slider? I load a some components like textfield editorpane labels etc into a panel...
0
by: madumm | last post by:
Hi all; How can i set a Background Image to this JScrollPane? JLabel imageLabel; JScrollPane jsp = new JScrollPane(imageLabel); Pls need your sugessions... Thanking in advance Madumm
2
by: gmioannou | last post by:
hi, can i clone JScrollPane or JPanel and its components? many thanks George Ioannou
3
by: blackraven1425 | last post by:
I've been having trouble implementing a JScrollPane. Nothing shows up inside the JScrollPane but the other component (an exit button) shows up below it like it should. Can anyone help me resolve this...
1
TheMan1
by: TheMan1 | last post by:
Hi guys. I have a mouse event on my frame that enlarges the size of a JPanel that in on a JScrollPane. When the JPanel's size changes, the JScrollPane's scrollbars don't "refresh" ie. their max...
2
by: Gangreen | last post by:
I have a Jscrollpane, holding a Jpanel on which I draw. Now, I have made buttons to zoom in and out. They will simply change the value of variables that hold the size of my Jpanel and the drawing on...
4
by: chanshaw | last post by:
I'm trying to add a verticle scroll bar to my scrollPane so it can go up and down the list as needed what sort of lines do I need to add to get this to work. private void refreshScrollPane(int...
6
BSCode266
by: BSCode266 | last post by:
Hey everyone, I'll cut right to the case. I have a JPanel and i call setLayout(null) on it. Simply because I would like to position everything myself and haven't seen a handy manager yet. Now i...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.