Discussion:
How to edit private method JButton ActionPerformed
lius90
2011-06-24 17:10:04 UTC
Permalink
Hi there,
im currently developing a GUI for my Bluetooth project using NetBeans 6.8

i have been evaluating this problem and find the solution on net for 3 days and i couldnt find any. Finally i got here.

my problem relies on:

I have created a JButton using the drag and drop, so i double click that button it will direct me to the source code that will look like this:

private void jButton1ActionPerformed1(java.awt.event.ActionEvent evt) {}

on this button i need to do some scanning to discover nearby bluetooth

so my discovery codes will go under this method, so the problem rise on the IOException, since this method is private i cant edit or input " throws IOException "

example that i want it to be like this:
private void jButton1ActionPerformed1(java.awt.event.ActionEvent evt) throws IOException{ codes }

or

public void jButton1ActionPerformed1(java.awt.event.ActionEvent evt) throws IOException{ codes }

So my question is how do i change this JButton actionperfomed become a public method instead of private. i already tried to change the variable of this JButton under the properties to public but it still showing a private method.

Thanks
gros_bidule
2011-06-24 23:21:38 UTC
Permalink
Hi,
methods that handle events should not be public and/or throw exceptions that are not related to UI.
You can add a public method that do what you want, and call it in the jButton1ActionPerformed1 method.
Loading...