Help!!! Simple JFrame doesn't work in jdk1.4

If I run the following code in jdk1.2 it works fine, but in 1.4 only one button displays initially. If I click on the button, the other will display, but it displays in the last location that the window was in. For example, if I move the window first, then click the button, it draws itself at the location that it was previously at. Even more frustrating, when I close the window, once again, it draws itself in the last location and this remains on the screen, even after the vm exits.
Source:
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class FrameExample extends JFrame {
public FrameExample(String title) {
     super(title);
     setSize(350, 200);
     setLocation(300, 300);
     JButton button1 = new JButton("Button 1");
     JButton button2 = new JButton("Button 2");
     JPanel buttonPanel = new JPanel();
     buttonPanel.add(button1);
     buttonPanel.add(button2);
     getContentPane().add(buttonPanel);
     setDefaultCloseOperation(EXIT_ON_CLOSE);
     setVisible(true);          
public static void main(String args[]) {
     FrameExample fe = new FrameExample("Frame Example");

try to set the width and height of the frame - setSize(int, int). or use pack()

Similar Messages

  • Ipad screen turns grey powering on and no apple logo appears! Help!  Reboot doesn't work.

    Help!  Reboot doesn't work.  Tried holding in the Sleep and Home buttons together for 10-15 secs to no avail!  I'm stuck in grey zone!

    The Basic Troubleshooting Steps are:
    Restart... Reset... Restore from Backup...  Restore as New...
    Restart / Reset   >  http://support.apple.com/kb/ht1430
    Restoring  >  http://support.apple.com/kb/HT1414
    If you try all these steps and you still have issues... Then a Visit to an Apple Store or AASP (Authorized Apple Service Provider) is the Next Step...
    Be sure to make an appointment first...

  • The inbox for Mac Mail lists every incoming message twice. When I delete a message it deleted both entries. I have tried the solution in "help" and it doesn't work. Any suggestions?

    The inbox for Mac Mail lists every incoming message twice. When I delete a message it deleted both entries. I have tried the solution in "help" and it doesn't work. Any suggestions?

    I am wondering if anyone is seeing my question? This is my first time and I am not sure if I am communicating correctly. If you are seeing the question above regading deleted messages reappearing please reply so I will at least know I am getting the message out.
    Thank you.

  • Help Refreshing JFrame, Validate not working...

    Hi,
    I've read many post suggesting that calling the JFrame.getContentPane().Validate() should refresh my JFrame and display the modifications made to the components on it, but it doesn't work for me. OK, so i'm creating a login screen where i want to hide 2 combos/2 labels, move the buttons and resize the frame when i click on a button (similar to the Windows Login screen where you can click "Options" to view the Domain Combo). When I hide my comtrols, works perfect, when i want to re-display them, the section of the frame that was hidden does not refresh what was behind it. The Option Button calls the ButtonOptionHandler() function, that's where the Validate() is executed.
    Here is the complete code for easier understanding, you can run it and see the effects:
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JTextField;
    import javax.swing.JPasswordField;
    import javax.swing.JButton;
    import javax.swing.JComboBox;
    import javax.swing.JPanel;
    import javax.swing.SwingConstants;
    import javax.swing.ImageIcon;
    import java.awt.event.*;
    public class screenLogin extends JFrame implements ActionListener {
    private static String OK = "OK";
    private static String CANCEL = "Cancel";
    private static String OPTION = "Option";
    private boolean showODBC = false;
         private JLabel lblUser;
         private JLabel lblPass;
         private JLabel lblOraODBC;
         private JLabel lblSqlODBC;
         private JTextField txtUser;
         private JPasswordField txtPass;
         private JComboBox cboOraODBC;
         private JComboBox cboSqlODBC;
         private JButton btnOK;
         private JButton btnCancel;
         private JButton btnOption;
         private JLabel lblImage;
         public screenLogin() {
              InitUI();
         private void InitUI() {
              this.setSize(400,230);
              this.getContentPane().setLayout(null);
              /* Labels */
              lblUser = new JLabel("NorLims User", SwingConstants.RIGHT);
              lblPass = new JLabel("Password", SwingConstants.RIGHT);
              lblOraODBC = new JLabel("Oracle ODBC", SwingConstants.RIGHT);
              lblSqlODBC = new JLabel("SQL Anywhere ODBC", SwingConstants.RIGHT);
              lblUser.setBounds(10, 65, 120, 23);
              lblPass.setBounds(10, 90, 120, 23);
              lblOraODBC.setBounds(10, 115, 120, 23);
              lblSqlODBC.setBounds(10, 140, 120, 23);
              txtUser = new JTextField();
              txtUser.setBounds(140, 65, 100, 20);
              txtPass = new JPasswordField();
              txtPass.setBounds(140, 90, 100, 20);
              txtPass.setEchoChar('*');
              cboOraODBC = new JComboBox();
              cboOraODBC.setBounds(140, 115, 200, 20);
              cboSqlODBC = new JComboBox();
              cboSqlODBC.setBounds(140, 140, 200, 20);
              btnOK = new JButton("OK");
              btnOK.setSize(80, 25);
              btnOK.setActionCommand(OK);
              btnOK.addActionListener(this);
              btnCancel = new JButton("Cancel");
              btnCancel.setSize(80, 25);
              btnCancel.setActionCommand(CANCEL);
              btnCancel.addActionListener(this);
              btnOption = new JButton("Options");
              btnOption.setSize(80, 25);
              btnOption.setActionCommand(OPTION);
              btnOption.addActionListener(this);
              // position Buttons and display labels/combos
              ButtonOptionHandler();
              // I commented this part since you dont have the login.jpg
              //lblImage = new JLabel(new ImageIcon("login.jpg"));
              //lblImage.setBounds(0, 0, 400, 60);
              this.getContentPane().add(lblUser, null);
              this.getContentPane().add(lblPass, null);
              this.getContentPane().add(lblOraODBC, null);
              this.getContentPane().add(lblSqlODBC, null);
              this.getContentPane().add(txtUser, null);
              this.getContentPane().add(txtPass, null);
              this.getContentPane().add(cboOraODBC, null);
              this.getContentPane().add(cboSqlODBC, null);
              this.getContentPane().add(btnOK, null);
              this.getContentPane().add(btnCancel, null);
              this.getContentPane().add(btnOption, null);
              //this.getContentPane().add(lblImage, null);
         public void actionPerformed(ActionEvent e) {
              String cmd = e.getActionCommand();
              if (OK.equals(cmd)) { //Process the OK Button
                   ButtonOkHandler();
              } else if (CANCEL.equals(cmd)) {
                   ButtonCancelHandler();
              } else if (OPTION.equals(cmd)) {
                   ButtonOptionHandler();
         private void ButtonOkHandler() {
              System.out.println("OK Button");
         private void ButtonCancelHandler() {
              System.out.println("Cancel Button");
              System.exit(0);
         private void ButtonOptionHandler() {
              showODBC = !showODBC;     // Toggle the value
              int top = (showODBC ? 165 : 115);          // determine the top for the buttons
              this.setSize(400, (showODBC ? 230 : 180));
              lblOraODBC.setVisible(showODBC);
              lblSqlODBC.setVisible(showODBC);
              cboOraODBC.setVisible(showODBC);
              cboSqlODBC.setVisible(showODBC);     
              btnOK.setLocation(100, top);
              btnCancel.setLocation(180, top);
              btnOption.setLocation(260, top);
              this.getContentPane().validate(); // This dont refresh ?!?
    I hope someone can help me with this!
    Thanks,
    XiNull

    First suggestion would be to use a layout manager. Then changing the visibility of components within the layout mgr will cause all the proper resizing, refreshing, etc. to happen for you. You should never have to call validate on your own like that (unless you are doing something really bizarre, which you aren't). Generally null or XY layout managers are more hassle than they are worth (and a maintenance nightmare). Do yourself a favor and learn to use gridbaglayout, etc. While a bit wacky to get used to, you will be glad you spent the time on it.

  • HELP, My SWF doesn´t work in latest versions of IE and Safari

    I have a swf made in Flash CS4. It works fine in firefox and older versions of flash player in IE, but it doesn't work in recent versions of IE and Safari In this case just I can hear the music.
    Could help me please, my URL is:
    http://www.quecolor.com.mx/UAT/

    Hi,
    Did you try embedding swf using SWFObject via JavaScript ? Here is more information on how to embed swf using swfobject. http://code.google.com/p/swfobject/wiki/documentation
    Thanks,
    Karthikeyan R.

  • Open new jframe doesn't work when put into jar

    I cant get my program to open up a new frame. When i run my program from netbeans it works fine but when i put it into an executable jar it doesn't work. I have three frames, Main, About and SelectLanguage. From Main i can create a new instance of this from this window but it wont open either of the other two. This is the code i use for all three. Please help.
    new About().show();please help.
    clarkie

    well, if that's the code you use for all three, and
    they are different classes, maybe you should call the
    right class name?
    The code you posted isn't helpful, and I can't begin
    to guess what you're doing wrong.nah, i use
    new Main().show();
    new About().show();
    new SelectLanguage().show();also, i get this error:
    java.lang.NoClassDefFoundError: org/netbeans/lib/awtextra/AbsoluteLayout
    at About.initComponents(About.java:29)
    at About.<init>(About.java:15)
    at Main.aboutMenuItemActionPerformed(Main.java:409)
    at Main.access$2200(Main.java:19)
    at Main$22.actionPerformed(Main.java:344)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknow
    n Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.AbstractButton.doClick(Unknown Source)
    at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
    at javax.swing.plaf.basic.BasicMenuItemUI$MouseInputHandler.mouseRelease
    d(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

  • Help, why keyRepeated doesn't work

    Hello,
    I created a class to extend GameCanvas in midp2.0. In this class, I overwrote "keyPressed ()","keyReleased()","keyRepeated()" three methods.
    "keyPressed ()","keyReleased()" both work very well to capture the key.
    But keyRepeated doesn't work. It looks it hasn't been called back by system.
    I used wtk2.0 DefaultColorPhone to test the code. Does the emulator not support KeyRepeated() ?
    Can anybody help me this?
    Thanks in advance.
    henry

    i not using wtk 2.0 but u can try hasRepeatEvents method to check the availability of repeat actions

  • Help, signatureValidate() function doesn't work on hidden fields

    I am trying to use the signatureValidate() function to check if any signature fields are signed. I am doing this because I need to have the signature fields lock the form manually so that a specific department can make changes after signatures have been applied (via a password field). I got the signature fields to lock the form and I can unlock everything with a password dialog. However, I am trying to add some code to the Change event so that if a user clears their signature and no other signatures have been applied, then the form will unlock. I wrote a script that checks the signature validation of each signature field to verify that all of them are unsigned, and it works perfectly until one of the signature fields becomes hidden. Then the code just doesn't work. Am I doing something wrong? Is there a way to check if a signature field (which may or may not be hidden) has been signed? Below is the code that I am using:
    var engMgrSig = event.target.getField("form1[0].Subform1[0].signatures[0].Eng_Manager[0].eng_manager_sign ature[0]").signatureValidate();
    var mfgMgrSig = event.target.getField("form1[0].Subform1[0].signatures[0].Mfg_Eng_Manager[0].mfg_engr_sig nature[0]").signatureValidate();
    if (mfgMgrSig == 0 && engMgrSig == 0)  {       
         oTargetField = this.resolveNode("ECO_table");
              oTargetField.access = "open";
    else {
         oTargetField = this.resolveNode("ECO_table");
              oTargetField.access = "readOnly";

    The fields are supposed to be hidden when the form is opened, but can be "added" (made visible) by the user to allow for additional signatures. I use hidden fields rather than a simple Add Instance because of data binding issues.
    I tried modifying the script to make the fields visible, fire the validation, and then hidden again, but for some reason it would either not work or it would make them visible after the first change and then hidden only if the field was changed again. Also, the code has to be able to recognize whether the fields were hidden before the code fired. If the were, they should be hidden afterwards. If they weren't then nothing needs to happen to them.
    I have tried using an IF statement to run a validation on the fields based on which ones are visible, but that doesn't seem to work either. Here is an example:
       // this field is always visible
        var status = event.target.getField("form1[0].Subform1[0].signatures_REV1[0].Eng_Manager[0].eng_manager _signature[0]").signatureValidate();
        var engMgrSig2 = event.target.getField("form1[0].Subform1[0].signatures_REV1[0].Eng_Manager2[0].eng_manage r_signature[0]").signatureValidate();
        var engMgrSig3 = event.target.getField("form1[0].Subform1[0].signatures_REV1[0].Eng_Manager3[0].eng_manage r_signature[0]").signatureValidate();
        // this field is always visible
        var mfgMgrSig1 = event.target.getField("form1[0].Subform1[0].signatures_REV1[0].Mfg_Eng_Manager[0].mfg_eng r_signature[0]").signatureValidate();
        var mfgMgrSig2 = event.target.getField("form1[0].Subform1[0].signatures_REV1[0].Mfg_Eng_Manager2[0].mfg_en gr_signature2[0]").signatureValidate();
        var mfgMgrSig3 = event.target.getField("form1[0].Subform1[0].signatures_REV1[0].Mfg_Eng_Manager3[0].mfg_en gr_signature3[0]").signatureValidate();
        //if all sig fields are visible
        if (this.resolveNode("signatures_REV1.Eng_Manager1").presence == "visible" && this.resolveNode("signatures_REV1.Eng_Manager3").presence == "visible" && this.resolveNode("signatures_REV1.Mfg_Eng_Manager2").presence == "visible" && this.resolveNode("signatures_REV1.Mfg_Eng_Manager3").presence == "visible") {
            if (status == 0 && mfgMgrSig1 == 0 && engMgrSig2 =0 && engMgrSig3 == 0 && mfgMgrSig2 == 0 && mfgMgrSig3 == 0)
                oTargetField = this.resolveNode("ECO_table");
                    oTargetField.access = "open";           
        //if eng_mgr2 is visible
        if (this.resolveNode("form1.Subform1.signatures_REV1.Eng_Manager2").presence = "visible" && this.resolveNode("form1.Subform1.signatures_REV1.Eng_Manager3").presence = "hidden" && this.resolveNode("form1.Subform1.signatures_REV1.Mfg_Eng_Manager2").presence = "hidden" && this.resolveNode("form1.Subform1.signatures_REV1.Mfg_Eng_Manager3").presence = "hidden") {
           if (status == 0 && mfgMgrSig1 == 0 && engMgrSig2 =0)
                oTargetField = this.resolveNode("ECO_table");
                    oTargetField.access = "open";

  • Simple example doesn't work when on two machines

    I have a simple RMI example that works when I run both the client piece and the server piece on one machine. However, when I seperate them to two different machines, it does not work. The client piece just sits and waits at this line:
    Calculator c = (Calculator)Naming.lookup("rmi://162.130.1.68/CalculatorService");I believe I don't need an HTTP server running on the "server" machine, but is there anything I need to setup on either machine? Do I need to start the rmi registry from a specific folder or put the server files in a specific folder? I've heard the term "network accessible" thrown arround. Do I need to make the files "network accessible?"

    The first thing I would do is what the previous poster said which refers to the term Network Accessible. The second thing I would do is remove "rmi:" in the lookup name. I've never seen that notation anywhere. The third thing I would do is make sure the rmi registry is started on the server. You can actually start it from inside the application like so: java.rmi.registry.LocateRegistry.createRegistry(java.rmi.registry.Registry.REGISTRY_PORT);
    Hope I've helped. Let me know how it works out.
    Dave

  • Help, My iPad Doesn't Work On iOs7

    I have neever been so unhappy with an upgrade as I am with iOs7. What a mess they made of everything. Why dod theyt have to re-invent the wheel? My Youtube doesn't work and surfing the internet went to a crawl. Can someone give me some advice on how to get the old software back?

    Hi David
    To be honest I am not sure what I updated from in my OS X All I do is agree to install when the automatic update says there is an update available for my Mac. I'm curious when we pay thousands of dollars to Apple for the best computer why we have to keep shelling out the clams to keep it running. What does the new update do that we have to pay for? I appreciate you telling me about it and I guess I need to know whaat it does. I'll try and find some reading on it.
    FIREFOX - I'm trying to decide what to run for a browser now. The reason I switched to Firefox is because it was said to be faster than Safari. I noticed also that when I view Youtube videos with Safari, we are bombarded with friggin commercials to no end.
    CHROME - I have been contemplating discarding my Google account because it seems Google wants to force us to go through them to access all my other accounts, and now they are getting to the point that when I try to open an account like Netflix or Facebook or other accounts, they try to force me to sign in with my Google account and they don't give me any other options. I am very upset as are many others with this communist turn Google has done. I don't want to change my email, but I may have no choice. I went into my Google account settings and chose to disconnect my other accounts from Google, but they still Hi-Jack my other accounts even when I choose not to connect them.
    Now this morning I noticed my Spell Check isn't working. I have it set to check spelling automatically in Language and Text.
    I have been trying to figure out how to check my version of Adobe Flash. Where can I find it to check it? It's not in my Applications folder like it's supposed to be. You're a little over my head with installing a control panel to install updates. I'll try going to Adobe.com/flashplayer andd try to update.
    I have power cycled my modem several times with no change. I am using Centurylink for my internet which is the worst I have ever seen for reliability. There aren't a lot of choices where I live. Every time I have trouble ith them and make the dreaded phone call to 611, they say there are no problems and want me to go through a barage of their stupid tests that never work because the problem is on their end. I think they over sell the service and at peak usage times the bandwidth is sucked dry.

  • Help! isight doesn't work in the morning, but work in the afternoon...

    Hi everyone, I am almost mad with my isight.....I found when I start the laptop in the morning, it doesn't work, it shows"there is no connected camera". But I keep using the laptop for several hours until the afternoon, then I open the isight, it turns out working as normal.....as long as I restarted, it doesn't work again, until waiting for several hours.....I tested these for several days....so strange.
    I tried all the ways mentioned in the "troublesome isight", none of them work. Should I reinstalled the systems or send it to the technical support?
    Thank you so much in advance for you replying!

    xiqing wrote:
    Hi everyone, I am almost mad with my isight.....I found when I start the laptop in the morning, it doesn't work, it shows"there is no connected camera". But I keep using the laptop for several hours until the afternoon, then I open the isight, it turns out working as normal.....as long as I restarted, it doesn't work again, until waiting for several hours.....I tested these for several days....so strange.
    I tried all the ways mentioned in the "troublesome isight", none of them work. Should I reinstalled the systems or send it to the technical support?
    Thank you so much in advance for you replying!
    Welcome to Discussions, xiqing
    I understand that you have tried all relevant suggestions from http://support.apple.com/kb/HT2090
    Restart your Mac and try the PMU/SMC reset one more time. If properly resetting your SMC does not resolve your problem, I think your problem you describe is a hardware one that will require professional service by your Apple-Authorized Service Provider.
    You could try reinstalling Snow Leopard and applying the 10.6.4 Combo Update, but I do not believe that either could resolve the problem you describe.
    *Be sure to backup all your important data files immediately before sending or taking your Mac for service*. When you retrieve your Mac after the work is complete, ask the AASP to show you that the camera is working before you leave the store.
    EZ Jim
    Mac Pro Quad Core (Early 2009) 2.93Ghz w/Mac OS X (10.6.4)  MacBook Pro (13 inch, Mid 2009) 2.26GHz (10.6.4)
    LED Cinema Display  G4 PowerBook  1.67GHz (10.4.11)  iBookSE 366MHz (10.3.9)  External iSight

  • Help: Force quit doesn't work

    Some error happens on my program and it freeze. So I force quit the program. It turned off. But when I reopen the program, error keep happens. I try restart, shut down, and reinstall program but it doesn't work. It happens to my firefox but somehow it works again. Now my flash program has this error and I can't fix this problem.. Anyone know what to do with this?

    no but I am getting similar problems with iTunes just started recently. IDK if it might have something to do with the latest update or something about using my external to play off of.

  • Adobe AIR help; breadcrum navigation doesn't work in multibyte characters?

    Hi there,
    I created Adobe application with RoboHelp 9 (using FrameMaker files,
    which are written in Japanese and English) to find that breadcrum navigation on the top doesn't work.
    Is this a feature that breadcrum navigation doesn't support multibyte characters? Or is this any workaround?
    Many thanks for your kind support in advance,

    See my reply to your other post. You can also test this in the new project and raise it with Adobe Support at the same time as the other problem.
    See www.grainge.org for RoboHelp and Authoring tips
    @petergrainge

  • Help! Trackpad doesn't work and keyboard sometimes does too

    I have Blackberry 9320 and it already has the latest software updates before these problems occured. My trackpad suddenly doesn't work, but it can click. And the weird thing is I can still move it up and down if I open the submenu. I repeat, only if I open the submenu.
    My keyboard also has some problems, when I type, it often misses some letters. For example if I type down "blackberry" it'll come out as "backbrry". So I have to erase and type it over again. Sometimes my keyboard just doesn't work at all, I can't type anything, even the non letter buttons such as the menu button doesn't work as well.
    I've tried hard restart and others, but it still didn't work. And actually I've faced the same problems a few months ago, but sadly I can't remember how I solved it at all.
    Thank you. I'm sorry if my English is pretty confusing because it's not my first languange.
     Update: I can move it up and down now if press the Alt button, but it's still different as it used to be

    Thanks for your reply. I've tried hard restart and I also had the OS re-installed, but it didn't work. I brought it to a service centre yesterday (not an official Blackberry Centre though), and the mechanic tried changing my trackpad with a new one, and cleaned my keyboard part (the one under the keytone). Those didn't give any effect too. He gave up and said maybe there's something wrong with my phone's IC and I must try bringing it to the Blackberry Centre. The problem is, the Blackberry Centre is really far from my campus and I don't have the time yet to go there, so I just want to try any possible ways to do by myself for now. Thanks.

  • Simple pass doesn't work after upgrading to Windows 10

    Hi all I just upgraded to Window's 10 (took 3 hours, works). However HP Simplepass now doesn't work. Anyone else with this problem? Brian

    Hi I fixed this issue using "Run programs made for previous versions of Windows" . BrianH15  

Maybe you are looking for

  • How to Disable edit option in Logon pad

    Hi, How to disable edit option in logon pad thanks

  • BB Error while sync with outlook

    Hi- Appreciate if you guys can help me in finding a solution! I am getting the following error while syncing with OutLook " error record with specific id error (FF1E892B) not found" I am using BB Tourch 9800! Rgds.

  • Import my iCal into Google Calendar

    The new Google software makes it easy to copy the Google Calendar into iCal but when I try to import my iCalendar into Google Calendar, I have to select a calendar. I have no idea which of the files in /Library/Calendars to select. How do I tell?

  • Basic L2 bridge troubleshooting ACE

    Hi, I have a strange behaviour on new ace module : I have a Dmz in bridge mode, I have installed a server on it with a simple web server, I first try to simple connect to this web server just being bridge between client and server. Sometimes it works

  • How to find the Last logon detail of a deleted user?

    I need to find the last logon detail of a deleted user.I have tried with SM20 i got the details,but i coildnt get for few users.Is there any other way to get this?