Results 1 to 4 of 4
Thread: Popup JFrame
- 12-04-2010, 03:20 AM #1
Member
- Join Date
- Oct 2010
- Posts
- 22
- Rep Power
- 0
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!!!
- 12-04-2010, 04:21 AM #2
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.
db
- 12-04-2010, 04:52 AM #3
Member
- Join Date
- Oct 2010
- Posts
- 22
- Rep Power
- 0
The tutorial actually did help a lot. I've gotten this far now;
Java Code:JFrame brightenDiag = new JFrame (); brightenDiag.setSize(400, 200); brightenDiag.setResizable(false); brightenDiag.setTitle("Brighten Image"); brightenDiag.setVisible(true); JPanel JPANEL_BD = new JPanel(); brightenDiag.add(JPANEL_BD,BorderLayout.SOUTH); JLabel JLABEL_BDL = new JLabel(); brightenDiag.add(JLABEL_BDL,BorderLayout.NORTH); JButton okButton = new JButton("OK"); okButton.setBounds(0, 0, 75, 75); okButton.addActionListener(this); JPANEL_BD.add(okButton); JLABEL_BDL.add("Enter a positive integer between 0 and 255 to increase the brightness."); JTextField inputLine1; JPANEL_BD.add(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.
-
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
-
to pass a parameter from a jframe children to its jframe mother
By anix in forum NetBeansReplies: 5Last Post: 06-14-2010, 06:10 PM -
How to make a Jframe un-focusable when another Jframe is active?
By Robert_85 in forum Advanced JavaReplies: 4Last Post: 04-22-2009, 11:02 PM -
Closing Popup JFrame in Applet
By Arsenic in forum Java AppletsReplies: 3Last Post: 04-10-2009, 08:37 PM -
JTree Popup
By jiexx in forum New To JavaReplies: 1Last Post: 03-24-2009, 01:58 AM -
Communicating with JSP and popup
By nilz in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 11-20-2007, 04:29 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks