Results 1 to 4 of 4

Thread: Popup JFrame

  1. #1
    BariMutation is offline Member
    Join Date
    Oct 2010
    Rep Power

    Default Popup JFrame

    Essentially, what I have is a very basic photoshop. A few of the features require some sort of pop up dialog that will display statistics for the image, or take input from the user to imply onto the image. Now, I have all the code written for actually working on the image itself (I've tested it and it works), but this is my first time working with JFrame and the like. That being said, I need a dialog to pop up when, for instance, the user clicks the Resize button and take input. That input then needs to be stored to a variable - from there, I have it.

    If it helps, I attached my code as a .txt document. I didn't just post it here because of how long it is...

    Thanks for any help!!!
    Attached Files Attached Files

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power


    If the code is too long to post in a forum, it's too long for me to be interested to go through. Recommended reading:
    How To Ask Questions The Smart Way
    SSCCE : Java Glossary
    How to Make Dialogs (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)
    and the rest of the Swing tutorial.


  3. #3
    BariMutation is offline Member
    Join Date
    Oct 2010
    Rep Power


    The tutorial actually did help a lot. I've gotten this far now;

    Java Code:
    JFrame brightenDiag = new JFrame ();
    brightenDiag.setSize(400, 200);
    brightenDiag.setTitle("Brighten Image");
    JPanel JPANEL_BD = new JPanel();
    JLabel JLABEL_BDL = new JLabel();
    JButton okButton = new JButton("OK");
    okButton.setBounds(0, 0, 75, 75);
    JLABEL_BDL.add("Enter a positive integer between 0 and 255 to increase the brightness.");
    JTextField inputLine1;

    But I keep getting an error saying that "JLABEL_BDL.add("Enter a positive integer between 0 and 255 to increase the brightness.");" isn't a variable, which I fully understand why. What I don't understand is how to create a static text field that says what I have in the quotes. I know the tutorial explained this, but I couldn't really follow.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power


    As Darryl suggests, you should create a small compilable program that we can run, test and modify that shows your problem, an SSCCE. If you post this, you'll likely get a helpful answer quickly. I have to ask why you are calling add on a JLabel? Please look at the API and you'll see that this is not what add is for, that you'll likely rarely if ever need to call this on a JLabel, and if you do call it on a JComponent, you don't pass a String into this method, but rather a Component. Perhaps you wanted to call setText(...) instead? I also see that it attempts to mix console with gui in a bad way. Get rid of all code that requires users to enter information on the console. Also, you will want to read up on how to use layout managers.

Similar Threads

  1. Replies: 5
    Last Post: 06-14-2010, 06:10 PM
  2. Replies: 4
    Last Post: 04-22-2009, 11:02 PM
  3. Closing Popup JFrame in Applet
    By Arsenic in forum Java Applets
    Replies: 3
    Last Post: 04-10-2009, 08:37 PM
  4. JTree Popup
    By jiexx in forum New To Java
    Replies: 1
    Last Post: 03-24-2009, 01:58 AM
  5. Communicating with JSP and popup
    By nilz in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 11-20-2007, 04:29 PM

Posting Permissions

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