Home arrow static arrow Java Programming [Archive] - JFrame problem
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - JFrame problem
This topic has 5 replies on 1 page.

Posts:8
Registered: 8/8/04
JFrame problem  
Aug 8, 2004 11:40 AM



 
I've got this problem:

symbol : constructor Loginscherm ()
location: class Loginscherm
frame2 = new Loginscherm();

Here are my three classes:

------------------------------------Hoofdklasse-----------------------------
import java.awt.Dimension;
/* Generated by Together */

public class Hoofdklasse {
public static void main(String[] argv)
{
Hoofdscherm frame1 = new Hoofdscherm();
Dimension d = frame1.getToolkit().getScreenSize();
frame1.setSize(800,600);
frame1.setLocation(d.width/2-400 , d.height/2-300);
frame1.setVisible(true);
}
}

-------------------------------------------Hoofdscherm----------------------------
/* Generated by Together */
import javax.swing.JFrame;
import java.awt.event.WindowEvent;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JMenuBar;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JLabel;
import javax.swing.JButton;
import java.awt.Dimension;

public class Hoofdscherm extends JFrame
{

/** Creates new form JFrame */
public Hoofdscherm() {

initGUI();
pack();
}

/** This method is called from within the constructor to initialize the form. */
private void initGUI() {
addWindowListener(
new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
exitForm(evt);
}
});

getContentPane().setBackground(new java.awt.Color(0,0,0));
getContentPane().setLayout(null);
getContentPane().add(lblInvoeren);
getContentPane().add(lblAanvullen);
getContentPane().add(lblWegnemen);
getContentPane().add(btnInvoeren);
getContentPane().add(btnAanvullen);
getContentPane().add(btnWegnemen);
getContentPane().add(btnLogin);
getContentPane().add(btnLogout);
setResizable(false);
setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
setTitle("Beheerprogramma textielgrondstoffen");
// setSize(new java.awt.Dimension(800, 600)); // moet nog weg

//menu
beheer = new JMenu("Beheer");
help = new JMenu("Help");

//menuitems
keuze1 = new JMenuItem("Afbeeldingen van de rekken");
keuze2 = new JMenuItem("Invoeren van een nieuwe plaatsomschrijving");
keuze3 = new JMenuItem("Totaal overzicht van de stock");
keuze4 = new JMenuItem("Overzicht per rek");
keuze5 = new JMenuItem("Overzicht van de weggenomen grondstoffen");
keuze6 = new JMenuItem("Help");
keuze7 = new JMenuItem("Credits");
keuze8 = new JMenuItem("Sluiten");

//mnemonics
beheer.setMnemonic('B');
help.setMnemonic('H');
keuze1.setMnemonic('A');
keuze2.setMnemonic('I');
keuze3.setMnemonic('T');
keuze4.setMnemonic('O');
keuze5.setMnemonic('v');
keuze6.setMnemonic('e');
keuze7.setMnemonic('C');
keuze8.setMnemonic('S');

//submenus toevoegen
beheer.add(keuze1);
beheer.add(keuze2);
beheer.add(keuze3);
beheer.add(keuze4);
beheer.add(keuze5);
beheer.addSeparator();
beheer.add(keuze8);
help.add(keuze6);
help.addSeparator();
help.add(keuze7);

//menubar opbouwen
bar = new JMenuBar();
setJMenuBar(bar);
setBounds(new java.awt.Rectangle(0,0,610,473));
bar.add(beheer);
bar.add(help);

keuze8.addActionListener( new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
System.exit(0);
}
}

);

lblInvoeren.setText("");
lblInvoeren.setBounds(new java.awt.Rectangle(135, 77, 262, 29));
lblInvoeren.setSize(new java.awt.Dimension(262,29));
lblInvoeren.setIcon(new javax.swing.ImageIcon("wiki/./src/afbeeldingen/invoeren.jpg"));

lblAanvullen.setText("");
lblAanvullen.setBounds(new java.awt.Rectangle(49, 214, 348, 27));
lblAanvullen.setSize(new java.awt.Dimension(348,27));
lblAanvullen.setIcon(new javax.swing.ImageIcon("wiki/./src/afbeeldingen/aanvullen.JPG"));

lblWegnemen.setText("");
lblWegnemen.setBounds(new java.awt.Rectangle(182, 365, 215, 29));
lblWegnemen.setSize(new java.awt.Dimension(215,29));
lblWegnemen.setIcon(new javax.swing.ImageIcon("wiki/./src/afbeeldingen/wegnemen.jpg"));

btnInvoeren.setText("");
btnInvoeren.setBounds(new java.awt.Rectangle(445, 55, 49, 70));
btnInvoeren.setIcon(new javax.swing.ImageIcon("wiki/./src/afbeeldingen/btnBobijn.jpg"));
btnInvoeren.setBorder(javax.swing.BorderFactory.createEmptyBorder());
btnInvoeren.setPressedIcon(new javax.swing.ImageIcon("wiki/./src/afbeeldingen/btnBobijnPr.JPG"));
btnInvoeren.setRolloverIcon(new javax.swing.ImageIcon("wiki/./src/afbeeldingen/btnBobijnRo.JPG"));

btnAanvullen.setText("");
btnAanvullen.setBounds(new java.awt.Rectangle(445, 191, 49, 70));
btnAanvullen.setIcon(new javax.swing.ImageIcon("wiki/./src/afbeeldingen/btnBobijn.jpg"));
btnAanvullen.setBorder(javax.swing.BorderFactory.createEmptyBorder());
btnAanvullen.setPressedIcon(new javax.swing.ImageIcon("wiki/./src/afbeeldingen/btnBobijnPr.JPG"));
btnAanvullen.setRolloverIcon(new javax.swing.ImageIcon("wiki/./src/afbeeldingen/btnBobijnRo.JPG"));

btnWegnemen.setText("");
btnWegnemen.setBounds(new java.awt.Rectangle(445, 343, 49, 70));
btnWegnemen.setIcon(new javax.swing.ImageIcon("wiki/./src/afbeeldingen/btnBobijnX.JPG"));
btnWegnemen.setBorder(javax.swing.BorderFactory.createEmptyBorder());
btnWegnemen.setPressedIcon(new javax.swing.ImageIcon("wiki/./src/afbeeldingen/btnBobijnXPr.JPG"));
btnWegnemen.setRolloverIcon(new javax.swing.ImageIcon("wiki/./src/afbeeldingen/btnBobijnXRo.JPG"));

btnLogin.setText("");
btnLogin.setBounds(new java.awt.Rectangle(612, 1, 179, 100));
btnLogin.setBorder(javax.swing.BorderFactory.createEmptyBorder());
btnLogin.setRolloverIcon(new javax.swing.ImageIcon("wiki/./src/afbeeldingen/btnLoginRo.JPG"));
btnLogin.setIcon(new javax.swing.ImageIcon("wiki/./src/afbeeldingen/btnLogin.JPG"));
btnLogin.setPressedIcon(new javax.swing.ImageIcon("wiki/./src/afbeeldingen/btnLoginPr.JPG"));

btnLogout.setText("Logout");
btnLogout.setBounds(new java.awt.Rectangle(713, 112, 77, 20));
btnLogout.setBorder(javax.swing.BorderFactory.createEtchedBorder());

btnLogin.addActionListener(new ActionListener()
{ public void actionPerformed(ActionEvent e)
{
frame2 = new Loginscherm(); //===> here seems to be the problem
frame2.setSize(460,300);
Dimension d = frame2.getToolkit().getScreenSize();
frame2.setLocation(d.width/2-230 , d.height/2-150);
frame2.setVisible(true);

}});
}

/** Exit the Application */
private void exitForm(WindowEvent evt) {
System.exit(0);
}

private Loginscherm frame2;
private JMenu beheer, help;
private JMenuItem keuze1, keuze2, keuze3, keuze4, keuze5, keuze6, keuze7, keuze8;
private JMenuBar bar;
private JLabel lblInvoeren = new JLabel();
private JLabel lblAanvullen = new JLabel();
private JLabel lblWegnemen = new JLabel();
private JButton btnInvoeren = new JButton();
private JButton btnAanvullen = new JButton();
private JButton btnWegnemen = new JButton();
private JButton btnLogin = new JButton();
private JButton btnLogout = new JButton();
}

--------------------------------------------------Loginscherm--------------------------
import domeinklassen.Beheerder;
import javax.swing.JFrame;
import java.awt.event.WindowEvent;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JPasswordField;
import javax.swing.JButton;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;

public class Loginscherm extends JFrame {
/** Creates new form JFrame */
public Loginscherm(Hoofdscherm p) {
initGUI();
pack();
beheerder = new Beheerder();
parent=p;
}

/** This method is called from within the constructor to initialize the form. */
private void initGUI() {
addWindowListener(
new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
exitForm(evt);
}
});

getContentPane().setBackground(new java.awt.Color(0,0,0));
getContentPane().setLayout(null);
getContentPane().add(lblUserID);
getContentPane().add(lblPaswoord);
getContentPane().add(txtUserID);
getContentPane().add(ptxtPaswoord);
getContentPane().add(btnOK);
getContentPane().add(btnAnnuleren);
setResizable(false);
setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
setTitle("Login");
setSize(new java.awt.Dimension(460,300));//moet nog weg

lblUserID.setText("");
lblUserID.setBounds(new java.awt.Rectangle(75, 52, 144, 48));
lblUserID.setIcon(new javax.swing.ImageIcon("wiki/./src/afbeeldingen/userid.jpg"));
lblUserID.setLabelFor(txtUserID);
lblPaswoord.setText("");
lblPaswoord.setBounds(new java.awt.Rectangle(36, 138, 183, 48));
lblPaswoord.setIcon(new javax.swing.ImageIcon("wiki/./src/afbeeldingen/paswoord.jpg"));
lblPaswoord.setLabelFor(ptxtPaswoord);
txtUserID.setText("");
txtUserID.setBounds(new java.awt.Rectangle(292, 67, 100, 20));
txtUserID.setToolTipText("Geef een correcte loginnaam in.");
ptxtPaswoord.setText("");
ptxtPaswoord.setBounds(new java.awt.Rectangle(292, 153, 100, 20));
ptxtPaswoord.setToolTipText("Geef het bijhorende correcte paswoord in.");

btnOK.setText("");
btnOK.setBounds(new java.awt.Rectangle(190, 216, 77, 48));
btnOK.setIcon(new javax.swing.ImageIcon("wiki/./src/afbeeldingen/ok.jpg"));
btnOK.setRolloverIcon(new javax.swing.ImageIcon("wiki/./src/afbeeldingen/okRo.JPG"));
btnOK.setPressedIcon(new javax.swing.ImageIcon("wiki/./src/afbeeldingen/okPr.JPG"));
btnOK.setBorder(javax.swing.BorderFactory.createEmptyBorder());

btnOK.addActionListener(new ActionListener()
{ public void actionPerformed(ActionEvent e)
{
String userID = txtUserID.getText();
char[] pasWoord = ptxtPaswoord.getPassword();
String paswoord = String.valueOf(pasWoord);

if (userID.length()==0 || paswoord.length() ==0)
{
JOptionPane.showMessageDialog(null,"Voer zowel een UserID als een paswoord in","Onvolledige invoer",JOptionPane.ERROR_MESSAGE);
txtUserID.setText("");
ptxtPaswoord.setText("");
txtUserID.requestFocus();
}
else
{
String u = beheerder.getUserId();
String p = beheerder.getPaswoord();

if (u.equals(userID) && p.equals(paswoord))
{

}
else
{
JOptionPane.showMessageDialog(null,"Het ingevoerde userID of paswoord was incorrect. Probeer opnieuw.","Foutieve invoer",JOptionPane.ERROR_MESSAGE);
txtUserID.setText("");
ptxtPaswoord.setText("");
txtUserID.requestFocus();
}
}
}});


btnAnnuleren.setText("Annuleren");
btnAnnuleren.setBounds(new java.awt.Rectangle(374, 231, 73, 27));
btnAnnuleren.setBorder(javax.swing.BorderFactory.createEtchedBorder());

btnAnnuleren.addActionListener(new ActionListener()
{ public void actionPerformed(ActionEvent e)
{
dispose();
parent.setSize(800,600);
parent.setVisible(true);
}});

}

/** Exit the Application */
private void exitForm(WindowEvent evt) {
System.exit(0);
}

private Beheerder beheerder;
private Hoofdscherm parent;
private JLabel lblUserID = new JLabel();
private JLabel lblPaswoord = new JLabel();
private JTextField txtUserID = new JTextField();
private JPasswordField ptxtPaswoord = new JPasswordField();
private JButton btnOK = new JButton();
private JButton btnAnnuleren = new JButton();
}



Can anyone please help. I tried everything.
Sorry that it's in dutch btw.
Thanks in advance.
 

Posts:18,384
Registered: 21.03.00
Re: JFrame problem  
Aug 8, 2004 11:45 AM (reply 1 of 5)



 
Hi,

What is your question? And please, next time you post code, use the formatting tags, http://forum.java.sun.com/features.jsp#Formatting

/Kaj
 

Posts:8
Registered: 8/8/04
Re: JFrame problem  
Aug 8, 2004 11:48 AM (reply 2 of 5)



 
Sorry about that. My first time on this forum. Next time it will be better :)
About my question: It simply doesn't work. I think i did everything right but i still have that error.
If someone could take a look at it, its probably a stupid little fault.
 

Posts:18,384
Registered: 21.03.00
Re: JFrame problem  
Aug 8, 2004 11:59 AM (reply 3 of 5)



 
Hi,

Loginscherm does not have a constuctor that takes no arguments. The constructor for Loginscherm is:
   public Loginscherm(Hoofdscherm p) 


/Kaj
 

Posts:8
Registered: 8/8/04
Re: JFrame problem  
Aug 8, 2004 12:10 PM (reply 4 of 5)



 
hi,
Sorry but i dont understand it.
That already stands there like that.
 

Posts:18,384
Registered: 21.03.00
Re: JFrame problem  
Aug 8, 2004 12:12 PM (reply 5 of 5)



 
Hi,

You got a compilation error at the line:
 frame2 = new Loginscherm();


because there isn't anything called Loginscherm without an argument. You need to pass a Hoofdscherm to the constuctor.

/Kaj
 
This topic has 5 replies on 1 page.