aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Help needed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Help needed" Watch "Help needed" New topic
Author

Help needed

Boba Jeff
Greenhorn

Joined: Jul 05, 2011
Posts: 12
Hello ,

I am just start to explore jave world and i am a bit lost in it I am preaty much aware how much i dont know about it and i maybe can post some naive or stupid question ( like next text on this topic ) but i just wana to learn and to know how to make what i imagine for my self.


I have been instaled Netbeans and making some CRUD Application for my self.
All is going ok untill i got some idea to try to make better for my application.

Problem, on main panel i wana to make one button wich will show pop up form for entering a data to db. Problem is not in making a form it's on connecting him to that button. Baseline i dont know what to doo. I have search allmoust all tutorials and noone was help me to achive what i wana.

In netbeans i make new form and design him as i wanted but i cant find the way to make him connected to button. I have try to copy code whit slight change to make similar as Aboutbox but that wasnt succesfull.

I have posting here becouse i am reading maybe for week and i dont geting to any progres what so ever. If anyone could tell me what to doo will be splendid.

Ty for your time, cheers.
Greg Reeder
Ranch Hand

Joined: Jun 14, 2011
Posts: 99

I have not worked with NetBeans so far, so i do not know if I can be of much help. What have you tried so far? Do you have a code example that might help?
Boba Jeff
Greenhorn

Joined: Jul 05, 2011
Posts: 12
I have take this code from Aboutbox

@Action
public void showAboutBox() {
if (aboutBox == null) {
JFrame mainFrame = DesktopApplication6.getApplication().getMainFrame();
aboutBox = new DesktopApplication6AboutBox(mainFrame);
aboutBox.setLocationRelativeTo(mainFrame);
}
DesktopApplication6.getApplication().show(aboutBox);
}


And i am change to this.



@Action
public void NewForm() {
if (NewForm == null) {
JFrame mainFrame = DesktopApplication6.getApplication().getMainFrame();
NewForm = new DesktopApplication6AboutBox(mainFrame);
NewForm.setLocationRelativeTo(mainFrame);
}
DesktopApplication6.getApplication().show(NewForm);
}
Boba Jeff
Greenhorn

Joined: Jul 05, 2011
Posts: 12
Blargh, i got some hunch that i am doing something wrong. i got confused about connecting main frame and ok/cansel dialog box.

Boba Jeff
Greenhorn

Joined: Jul 05, 2011
Posts: 12
Ok after some time i spend at code i make this one whit some problems as well :P



@Action
public void showAboutBox() {
if (aboutBox == null) {
JFrame mainFrame = DesktopApplication6.getApplication().getMainFrame();
aboutBox = new DesktopApplication6AboutBox(mainFrame);
aboutBox.setLocationRelativeTo(mainFrame);
}
DesktopApplication6.getApplication().show(aboutBox);
}

@Action
public void showNpop() {
if (Npop == null) {
JFrame mainFrame = DesktopApplication6.getApplication().getMainFrame();
Npop = new Npop(mainFrame);
Npop.setLocationRelativeTo(mainFrame); // At this line show error "cant find the symbol"
}
DesktopApplication6.getApplication().show(Npop); //error on this line "Not suitable method found for show
}
Boba Jeff
Greenhorn

Joined: Jul 05, 2011
Posts: 12
For some time reading the tutorial site and runing in NB i have make some work what i need.

I use this step by step post and got my own pop up.


Now, how to do that in NetBeans.
1, Create the two JFrames, lets call them FirstFrame.java and
SecondFrame.java.
2, Drag a Button from the Pallete to the FirstFrame (in the GUI designer)
3, Select the Button and in the Properties window (on the right side of the
screen by default, or using right-click menu of the Button) click on
"Events"
4, Now, select the line with 'actionPerformed' and pres the [...] button on
right side -> Handlers dialog should open
5, Add new Handler and name it as you wish (e.g. "openFrame"). Now hit OK
and you will find yourself in source code of the FirstFrame.java.
6, you should see a method called "openFrame", and you can edit it's body
(the surrounding lines have grey background as they are not editable).
Simply write there:
new SecondFrame().setVisible(true);

And that's it! Simple as that. Now if you run the FirstFrame, you should see
your Button and after clicking it, the SecondFrame appears.

You can now explore the code of the FirstFrame a bit. If you expand the
Generated code, you will see that NB prepared the Listener I was talking
about at the beginning automatically. It is the line with
"jButton1.addActionListener..." . You see that the Listener call your method
(handler) called "openFrame".
And that is the whole magic
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help needed
 
Similar Threads
I wanted to aks this: How much code You can write without testing?
From database to form and vice virsa
I hate my tech lead....
Java application Microsoft SQL server
How to set icon at net beans