What method I use?

import java.awt.*;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
public class GridBagLayoutDemo2{
    final static boolean shouldFill=true;
    final static boolean shouldWeightX=true;
    final static boolean RIGHT_TO_LEFT=false;
    public static void addComponentsToPane(Container pane){
        JLabel lbl;
        JTextField txt;
        JButton button;
        pane.setLayout(new GridBagLayout());
        GridBagConstraints c=new GridBagConstraints();
        lbl=new JLabel("        ");
        c.fill=GridBagConstraints.HORIZONTAL;
        c.gridx=0;
        c.gridy=0;
        pane.add(lbl,c);
        lbl=new JLabel("First Name:");
        c.fill=GridBagConstraints.HORIZONTAL;
        c.gridx=1;
        c.gridy=1;
        pane.add(lbl,c);
        lbl=new JLabel("Last Name:");
        c.fill=GridBagConstraints.HORIZONTAL;
        c.gridx=1;
        c.gridy=2;
        pane.add(lbl,c);
        lbl=new JLabel("Middle Name:");
        c.fill=GridBagConstraints.HORIZONTAL;
        c.gridx=1;
        c.gridy=3;
        pane.add(lbl,c);
        txt=new JTextField(20);
        c.fill=GridBagConstraints.HORIZONTAL;
        c.gridx=2;
        c.gridy=1;
        pane.add(txt,c);
        txt=new JTextField(20);
        c.fill=GridBagConstraints.HORIZONTAL;
        c.gridx=2;
        c.gridy=2;
        pane.add(txt,c);
        txt=new JTextField(20);
        c.fill=GridBagConstraints.HORIZONTAL;
        c.gridx=2;
        c.gridy=3;
        pane.add(txt,c);
        lbl=new JLabel("                ");
        c.fill=GridBagConstraints.HORIZONTAL;
        c.gridx=3;
        c.gridy=1;
        pane.add(lbl,c);
        lbl=new JLabel("                ");
        c.fill=GridBagConstraints.HORIZONTAL;
        c.gridx=3;
        c.gridy=2;
        pane.add(lbl,c);
        button=new JButton("OK");
        c.fill=GridBagConstraints.HORIZONTAL;
        c.anchor=GridBagConstraints.CENTER;
        c.gridx=4;
        c.gridy=1;
        pane.add(button,c);
        button=new JButton("Cancel");
        c.fill=GridBagConstraints.HORIZONTAL;
        c.insets=new Insets(10,0,0,0);
        c.gridx=4;
        c.gridy=2;
        pane.add(button,c);
     * Create the GUI and show it. For thread safety,
     * this method should be invoked from the
     * event-dispatching thread.
    private static void createAndShowGUI(){
        JFrame frame= new JFrame("GridBagLayoutDemo");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        addComponentsToPane(frame.getContentPane());
        frame.pack();
        frame.setVisible(true);
    public static void main(String[] args){
        javax.swing.SwingUtilities.invokeLater(new Runnable(){
            public void run(){
                createAndShowGUI();
}masters can you tell me what method I add to make the object never move once you maximize the frame?

If you want the JComponents to stay in the upper left of the JFrame, then just add the GridBagLayout JPanel to a JPanel that uses FLowLayout(FlowLayout.LEFT), then add this to the contentPane.

Similar Messages

  • Firefox will not maximize. Covers about 1/2 of my monitor and will not max, no matter what method I use. How do I correct this?

    My firefox screen is filling only about 1/2 my monitor screen. I cannot maximize it no matter what method I use (F11, manual click & drag on corner). I have rebooted; no change.
    == This happened ==
    Just once or twice
    == I opened Firefox this morning. Has never happened before.

    See:
    *http://www.imessengr.com/2006/12/how-to-remove-uninstall-sweetim.html
    * http://www.sweetim.com/help_simff.asp

  • What method is used to take action of Enter button in keyboard?

    I doing exercise about GUI.
    One ex ask me type a number in one JTextField object, press Enter and then another converted number appear in the second JTextField object. This ex are not allowed to use a JButton object. I have no idea about what method to use to take action of pressing Enter. Please help me.
    Thank you

    Encephalopathic wrote:
    codingMonkey wrote:
    Interesting. I never knew that.Did you really not know, or are you trying to tell me in a nice way that my answer is full of chit (it's been known to have happened before and I know will happen again)?I really did not know that. It is an interesting little fact that might come in useful someday. :)

  • I can't launch Safari. When I right click on the icon, the "Application not responding" is grey and no matter what method I use to Force quit, I get no response.

    I can't launch Safari. When I right click on the icon, the "Application not responding" is grey and no matter what method I use to Force quit, I get no response.

    Do a backup.
    Quit the application.
    Go to Finder and select your user/home folder. With that Finder window as the front window, either select Finder/View/Show View options or go command - J.  When the View options opens, check ’Show Library Folder’. That should make your user library folder visible in your user/home folder.  Select Library. Then go to Preferences/com.apple.Safari.plist. Move the .plist to your desktop.
    Restart the computer, open the application and test. If it works okay, delete the plist from the desktop.
    If the application is the same, return the .plist to where you got it from, overwriting the newer one.
    Thanks to leonie for some information contained in this.

  • What method u use to out put text

    what method u use to out put text  is top ....end top or write_form.
    say me 1 reason for using write_form rather than top...endtop.

    Logic Pro is a professional application that is available very cheap, so that professionals and amateurs alike can use the same tools. This is because the cost is subsidised by the cost of the mac computers.
    A reciever that has optical, coax and HDMI would be a consumer grade home theatre system. Mixing to 5.1 is a highly specialised task, and you are very unlikely to get good results through a home theatre system, even if you could plug it straight in.
    Professionals who do 5.1 mixing with Logic (I am one of them) would have a serious multichannel external audio interface, and would plug the disctrete outputs from there into a monitoring system setup in a properly designed room. Anything less would result in a mix that would sound different everywhere it is heard, and probably only good in your room.
    The mix as done by logic provides a file or files that are 6 discrete channels. You would then use a program like "Compressor", (previously available with Logic Studio and not to be confused with an audio compressor) to convert the files to one of a number of possible formats.
    The format that your receiver would be looking for would be a Dolby digital format, a licensed format designed especially for home theatre. If every mac was designed to deliver that natively so the very few who might use it are able to access it directly, every mac user would have to pay more. This wouldn't make sense.
    Sorry.

  • Urgently, Help. Stuck on this issue when unable to figure out what methods to use...

    Urgently, Help. Stuck on this issue when unable to figure out what methods to use...
    Attachments:
    enquiry.jpg ‏101 KB

    so sorry about that
    I have an example attached.
    How to control the pause function automatic control by the system timing? when only reaches 0000hrs, pause function execute?
    Attachments:
    pause_button.vi ‏16 KB

  • OIM11g: Is there a way to find out what method is used to create user

    Hello,
    I have a user pre-create event handler that gets called every time a user is created in OIM. In here, is there any way to find out if the user is created by self-service request, admin, or by an external client that used UserManager API? How can the Orchestration parameter be used to get this information?
    Thanks

    Once you have closed the file, the history in the palette is gone.

  • How to create a warm full chorus effect on a vocal track? What effects, plugins or methods to use?

    Hey, I am using Logic pro 9 and have been for quite sometime now. The reason I am here today is because I want to know how to create a warm, more full, (almost doubling) chorus effect for my vocal hooks for the hip-hop tracks that I create. I have always heard that type of effect on hooks and never knew how they did it. For example in this song (This song is not my song, excuse the language but this is the type of effect i am looking for. Go to 1:12 of the song)
    http://www.youtube.com/watch?v=5aok9Hq7GQ4
    This is what I am looking for. PLEASE SOME ONE HELP I WOULD REALLY APPRICATEIT!! Thanks

    True, the equipment that I am using does matter and at the moment I am only using a usb microphone with no pre amps or audio interface. I was asking that question to know what methods people use to create that chorus  effect. What I did for the time being until I get my new set up I had a main vocal track that was centered and had no effect on it, then made 2 other copies so I had 3 tracks all together I panned one track all the way left and the other track all the way right then I applied the stereo spreader to the two copied tracks and turned the mix 76% channel delay 250 same intensity 100% and speed 1.644 Hz. Then I manually moved the tracks so that the left panned track came first then the main track then the right panned track. It was very small moves not to the point were you could tell just gave it that chorus effect. Do you think those were the right things to do? So its close almost there and maybe with the new setup it will be what I am looking for. But PLEASE KEEP COMMENTING EVERYONE HAS THERE OWN METHODS I AM CURIOUS TO KNOW YOURS!

  • What method does Audition use to determine the overal frequency?

    Hi,
    Does anyone know what method Audition uses to determine 'overall frequency' in the 'frequency analysis' section? I need to know how it is calculated?
    Many thanks!

    stephaniec9433324 wrote:
    Thank you for that! So am I right in thinking the 'overall frequency' is just the frequency point which contains the highest amount of energy in a given sound sample?
    I don't know why it's called the 'overall' frequency - seems a bit strange to me, although what else you could call it without it being a bit of a mouthful, I'm not sure. But strictly speaking, what it is is the frequency of the highest amplitude at that instant in the display. It's not really a signal you are measuring either; it's a single FFT 'slice', which begs even more questions, as the size of the slice determines the resolution, and therefore the accuracy of the result anyway.

  • What counter method to use for measuremen​ts on combustion engine

    Hello,
    Here is my dilemma. I want to measure the rpm of crank/cam shaft and thus I need to determine which of the three methods to use to get accuracy +-5rpm and couple of readings during one revolution of the shaft.
    The hardware: NI PCI 6120-two counters
    IRC 360-3600 pulses
    Lets say I want to measure the range of rpm of the crankshaft from 100rpm(1.7Hz) to 10000rpm(166.7Hz). If I use the IRC with 720pulses I get the frequency range I will be measuring 1200Hz-120kHz assuming the IRC is on the crankshaft.
    So my question is which of the methods to use? I did some calculations to determine that
    1) 1 counter - the calculated rpm if the real rpm was 6000 would be between 5973-6017 which is not good enough
    2) 2 counters, high freq - I would have to be using the frequency of the gate around 1Hz to get desired accuracy at 100rpm which is not suitable since I also want to have more readings through one revolution - do I understand it right? That would mean for example at 6000rpm I would have to wait 100revolutions to get one rpm reading, right?
    3) seems as the right choice but still the acuracy is not good enough. If I use the divider of 10 it gives me 72readings per one revolution if the IRC is set to 720 pulse. If I measure at 6000rpm the diversion is then +-3rpm. But with 10000rpm and 3600pulses per revolution of the irc the diversion is already +-40
    What method is used for this kind of measurement? How to improve  accuracy?
    Thanks
    Message Edited by ceties on 07-09-2009 03:12 PM
    LV 2011, Win7

    Hi Ceties,
    Yes, if you want to measure 600 kHz signal, the error will increase. I thought you were intend to measure upto 120 kHz.
    In Method III, we do the following:
    We have a known time period (1 ms), we have a frequency to measure (100 kHz), we will know how many pulses are going to be in that period ([100*e3]*[1*e-3]=100). First, we would like to divide this frequency with the first counter: we generate another known pulse train for 1 ms period with i.e. 500 pulses. In this case the rate will be 100/500 = 1/5.
    Know, we are able to measure a lower frequency signal (100 kHz*1/5 = 20 kHz) with Method I. Which results a much more accurate measurement. That is the theory behind Method III.
    Pulses per revolution to read will remain the same in each case: (frequency to measur)/(basis clock); in different methods we are trying to increase accuracy with measuring either a longer period (Method II) or diveded frequency (Method III).
    I hope it will help moving forward with your project!
    Regards,
    Matyas

  • What method should be used for resizing the particular JTable Column width

    I have a four table. Only one table which are on top have a table header. I want that when user resize the topmost table with a mouse other table colume also be resized automatically. So I want to know that what method should be used for resizing the particular JTable Column width.
    Thanks
    Lalit

    maybe you can implement a interface ComponentListener as well as ComponentAdapter with your topmost Table.
    for example:
    toptable.addComponentListener(
    new ComponentAdapter(){
    public void componentResized(ComponentEvent e){
    table1.setSize(....);
    table2.setSize(....);
    /*Optionally, you must also call function revalidate
    anywhere;*/
    );

  • What is the use of OTYPE_REF in Add method

    what is the use of OTYPE_REF in Add method

    class A
    static public void m(){}
    class B extends A
    static public void m(){}
    }is this over riding? well static methods are bind at
    compile time then there shouldnt be any over riding
    in case of static methods but when we use final
    keyword in the method of class A it makes an error.
    when static methods are bind at compile time then
    what is the use of final keyword with static methods?there is none, since static methods cannot be overridden and final prevents them from being overridden

  • What is the use of passing String[] args in main() method?

    what is the use of passing String[] args in main() method?
    Is there any specific use for this ?

    actually my sir asked me the same question & I gave
    the same reply as given by you........but he further
    asked what is the use of this also??
    ie accepting cmd line args at runtime??is there any
    specific purpose ??Apart from the one you just mentioned? No

  • What method, BAPI, etc. is used to launch a standard SAP transaction?

    Hello friends,
    Is there a simple way of finding out what method, BAPI, FM, etc. is used  to launch a standard SAP transaction?
    I was told that instead of CALL TRANSACTION using BDCDATA stuff, I can use the method or BAPI or FM, or whatever to get the same results. The problem is I don't know how to find out this information.
    Apparently using BDCDATA for a CALL TRANSACTION form within an ABAP  program can be hazardous because of SAP's upgrades, new releases etc... If one of the screens is modified during the next release, then the BDCDATA will no longer work. So I need to launch a transaction from within my ABAP  without having to worry about future changes implemented by SAP.
    Any ideas?
    Your help is greatly appreciated,

    Hi,
    It depends on which transaction you are looking for. Usually it comes by experience. You can search in SE37 or transaction BAPI to find out relevant BAPI suitable for you. All BAPI FMs starts with name BAPI.
    eg: If you want to findout the BAPI for VA01 transaction, try like this.
    SE37=> enter BAPIsalescreate* and click F4.
    You can see below list of FMs.
    BAPI_SALESDOCU_CREATEFROMDATA
    BAPI_SALESORDER_CREATEFROMDAT1
    BAPI_SALESORDER_CREATEFROMDAT2
    BAPI_SALESORDER_CREATEFROMDATA
    BAPI_SALES_DEL_SCHEDULE_CREATE
    BAPI_SALESORDER_PROXY_CREATE
    BAPI_SALESDOCU_CREATEFROMDATA1
    BAPI_SALESDOCU_CREATEWITHDIA
    By looking at the name we can identify upto 60%. Just go through the FM documentation and see if it works for u and how to use it.
    SCN is always there to help us out. But before posting to ask for a BAPI, please search and give a try to findout:)
    Thanks,
    Vinod.

  • What is the best method to use for revealing the text on a jpg (as though the text is drawing itself?) Thanks.

    What is the best method to use for revealing the text on a jpg (as though the text is drawing itself?) Thanks.

    tacbob wrote:
    Are there any tutorials? I cannot find anything close.
    http://itunes.apple.com/de/podcast/write-on-effects-in-motion/id287113664?i=4883 4057
    The MacBreak Podcasts are an excellent source of info!
    Have a look on the others ..

Maybe you are looking for