Results 1 to 3 of 3
- 12-15-2008, 01:52 PM #1
Member
- Join Date
- Dec 2008
- Posts
- 28
- Rep Power
- 0
[SOLVED]Usual problem: cannot make a static....
Hello friends. Please, help me with this.
I simply need a login page. I created a button that will call patterns.Controlli.ConfermaLogin(campo_nome_utente , campo_password);
and Eclipse IDE returns me a Cannot make a static reference to the non-static method ConfermaLogin(JTextField,
JPasswordField) from the type Controlli
Here's my code:
Login.java
Here's patterns.Controlli.javaJava Code:private void tasto_confermaActionPerformed(ActionEvent evt) { System.out.println("registra.actionPerformed, event="+evt); patterns.Controlli.ConfermaLogin(campo_nome_utente, campo_password); }
and up above, this commandJava Code:public void ConfermaLogin(JTextField nome_utente, JPasswordField campo_password){ String testo_nome = nome_utente.getText(); String testo_password = ""; char[] char_pass = campo_password.getPassword(); testo_password = String.valueOf(char_pass); if (testo_nome.equals("") || (testo_password.equals(""))) { JOptionPane.showMessageDialog(null, "Bisogna inserire nome utente e password.", "Non hai inserito tutti i campi!", JOptionPane.WARNING_MESSAGE); } else { JOptionPane.showMessageDialog(null, "Ok.", "Campi inseriti!", JOptionPane.WARNING_MESSAGE ); GestInterfaccia.Accesso(testo_nome, testo_password); } }
return this error:Java Code:GestInterfaccia.Accesso(testo_nome, testo_password);
Cannot make a static reference to the non-static method Accesso(String, String) from the
type GestInterfaccia.
Here's GestInterfaccia.java
and returns me this error:Java Code:public void Accesso(String campo_nome, String campo_password) { patterns.BusinessDelegate.accesso(campo_nome, campo_password); }
Cannot make a static reference to the non-static method accesso(String, String) from the
type BusinessDelegate
and here's BusinessDelegate.java
I really can't understand how i can handle static and non-static. I know what does it mean, but i can't make it work.Java Code:public class BusinessDelegate { public void accesso(String campo_nome, String campo_password) { database.GestoreQuery.accesso(campo_nome, campo_password); } }
Somebody help me!
Sorry for the intrication, but... that's how i need, it's not a small program, so i need to make some calls.
Please make some examples with my code, so i can understand better, and finally i won't break you anymore :PLast edited by hendrix79; 12-15-2008 at 03:20 PM. Reason: Solved, thanks alot.
- 12-15-2008, 02:16 PM #2
I left out some bare essentials to focus on your central challenge....In short, we have to "declare an instance of a class" which is what the SomeClass sc = new SomeClass(); does, we then place the method names of that class directly up against the name of the class followed by a dot '.' - this occurs in another class, that is called an instance of that class.Java Code:class SomeClass{} class anotherClass { SomeClass sc = new SomeClass(); sc.doSomething(); }
The keyword static works without calling new, but it has to be everywhere one uses the class from a static context....
if not this help, ask further.Introduction to Programming Using Java.
Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor
- 12-15-2008, 03:19 PM #3
Member
- Join Date
- Dec 2008
- Posts
- 28
- Rep Power
- 0
Similar Threads
-
Static Vector Problem
By calicocal in forum New To JavaReplies: 12Last Post: 11-09-2008, 11:31 PM -
Please help, need to make my class static.
By sumak in forum New To JavaReplies: 1Last Post: 04-19-2008, 07:29 AM -
Explicit static initialization with the static clause
By Java Tip in forum java.langReplies: 0Last Post: 04-16-2008, 11:07 PM -
Error: Non-static method append(char) cannot be referenced from a static context
By paul in forum Advanced JavaReplies: 1Last Post: 08-07-2007, 05:05 AM -
Error: non-static variable height cannot be referenced from a static context at line
By fernando in forum AWT / SwingReplies: 1Last Post: 08-01-2007, 09:25 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks