Results 1 to 5 of 5
  1. #1
    tOpach is offline Member
    Join Date
    Sep 2008
    Location
    Ankara-TURKEY
    Posts
    42
    Rep Power
    0

    Default [SOLVED] how to put string to JLabel with coordinate

    Hi everybody,

    I have a question about Jlabel and Jpanel . How can I put string to JLabel and Jpanel( I dont know which one is useful ) with coordinate which I will decide. Thanks in advance.

    Kind regards,

    Salih Ozan IRBIK.
    Last edited by tOpach; 12-17-2008 at 01:30 AM.
    A stitch in time saves nine:D

  2. #2
    tOpach is offline Member
    Join Date
    Sep 2008
    Location
    Ankara-TURKEY
    Posts
    42
    Rep Power
    0

    Default

    I really need that thing. I can add JTextField like;
    JTextField f1= new JTextField();
    f1.setBounds(30,70,100,30);
    add(f1);
    And I would like to add text "User Name" above JTextField, again by using setBound. Is ıt possible.If it is could you give an sample example?
    A stitch in time saves nine:D

  3. #3
    xcallmejudasx's Avatar
    xcallmejudasx is offline Senior Member
    Join Date
    Oct 2008
    Location
    Houston, TX & Flint, MI
    Posts
    609
    Rep Power
    7

    Default

    ya. Thats Swing correct? I'm assuming it works the same as SWT in which
    Java Code:
    new Label(banner, SWT.NONE).setText("Name:");
    		buildNameText = new Text(banner, SWT.BORDER);
    		GridData gridData = new GridData();
    		gridData.horizontalAlignment = SWT.FILL;
    		gridData.horizontalSpan = 2;
    		gridData.grabExcessHorizontalSpace = true;
    		buildNameText.setLayoutData(gridData);
    		buildNameText.setText("");
    I have 3 columns in my view so setting the horizontal span to 2 makes the input field 2 fields long.
    |Name|_input|field _|

    If you want something like this
    |Name| blank | blank |
    |input field goes here|

    you just need to do change my first line of code to
    Java Code:
    Label name = new Label(banner, SWT.NONE);
    name.setText("Name:");
    GridData nameData = new GridData();
    nameData.horizontalSpan = //what your max columns is set to

  4. #4
    xcallmejudasx's Avatar
    xcallmejudasx is offline Senior Member
    Join Date
    Oct 2008
    Location
    Houston, TX & Flint, MI
    Posts
    609
    Rep Power
    7

    Default

    eh dont forget name.setLayoutData(nameData);

  5. #5
    tOpach is offline Member
    Join Date
    Sep 2008
    Location
    Ankara-TURKEY
    Posts
    42
    Rep Power
    0

    Default

    dear xcallmejudasx,

    thank you very much. That's exactly what I was looking for.
    A stitch in time saves nine:D

Similar Threads

  1. How to write multiline String in a JLabel
    By JavaBean in forum AWT / Swing
    Replies: 4
    Last Post: 12-14-2009, 06:09 AM
  2. Replies: 1
    Last Post: 08-25-2008, 09:48 PM
  3. set coordinate to an image
    By nuur in forum AWT / Swing
    Replies: 2
    Last Post: 04-01-2008, 09:08 AM
  4. X&Y Coordinate Drawing on jPanel
    By BHCluster in forum Java 2D
    Replies: 2
    Last Post: 03-27-2008, 11:47 AM
  5. Replies: 2
    Last Post: 03-25-2008, 06:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •