• 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

JScrollPane and FlowLayout

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
Is there a posibility to use the FlowLayout and JScrollPane in one JFrame/JApplet? My Problem is that I hava a text splitted in many JLabels and want to show this text in an Applet with the help of the FlowLayout. But I need a vertical srollbar, if the text is too long. But when I add the JPanel with the FlowLayout to the Applet, the hole text is shown in one line without a line break. Here a part of the code:
...
JPanel MyJPanel=new JPanel(new FlowLayout(FlowLayout.LEFT,4,4));
...
Iterator it=labelList.iterator();
while (it.hasNext())
MyJPanel.add((Component)it.next());
...
JScrollPane scrollpaneExercise = new JScrollPane(MyJPanel);
getContentPane().add(BorderLayout.CENTER, scrollpaneExercise);
...
Nick
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It sounds like you are expecting FlowLayout to insert line breaks into your series of JLabels if they flow over the JApplet/JFrame side. An't gonna happen. FlowLayout goes from left to right (or from right to left in appropriate locales) in a single row.
 
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try GridLayout, BoxLayout or GridBagLayout
 
reply
    Bookmark Topic Watch Topic
  • New Topic