Which layout I should use?

Hi,
I want to develop a panel which will contain label and a text field. Label should appear in first row and textfield should in second row. I tried to use boxLayout, but textfield in the second row is taking its maximum size. I want size of the textfield should be as per my need. What way I can use to achieve this?
Thanks,
Atul.

Sometimes you have to embed a couple of panels to keep things aligning properly. Here's another solution, using this method:
import java.awt.*;
import javax.swing.*;
public class LeftAlignedDemo extends JFrame {
     public LeftAlignedDemo() {
          JPanel cp = new JPanel(new BorderLayout());
          cp.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
          JPanel promptPanel = new JPanel(new BorderLayout());
          promptPanel.add(new JLabel("Enter a value: "), BorderLayout.LINE_START);
          promptPanel.add(new JTextField(30));
          JPanel temp = new JPanel(new BorderLayout());
          temp.add(promptPanel, BorderLayout.LINE_START);
          cp.add(temp, BorderLayout.NORTH);
          setContentPane(cp);
          setDefaultCloseOperation(EXIT_ON_CLOSE);
          setTitle("LeftAligned Demo");
          pack();
     public static void main(String[] args) {
          SwingUtilities.invokeLater(new Runnable() {
               public void run() {
                    new LeftAlignedDemo().setVisible(true);
}Note that if you're creating an input form, and have multiple label/textfield pairs, you might consider using SpringLayout. For just one label/textfield pair though, the above should suffice.

Similar Messages

  • Which tool i should use to develope a portal

    Hi all,
      we are planning to develop a portal which we will expose to internet.
    Now my question is which tool i should use to develope this
       1.BSP
       2. jspdynpage
       3.Webdynpro java
       4.Webdynpro abap
    Which application will perform better on internet.
    Lots of rfc calls and webservice calls are there.
    plz give me suggestions .
    Thanks
    developer

    Hi,
    BSP - Abap workbench
    JSP Dynpages - NWDS (Netweaver Dev Studio)
    Webdynpro Java - NWDS
    Webdynpro ABAP - ABAP Workbench
    above all applications will perform at same level  depend on the content.
    best regards
    Hari

  • Which protocol we should use for file transfer in ios ?

    which protocol we should use for file transfer in ios ?

    My friend that's definitively a Lotus Domino question, you'll probably ask in the Domino's forums if it generates wsdl, or simple http services you're ready to consume those services in Flex.

  • Which Listener I should use if I drag and Drop an image/icon into a JPanel?

    Dar Friends:
    Happy new year.
    I try to drag and Drop an image/icon into a JPanel, and hope I can immediately detect it after DND,
    Which Listener I should use in this JPanel if I drag and Drop an image/icon into a JPanel??
    Thanks

    Thank camickr .
    I can dnd an image into a JPanel called JPanelOld already, I hope to use another JPanel or JTree to listen to any Dropped Image in JPanelOld later on so I can take some action in another JPanel or JTree.
    so what kind of Listener I should use for my purpose??
    where to add this Listeners??
    Happy New Year.

  • Can someone tell which player I should use to run flv,avi file in my iPad 3 after download from any site ????

    Can someone tell me which player I should use to run flv,avi file in my iPad 3 after downloading video from any site ????

    Can someone tell me which player I should use to run flv,avi file in my iPad 3 after downloading video from any site ????

  • In which situations we should use Character Mode Reports?

    Question: In which situations we should use Character Mode Reports?
    Explaination: I am faced with a certain situation. I feel that I should develop reports in Character Mode. But I am not sure about this.
    I invite all readers to contribute on the subject matter. Once I receive responses, I will explain my specific situation as writing it now may narrow the list of such situations.
    Also I would like to know what problems we face when developing reports in Character Mode. I was developing my first Character Mode report and I faced layering problems. So I would like to know more such precautions.
    TIA
    Tariq

    Hi Muhammad,
    There's any number of cases for using character mode Reports. However, they all typically come down to what your doing with the output of the report.
    Basically, you need character mode reports whenever the Report output needs to be read by some sort of Ascii file reader. This could be notepad, VI, MSVC, dot matrix or fixed character set printers, ...
    A less common case is where you just want to get at the data within the report. You're just using the ascii output as a data dump to pass through to another program/utility. (This is really just a specialised case of the previous one).
    There are some cases where character mode output may be one of several choices. Eg: the body of an email message which could be HTML or plain text.
    Robin.

  • I have an iPhone in my name and my wife has an iPad in her name. We have just ordered an iMac and wondered which account we should use to get the best out of all the devices

    I have an iPhone in my name and my wife has an iPad in her name. We have just ordered an iMac and wondered which account we should use to get the best out of all the devices? Can we use both accounts in iCloud?

    Yes you can.  However, it is better to use one person's account most of the time for purchases in the Mac App Store and iTunes since you can share purchases, such as songs, among various devices using the SAME account.  You Cannot share purchases among different accounts, though.   So make one of your accounts the main "purchasing" account so you can share purchases.
    Hope this helps

  • Which platform I should use ?

    which java platform I should use to creat message display and settings in mobile phone ? and how can I add language code in java to show different laguage(other than English) on mobile screen ?

    Or is it the tabbed appearance of the portfolio cover which interests you? I think this might be made with Flash Builder. Very bad choice, to use Flash, in my opinion. Looks slick, certainly, but locking out all customers with iPads and Android is just lunacy. But see Adobe Digital Enterprise Platform * Demonstrating the Flash Builder-based interactive statement

  • I want to create report on Sybase which provider I should use.

    I want to create report on Sybase which is good provider that I should use. I don't want to use the DSN.

    CR no longer has a native Sybase driver. Your only option is to u se ODBC or possibly a JDBC driver if they have one or their client supports one. Look on Sybases site for options.

  • RFC and Webservice which one i should use and why?

    Hi,
      I have to write a extractor program in BI which would be fetching a huge data from CRM.
      I have two options to achieve this targer.
               1-> Create a RFC which will give me all the data
               2-> Create a Webservice in CRM and use it in BI
    Please advice me , which way i should go and advantage of that way.
    Regards
    PG

    Hi,
    If amount of data is huge then it is recomnded to use RFC because of its speed and reliability. Webservice not yet proven good for extracting and handling very large chunk of data.
    Regards,
    Gourav Khare

  • Which version I should use

    Hi,
    I got this
    Java 1.5.0_03 or later is required for installing Oracle Solaris Studio. Make sure that Java is properly installed and run installer again.
    You can specify valid Java location using --javahome installer argument.
    Can anyone tell me which JDK version I should use there?

    Moderator Action:
    This post has been moved from the Oracle Linux forum.
    You don't have a Linux question.
    You actually don't have a JRE/JDK question.
    You have a Solaris Studio question.
    You needed to spend an extra moment choosing where to post it.
    We moved it for you.

  • I am trying to download Firefox 4 but I get a window that asks me what Firefox should do with this file. I have no idea which program Firefox should use to download the file!! Help!

    What should the default program be for downloading this type of file? How can I get Firefox to download these without asking me which program to use?

    Firefox 4 requires at least OS X 10.5 and an Intel Mac.
    * http://www.mozilla.com/firefox/4.0/system-requirements/
    For Mac OS X 10.4.11 or Mac OS X 10.5.8 you can look at:
    * http://www.floodgap.com/software/tenfourfox/
    Firefox 3.6.x can be found here:
    * http://www.mozilla.com/en-US/firefox/all-older.html

  • Which Time variable should use compare this month with last month

    We want to calculate the increaed number of employees according to one action reason e.g. Entry to company compare with last month. In this case we have to use time variable in BEx query designer. Now can see 0calmonth has serval variable available.
    1) Should we use [0CMLMON] for last month and use offset for this month like [0CMLMON]-1 or [0CMLMON]+1 or use variable [0RSTTCM1], which variable should we use for this month and last month? Do we need to create variables by manually?
    2) Then using calculated KF to calculate the increaed number of employees, is this logic correct? If it is wrong, please info.
    Edited by: hi ni on Apr 22, 2008 7:58 AM

    Hi,
    For the comparison of last 2 months data, you can use two Restricted Key figures with reference to 0CALMONTH and it is better to use only customer exit variable for both RKF's.For the Last month use offset value as -1.
    Rgs,
    I.R.K

  • Which trigger i should use to display the values

    Hi all,
    Assume there are four fields in my forms coming from the same table i.e empno,empname,depno,salary.In which empno is LOV which displays all the employee names whenever i select the empname from the list the form should automatically fill empno,depno,salary fields which form trigger i can use here....

    The Column Mapping Properties in the LOV's property palette allows you to select a return item for each column displayed in the LOV. This will do what you want, there is no trigger involved. If you want a value to be returned but not visible in the LOV then set the column width in the LOV to zero.

  • Any advice on which method I should use?

    Essentially, I will be collecting a varaible number of longs. Te fixed length of arrays makes it seem inefficient and I am not sure what collection method/object I should be using otherwise. Please advise. Thank you.

    Essentially, I will be collecting a varaible number
    of longs. Te fixed length of arrays makes it seem
    inefficient and I am not sure what collection
    method/object I should be using otherwise. Please
    advise. Thank you.You can use an ArrayList of Long.
    An ArrayList basically is a dynamic array implementation so it will grow in size as you add the Longs.
    Not that I write Long instaed of long. Long is the wrapper class of the long primitive. ArrayLists can only store objects so if you add longs they will be converted to Long objects instead. This is a drawback but it may not be a problem for you?
    One possible strategy is to first collect the Longs in an ArrayList and then when you know the actual umber of longs create a static long array of that size.

Maybe you are looking for