File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to build a frame ?

 
Vitor Mateucci
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi so i wrote this program
So i am wondering how would i go about building a small frame around this to make it look more like an applet?(i think this is the right term??) i just want a small little program where i can have a little boxes where i plug in the variables b,c,d.
 
Maneesh Godbole
Saloon Keeper
Posts: 10976
11
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
 
Rob Camick
Ranch Hand
Posts: 2476
8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Applets can't read from the keyboard.

You want to create an application so you should start with How to Make Frames.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47300
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to our GUIs forum.
 
Vitor Mateucci
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Camick wrote:Applets can't read from the keyboard.

You want to create an application so you should start with How to Make Frames.


Hi,

Thanks for the link i was able to make a blank frame but i still dont understand,

how would i go about adding my program to the frame?
 
Campbell Ritchie
Sheriff
Pie
Posts: 47300
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java Foo "Campbell\'s GUI"

There is an error hidden somewhere in that code. It isn’t intentional, but rather than correcting it, I’ll let you find it for yourself. Don’t anybody else tell him
 
Rob Camick
Ranch Hand
Posts: 2476
8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You wouldn't add your program to the frame. Working with a GUI is different than working with the keyboard.

For example you might use a JOptionPane to prompt the user for data. Then once the user enters all the data you might use a JLabel to display the data.

Or you can create a simple JDialog that contains 3 JTextFields where the user can enter all 3 pieces of information at one time.

Read the tutorial and start playing with the different Swing components. Every section in the tutorial comes with working examples that you can download and test.
 
Vitor Mateucci
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:java Foo "Campbell\'s GUI"

There is an error hidden somewhere in that code. It isn’t intentional, but rather than correcting it, I’ll let you find it for yourself. Don’t anybody else tell him


Isn't the error on line 17 where you put a ) instead of a }
 
Vitor Mateucci
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Camick wrote:You wouldn't add your program to the frame. Working with a GUI is different than working with the keyboard.

For example you might use a JOptionPane to prompt the user for data. Then once the user enters all the data you might use a JLabel to display the data.

Or you can create a simple JDialog that contains 3 JTextFields where the user can enter all 3 pieces of information at one time.

Read the tutorial and start playing with the different Swing components. Every section in the tutorial comes with working examples that you can download and test.


Ohhh ok i am starting to understand it now but then where would i put the arithmetic?
 
Campbell Ritchie
Sheriff
Pie
Posts: 47300
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vitor Mateucci wrote: . . . Isn't the error on line 17 where you put a ) instead of a }
No. That ) matches the ( after invokeLater. The error is something different. And the ... ellipses don’t count.
 
Rob Camick
Ranch Hand
Posts: 2476
8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You put the arithmetic in the same place you put it before.

Before you prompted the user for input and got the value the user typed. Once you have all the values you did the arithmetic.

This is the same. The difference is that you are promting the user for input from a GUI, instead of the console.
 
Vitor Mateucci
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Camick wrote:You put the arithmetic in the same place you put it before.

Before you prompted the user for input and got the value the user typed. Once you have all the values you did the arithmetic.

This is the same. The difference is that you are promting the user for input from a GUI, instead of the console.


Ohh i understand now thank you,

I'll try posting up the final code once i finish
 
Vitor Mateucci
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:
Vitor Mateucci wrote: . . . Isn't the error on line 17 where you put a ) instead of a }
No. That ) matches the ( after invokeLater. The error is something different. And the ... ellipses don’t count.


Is it the extra = ?
 
Campbell Ritchie
Sheriff
Pie
Posts: 47300
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No.

But at least you have found the line with the error.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47300
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a second error, but it will become obvious if you try to run my code; the compiler error will tell you everything.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47300
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shall I let you out of your misery?

  • When I tried to compile it, I had to change the args array to final. That is standard when a local variable or parameter is used by an anonymous class.
  • If you have args.length == 0, all is well. But if you pass a 1-element args array, you will get an Exception for args[1]. That should of course read args[0].
  •  
    I agree. Here's the link: http://aspose.com/file-tools
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic