Forums Register Login

Help needed

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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?
+Pie Number of slices to send: Send
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);
}

 
+Pie Number of slices to send: Send
Blargh, i got some hunch that i am doing something wrong. i got confused about connecting main frame and ok/cansel dialog box.

+Pie Number of slices to send: Send
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
}

 
+Pie Number of slices to send: Send
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

 
That feels good. Thanks. Here's a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1004 times.
Similar Threads
How to set icon at net beans
From database to form and vice virsa
mail notifications
javac doesn't make any class
cursor mouse trails for applets
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 22:57:46.