Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

JScrollPane and FlowLayout

Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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())
JScrollPane scrollpaneExercise = new JScrollPane(MyJPanel);
getContentPane().add(BorderLayout.CENTER, scrollpaneExercise);
Posts: 9615
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Try GridLayout, BoxLayout or GridBagLayout
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic