Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (516)
Games in Android Showcase (123)
games submitted by our members
Games in WIP (577)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  JPanel - JList -> JScrollPane  (Read 1571 times)
0 Members and 1 Guest are viewing this topic.
Offline Phibedy

Senior Duke


Medals: 9



« Posted 2012-06-22 23:33:09 »

Hi,
we got a list, that is to big, to be shown at once. That´s why we would like to replace it with a ScrollPane, but the ScrollPane never appears.
Could it be, that it isn´t possible use "this.setLayout(null);" in the construktor, some say, that I have to usw a Layout Manager, is that true?
best regards Phibedy
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #1 - Posted 2012-06-22 23:43:28 »

You're right you can't do that. Just don't call setLayout() at all and it will use the default of a FlowLayout.

See my work:
OTC Software
Offline ReBirth
« Reply #2 - Posted 2012-06-23 08:39:31 »

By never appears, you mean the scroll bar? update the policies for both horizontal and vertical bars.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Phibedy

Senior Duke


Medals: 9



« Reply #3 - Posted 2012-06-23 08:48:23 »

thx for for answers Smiley
@ Eli Delventhal: If I remove "setLayout" the buttons are centered on the top of the Jpanel  Huh
If I dont use Layout.set(null), what else should I do, to be able to set buttons on coordinates?

@ ReBirth: Yes I mean the scrollbar.
Offline ReBirth
« Reply #4 - Posted 2012-06-23 09:01:45 »

1  
scroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

"scroller" is JScrollPane. You can set it to alwasy show.

Offline Phibedy

Senior Duke


Medals: 9



« Reply #5 - Posted 2012-06-23 09:24:11 »

Thx, works great  Grin

But I got another problem:

1  
2  
3  
4  
5  
6  
public static Icon getIcon(String path) {
      Icon icon = null;
      icon = new ImageIcon(path);
      System.out.println(path);
      return icon;
   }

At first, I call the method getIcon, after that, I replace the Icon in the directory and call the method again, but it always returns the old Icon not the one that I pasted.
If I don´t call it at first and replace the Icon in the directory and then call the method, it returns the new Icon that I pasted.
best regards Phibedy
Offline CaptainJester

JGO Knight


Medals: 12
Projects: 2
Exp: 14 years


Make it work; make it better.


« Reply #6 - Posted 2012-06-23 11:20:13 »

You have to call invalidate() on your JFrame. The docs say to call validate() but it never works for me.

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

TehJavaDev (32 views)
2014-10-27 03:28:38

TehJavaDev (26 views)
2014-10-27 03:27:51

DarkCart (41 views)
2014-10-26 19:37:11

Luminem (22 views)
2014-10-26 10:17:50

Luminem (27 views)
2014-10-26 10:14:04

theagentd (33 views)
2014-10-25 15:46:29

Longarmx (61 views)
2014-10-17 03:59:02

Norakomi (58 views)
2014-10-16 15:22:06

Norakomi (47 views)
2014-10-16 15:20:20

lcass (43 views)
2014-10-15 16:18:58
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!