Position buttons problem

Hi all i just started java couple of days ago and im stuck on how to position my buttons on screen. I cant seem to position the button to the bottom of my screen lined up in rows. Also how can i insert an image area in the middle?
Thx people for your help
import javax.swing.*;         
import java.awt.*;
import java.awt.event.*;
public class SwingApplication implements ActionListener {
    private static String labelPrefix = "Number of questions answered: ";
    private int numClicks = 0;
    final JLabel label = new JLabel(labelPrefix + "0    ");
    //Specify the look and feel to use.  Valid values:
    //null (use the default), "Metal", "System", "Motif", "GTK+"
    final static String LOOKANDFEEL = null;
    public Component createComponents() {
        JButton AnswerButton = new JButton("Answer");
        JButton Submit = new JButton("Sumbit");
         JButton button = new JButton("Next Question");
        JTextField AnswerText = new JTextField("");
        button.setMnemonic(KeyEvent.VK_I);
        button.addActionListener(this);
        label.setLabelFor(button);
         * An easy way to put space between a top-level container
         * and its contents is to put the contents in a JPanel
         * that has an "empty" border.
        JPanel pane = new JPanel(); //(new GridLayout(0, 1));
        pane.setLayout(new GridLayout(2,3)) ; //2 rows, 3 columns
        pane.add(button);
        pane.add(label);                     
        pane.add(AnswerText);                             
        pane.add(AnswerButton);   
        pane.add(Submit);    
        pane.setBorder(BorderFactory.createEmptyBorder(
                                        300, //top
                                        300, //left
                                        300, //bottom
                                        300) //right
        return pane;
    }

these links might help
http://java.sun.com/docs/books/tutorial/uiswing/layout/visual.html
http://java.sun.com/developer/onlineTraining/GUI/AWTLayoutMgr/shortcourse.html
then try this
import javax.swing.*;
import java.awt.*;
class SwingApplication extends JFrame
  String labelPrefix = "Number of questions answered: ";
  JLabel label = new JLabel(labelPrefix + "0    ");
  public SwingApplication()
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setLocation(300,200);
    setSize(400,300);
    JButton answerButton = new JButton("Answer");
    JButton submit = new JButton("Sumbit");
    JButton button = new JButton("Next Question");
    JTextField answerText = new JTextField("");
    JPanel pane = new JPanel(new GridLayout(2,3));
    pane.add(button);
    pane.add(label);
    pane.add(answerText);
    pane.add(answerButton);
    pane.add(submit);
    getContentPane().add(pane,BorderLayout.SOUTH);
    JLabel forImage = new JLabel(new ImageIcon("Test.gif"));
    getContentPane().add(forImage,BorderLayout.CENTER);
  public static void main(String[] args){new SwingApplication().setVisible(true);}
}

Similar Messages

  • SM30 / View Maintainance Call problem with Position button

    We are having an issue with the position button on Tcode SM30 and Function View Maintenance Call. When we press the position button and try to enter a material number (matnr element, with links to the correct databases) and then click on ok, it doesn't found materials that we know are on the Ztable.
    Experimenting, I found that entering the complete number with all the leading zeroes finds the correct item, so my guess is that the Position button doesn't use the conversion alpha exit. A test with a Ztable where the made up code fills up the entire code space shows it finds the data correctly, so it seems that completion is the issue, reinforcing the idea that the conversion alpha exit (wich is correctly associated to the matnr domain) is not working in positioning.
    Any pointers or ideas will be appreciated.

    Hi
    Use this function modules for the material number
    CONVERSION_EXIT_ALPHA_input
    CONVERSION_EXIT_ALPHA_output
    I think it will work..find in debug wat value s coming

  • Caller screen Buttons problem Z10STL100-1

    I have Z10STL100-1 after official update Z10STL100-1/10.3.1.1565 having caller screen Buttons problem these are little above not like it's on 10.2 very below position. I security wipe and restart many times still same position of buttons? See pic attached

    Hello,
    Did you check if there are no objects on that index slide that have a fading transition? You should set the transition for every object to 'No transition'. The transition can be found in the Properties dialog, tab Options.
    Lilybiri

  • Position button at the end of ALV grid

    Hi,
    I have a requirement to place position button (like in OB52 or any table/view maintenance ) to search and position the record on the top of list. I have placed the position pushbutton with function code and have called TABLE_GET_KEY_TO_SET_CUR_ROW for the input . My alv grid doesn't show the toolbar till the records cross one page. can you please suggest 1- how to make the scrollbar visible always ? 2- How to make the position button work as in tables for ALV grid?
    Regards,
    Garima

    I have created the pushbutton in the same screen as container and assigned a function code. I have put this logic in user-command for this button and refreshed display. But it doesn't work, moreover the scrollbar is not visible if the records are less than one page.
    MODULE USER_COMMAND_0100 INPUT.
      CASE SY-UCOMM.
        WHEN '&BACK&'.
          LEAVE TO SCREEN 0.
        WHEN '&EXIT&'.
          LEAVE PROGRAM.
        WHEN '&POSI&'.
          DATA: LV_EBELN(15) TYPE C,
                IT_EXCL TYPE VIMEXCLFLD OCCURS 0,
          WA_EXCL TYPE VIMEXCLFLD,
          LV_PO TYPE EKKO-EBELN.
          DATA: LT_CELL1 TYPE TABLE OF LVC_S_ROID,
           LS_ROW_ID TYPE LVC_S_ROID,
           LS_COL_ID TYPE LVC_S_COL.
          DATA: LWA_CELL1 LIKE LINE OF LT_CELL1.
          WA_EXCL-FIELDNAME = 'MANDT'.
          APPEND WA_EXCL TO IT_EXCL.
          CALL FUNCTION 'TABLE_GET_KEY_TO_SET_CUR_ROW'
            EXPORTING
              TABLE             = 'EKKO'
            IMPORTING
              TABLE_KEY         = LV_EBELN
            TABLES
              EXCLUDE_FIELDS    = IT_EXCL
            EXCEPTIONS
              CANCELLED_BY_USER = 1
              TABLE_NOT_FOUND   = 2
              OTHERS            = 3.
          IF SY-SUBRC EQ 0.
            SHIFT LV_EBELN LEFT DELETING LEADING SPACE.
            MOVE LV_EBELN+0(10) TO LV_PO.
            READ TABLE GT_FINAL INTO WA_FINAL WITH KEY EBELN = LV_PO.
            CALL METHOD R_GRID->GET_SCROLL_INFO_VIA_ID
             iMPORTING
                ES_ROW_NO   = LS_ROW_ID
                ES_COL_INFO = LS_COL_ID.
            LS_ROW_ID-ROW_ID = sy-tabix.
            LS_COL_ID-FIELDNAME = 'EKGRP'.
            data: ls_row type LVC_S_ROW,
           ls_col type LVC_S_COL.
    ls_row-index = 2.
    CALL METHOD r_grid->set_scroll_info_via_id
       EXPORTING
         IS_ROW_INFO = ls_row
         is_col_info = ls_col.
          ENDIF.
        **Row and column of the alv are refreshed after changing values
      STABLE-ROW = 'X'.
      STABLE-COL = 'X'.
    *REfreshed ALV display with the changed values
    *This ALV is non editable and contains new values
      CALL METHOD R_GRID->REFRESH_TABLE_DISPLAY
        EXPORTING
          IS_STABLE = STABLE
        EXCEPTIONS
          FINISHED  = 1
          OTHERS    = 2.
      IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Please help!!

  • 'Position' Button in Table Maintenance Generator

    Hi,
    i am using 'Position' button to navigate to particular entry in the table in table maintenance generator.
    as far as i know this will correctly when we provide 'left part' of key in the pop up provided by position button.
    however in my case where i changed the column positions in the table maintenance generator which includes key fields.
    does it going to affect 'Position' functionality? because position button is not taking me to correct positions now.
    please suggest....

    Did you change the key field order in the table structure in SE11 or did you manipulate the table maintenance screens by changing the key column order?
    In either case, you can regenerate table maintenance by clicking the change button in SE55 and selecting all check boxes. This will correct the issue. However, check if you have any custom events written or modified screens, as those changes will have to be restored after regeneration

  • Apart from the lock button problem in iphone 5 the display brightness suddenly goes blank and becomes normal after locking and unlocking the iphone. The Apple service centre in India is denying to service the iphone as it was purchase in USA even thoug it

    Apart from the lock button problem in iphone 5 the display brightness suddenly goes blank and becomes normal after locking and unlocking the iphone. The Apple service centre in India is denying to service the iphone as it was purchase in USA even though the iphone is in warranty.

    iPhones do not have an international warranty.  Warranty is valid only for the country of purchase.  This is most likely because different countries require different iPhone models.  Not reasonable to expect all countries to maintain stock for all models.

  • **URGENT** Scene button problem!

    Why my 'maps' and 'video' buttons do not play the movie? I use this code:
    on(release){gotoAndPlay("play");}
    I have labelled "play" in other scene, but it does not play the movie!
    I have tried this code:
    on(release){gotoAndPlay("Scene 36", "play");}
    Still, it does not work as well! I got deadline this week, so I need your help ASAP!
    I got other button problems on every scene! It's frustrating!
    Please download my flash file to look at my flash product!
    http://www.4shared.com/file/24177440...6d/Maps_1.html

    Nope it doesn't work , I got my deadline this week and if you got a spare time, would you please download my flash and check and repair it please! Only two buttons need refitting and nothing else! I asked my teachers, they tried their best and couldn't find what the problem is. I looked through other forum website, I tried the solutions and it doesn't work! I am really behind as there are many failure in my project! This is my first flash creation.

  • Naming Buttons - Problem with using Captivate 7 Buttons to Open URL or File

    After spending too much time troubleshooting a button problem, I discovered the importance of naming each item in a Captivate project.
    For some reason I have yet to figure out, publishing to SWF from Captivate causes buttons to function arbitrarily. In my case, I had eight buttons pointing to external URLs, three that worked and five that didn't. All of the buttons pointed to the same external website, only to different PDFs hosted on that site. Each button was named with the default "Button_X" convention as set by Captivate. After trying lots of different settings adjustments, On Enter and On Exit actions, and Play/Pause timings, I did what I should've done from the beginning; changed the names of the buttons.
    Why this worked? I don't know. I've seen hints on other discussions as to SWFs not working well when there are a lot of unnamed or default-named items. If there's some logic to this I would be happy to know it, but for a default setting to cause such a bizarre problem is beyond my comprehension. I could understand if I had named the buttons incorrectly, but I didn't do anything to them; I left them with the names created by default.
    Hopefully this helps someone else resolve a similar issue and, if anything, encourages everyone to follow best practices and use a clear file naming conventions for all projects.

    Hi there
    Perhaps the link below will help?
    Click here to view
    Cheers... Rick
    Helpful and Handy Links
    Captivate Wish Form/Bug Reporting Form
    Adobe Certified Captivate Training
    SorcerStone Blog
    Captivate eBooks

  • K button problems

    K button problems on keyboard. Has to be pressed harder than all the other butons on the keyboard. Ive tried going on  command prompt and pressing it, and its the same. I am running windows 7 pro.

    you probably need to get a new keyboard if you have a model number i can send you a link on what you need thanks 

  • HT1688 iPhone 4 home button problem

    Good afternoon,
    I have an iPhone 4 and it still in good condition but sometimes, the Home button doesn't respond quickly or doesn't respond at all. What to do?

    I seem to have fixed my iPhone 4 home button problems.
    1. Sync phone and back up.
    2. Go back and resync phone but uncheck all the apps you have purchased/downloaded so that your iphone will have no additional apps on it.
    3. Now reset your phone as a NEW PHONE.
    4. When reset as NEW, unplug it and try home button functions. I'll bet they work just fine, like mine did.
    5. Now that you are satisfied you can resync your apps, but be choosey. Re-install only a couple at a time, and test your home button each time. You'll soon find out which of your apps is causing the problem. It's time consuming and irritating, but it certainly works.
    So far - no problems with my selected re-installed apps. My home button works fine.
    However, I recently purchased several photography apps and an emoticon app and that was when the problems appeared to have started.
    So I've been very selective in putting only the apps I want back on ... for now.
    Hope this helps.
    I will report back to tell you if this complicated but effective solution has worked for me.

  • Home button problem in iphone 3g 3.0

    After upgrading my iphone 3g to 3.0 software, the home button has become so unresponsive, i have to click it 6-10 times sometimes to awake it. I mean what is it, dont you check the update before making it available to public, i mean its annoying, my 2 other friends have same problem as mine, they are on iphone 3g too. even 3.0.1 behaves the same way. comeon folks, become professional, kindly fix this thing in next firmware release.

    I had exactly the same problem - I bought my iphone 3gs last week, upgraded it and had the 'home button' problem. I tried all the fixes - restarting, resetting to factory settings, reloading update, etc. Then, a few days later, it all sorted itself out - no idea what happened, but since then my home button has been working perfectly! I have a feeling the factory reset and reload of update might have been the one that eventually did the trick...but since then, touch wood, it has been working perfectly. I would suggest trying the factory reset and see if that helps...make sure you back up first though!

  • Mega 865 - HiFi Button problems !

    Mega 865 - HiFi Button problems.
    Hi,
    I recently had some problems with the LCD display on the 865 and after
    following the very technical (wiggle the power cable) instructions, i got
    the LCD display working again, but now my HiFi button doesn't work
    has anyone experienced this before ??
    The radio/lcd display works fine in media centre
    cheers.

    I refer to this post https://forum-en.msi.com/index.php?threadid=66148
    I did this and the LCD display came back on again but now the hifi button doen't work

  • Anti virus's and home button problem

    Hi
    1)i want to
    We Need antiviruse in My iPhone 5s ?
    2)how to understand my iPhone when produce???
    Due to home button problem .
    Thanks

    There is no home button problem, the problem is with the power button on some iPhone 5 devices: https://ssl.apple.com/support/iphone5-sleepwakebutton/

  • G750 power button problem

    Hi guys,
    So the problem with my laptop is that when I press the power button, the power button itself and the two leftmost lights below the touchpad- power and battery- they light up for a second or two. But the laptop doesn't start up and the lights go off. If I long press the power button, the laptop starts, though.
    Now this is not a severe problem as of now, I know. But I'm pretty sure this will escalate into something else. Does anyone know what the problem actually is and what I can do to solve it? 
    P.S.: Unlike people with power button problems, I didn't do anything with the hardware or software.

    Hi Sanjana,
    Welcome to Lenovo Community!
    I’m sorry to hear that the Power button is not working as expected in your G750 Laptop. I would suggest you to perform the Flee-Power, below are the steps to perform the same:
    Remove the battery and any other peripheral device connected to the computer.
    Hold the power button for 10-15 seconds and then connect only the AC Adapter and try to turn ON the computer.
    If the issue persists even after performing Flee-Power, I would suggest you to contact our Technical Support for further Assistance to get the details of the nearest Authorized Service Center to get the issue analyzed.
    Click here to open a link where you can select the country and get the exact contact support number. I’m sure they will be a great help.
    Do post us back for further queries.
    Best Regards
    Shiva Kumar
    Did someone help you today? Press the star on the left to thank them with a Kudo!
    If you find a post helpful and it answers your question, please mark it as an "Accepted Solution"! This will help the rest of the Community with similar issues identify the verified solution and benefit from it.
    Follow @LenovoForums on Twitter!

  • Power Button Problem NO MORE HP!!!

    Tried everything to fix my power button, but no way,NO MORE HP.
    Today, one of my friends also had power button problem, even his laptop was one of the newest model.

    Model?

Maybe you are looking for

  • HT5639 How to stop a Terminal process when a file becomes to large?

    I was making a terminal program to produce a txt file with incrementing numbers every line. But do to time and size I had wished the program to stop when it produced a txt file larger than 1GB here is the code I was using. #!/bin/bash main()     cd ~

  • 5002 Tax group account is missing

    I'm using the DI Server to add invoices, and I suddenly get "-5002 Tax group account is missing" whenever I try to make an invoice. What's strange, is that this occures only on one of my SAP-databases, whereas the others are ok. Luckily it's in a tes

  • I have two emails only one shows on my phone

    I have two e-mail accounts only one will show  on my iphone

  • Location of the Source Pane columns

    I would like to reverse the positions of the Name and Artist columns in the Source Pane. I can change the position of all of the columns except Name and Artist. I am using iTunes on Windows.

  • RE:  PHOTOSHOP CC - MENU ITEM EXPLANATIONS

    1)  Where can I find a very basic, very in depth discussion of of all menu items?   There are so many that do not seem to be covered in any of the tutorials - such as "Image" > "Mode" > "8, 16, 32 Bit/Channel".   That's just an example.  Even Fundame