Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Why can't i control location of label?

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have background picture and a label that is suppose to go on top of it but i can't seem to control it's location.

Setting the location seems to have no effect. I tried increasing the numbers but the textLabel won't budge. It's not exactly at (0,0) of the panel.
It is actual 1/4 to the right and less than 1 row down.

 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to read the Sun tutorials on the layout managers to understand what is happening and why. For one, the container you are placing your label in is using a layout manager, possibly FlowLayout as a default layout, and so setLocation won't work. setLocation works when using a null layout, but having said that I don't recommend that you use this, but instead learn to use and nest the various layout managers.

I will request that the mods move this question to the Swing forum.

Best of luck!
 
Bartender
Posts: 11445
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Agree with Pete.
Moving.
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
all you seem to be doing is copying working code (latest from this forums FAQ),
adding stuff, then posting it here with a 'this doesn't work'.

the changes you make indicate very little understanding of the basics of swing,
so I'd suggest you start the tutorials earlier than the layout managers.
 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ana,
I have a great LINK to learn java swing... It show you how to use layout manager and etc..
Just sit back, make some coffee (java coffee ) and check out the link..Have a nice study..

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ana Suvari wrote:I have background picture and a label that is suppose to go on top of it but i can't seem to control it's location.

Setting the location seems to have no effect. I tried increasing the numbers but the textLabel won't budge. It's not exactly at (0,0) of the panel.
It is actual 1/4 to the right and less than 1 row down.




This is a good candidate for a custom painting. Extends the JLabel and overide the painComponent method

example can be supplied if wanted

 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic