Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

setbounds(); method in Swing

  • 27-04-2004 11:43pm
    #1
    Registered Users, Registered Users 2 Posts: 366 ✭✭


    hey,
    Just finished a project in college that was fully implemented using swing.
    A lot of people used absolute positioning for their gui layout. Some lecturers have pointed out that this is bad programming..however you may gain marks for good gui but lose marks for bad programming practices because using setbounds is not industry standard,
    eg:
    JLabel jk = new JLabel("hello");
    jk.setbounds(100,50,60,25);

    Just wondering if this is true in industry?
    thanks


Comments

  • Registered Users, Registered Users 2 Posts: 491 ✭✭Silent Bob


    setBounds() exists as part of Java's Swing API (it's a method of JComponent) and if it's in there then it is standard Java.

    As for it not being great programming practice you should probably use a layout manager, that way your app will scale accordingly when users resize it.

    You don't “lose marks” for making bad programming decisions in industry, you might lose a load of time and money later on as you have to fix your mistakes, or no-one might notice :)

    In short, it is better to program the lazy way. The lazy way is the way that saves you a lot of effort much further down the line, not the one that saves you a little effort now. After all you wouldn't want to have to do all that extra work in a months time, would you? :)


  • Registered Users, Registered Users 2 Posts: 366 ✭✭Jk_Eire


    cool thanks..
    Ya just cant get it perfect with layout managers though..
    well i cant anyway :D
    yeah your right about resizing the screens,never thought about that,
    but it looks good now and unless head of computing deems it to such a good project and wants to licence and sell it..which is highly unlikely theres no fixing to worry about :ninja:


  • Closed Accounts Posts: 660 ✭✭✭naitkris


    have you tried the GridBagLayout way of doing it in Swing out of the different layout methods? i found this to be the easiest way of organising my GUI and keeping everything neat - is great in the long run as you don't need to worry about content changes messing up your layout.


Advertisement