Results 1 to 13 of 13
  1. #1
    Geraldo is offline Member
    Join Date
    Jun 2010
    Posts
    7
    Rep Power
    0

    Default dispose(); not working

    Hello everybody,

    Can anybody tell me why in this code this dispose();

    int ID6 = rs14.getInt("Bedrijf_ID");

    if (rs14 != null) {
    Hoofdscherm2 = new Hoofdscherm2(conn);
    Hoofdscherm2.setVisible(true);
    dispose();

    }

    .... isn't working?

    I hope somebody can help me it's a bit urgent.
    thanks in advanced


    public class Hoofdscherm extends JFrame implements ActionListener {

    private Container container;
    private JButton btnGBR, btnPL, btnGER, btnNL, btnCZ;
    public JButton lubtn;
    private JLabel lbl, wnlbl, datelbl, wslbl;
    private JTable tbl, tb2, tb3, tb4, tb5, tb6;
    private JPanel pnl, pn2, pn3, pn4, pn5, pn6, pn7;
    private JScrollPane pndata, pndata2, pndata3, pndata4, pndata5, pndata6;
    private ImageIcon GBR, PL, GER, NL, CZ, FHSlogo;
    private Locale CurrentLocale;
    private ResourceBundle messages;
    private JMenuBar bar;
    private BorderLayout layout;
    public Connection conn;
    ResultSetMetaData md, md1, md2, md3, md4, md6, md7, md8, md9, md10, md11, md12, md13, md14, md15;
    Vector vector1, vector7, columns7, vector9, row9, columns9, columns11, vector11, vector13, row13, row14;
    Vector row, columns, columns4, vector4, vector, row1, row4, row7, columns1, row11, columns13, columns14, vector14;
    PreparedStatement ps, ps1, ps2, ps3, ps4, ps6, ps7, ps8, ps9, ps10, ps11, ps12, ps13, ps14, ps15;
    Statement stmt, stmt1;
    ResultSet rs, rs1, rs2, rs3, rs4, rs6, rs7, rs8, rs9, rs10, rs11, rs12, rs13, rs14, rs15;
    String language = new String();
    String Werknemer_ID;
    String Werknemer_Naam;
    private Hoofdscherm2 Hoofdscherm2;
    private Hoofdscherm Hoofdscherm;

    public Hoofdscherm(Connection conn) {

    this.conn = conn;
    setTitle("Hoofdscherm");
    setResizable(false);
    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
    setSize(dim);
    setUndecorated(true);
    setDefaultCloseOperation(WindowConstants.DO_NOTHIN G_ON_CLOSE);
    Color background1 = new Color(232, 232, 232);

    CurrentLocale = new Locale(language);
    messages = ResourceBundle.getBundle("GUI/Properties/MessagesBundle", CurrentLocale);


    Werknemer_ID = new String(LoginForm.txtUser.getText());
    container = getContentPane();
    layout = new BorderLayout();
    container.setLayout(layout);


    pnl = new JPanel();
    pnl.setLayout(new BorderLayout());
    container.add(pnl, BorderLayout.NORTH);

    pn3 = new JPanel();
    FHSlogo = new ImageIcon("/Users/Gerard/NetBeansProjects/WerkplanningWebviewer/src/GUI/resources/logoFHSapp.jpg");
    lbl = new JLabel();
    lbl.setIcon(FHSlogo);
    pn3.add(lbl);
    pnl.add(pn3, BorderLayout.LINE_START);

    pn2 = new JPanel();
    pn2.setLayout(new FlowLayout());
    pnl.add(pn2, BorderLayout.LINE_END);

    pnl.setBackground(background1);
    pn2.setBackground(background1);
    pn3.setBackground(background1);

    // waarschuwing meerdere bedrijven label
    wslbl = new JLabel(" LET OP!!! JE WERKT BIJ 2 BEDRIJVEN!!!");
    wslbl.setFont(new Font("", Font.PLAIN, 20));
    wslbl.setForeground(Color.red);

    // query auto tabel 1
    try {
    String auto = ("SELECT Bedrijf.Bedrijf_ID FROM Bedrijf " +
    "INNER JOIN Opdracht ON Bedrijf.Bedrijf_ID = Opdracht.Bedrijf_ID " +
    "INNER JOIN OpdrachtWerknemer ON Opdracht.Opdracht_ID = OpdrachtWerknemer.Opdracht_ID " +
    "INNER JOIN Werknemer ON OpdrachtWerknemer.Werknemer_ID = Werknemer.Werknemer_ID " +
    "WHERE Werknemer.Werknemer_ID = " + Werknemer_ID + " ");

    ps8 = conn.prepareStatement(auto);
    rs8 = ps8.executeQuery();
    md8 = rs8.getMetaData();

    rs8.next();
    int ID8 = rs8.getInt("Bedrijf_ID");

    String tblA1 = ("SELECT Auto.Auto_ID, Auto.Auto_Kenteken, Auto.Auto_Personen, Auto.Auto_Locatie FROM Auto " +
    "INNER JOIN OpdrachtAuto ON Auto.Auto_ID = OpdrachtAuto.Auto_ID " +
    "INNER JOIN Opdracht ON OpdrachtAuto.Opdracht_ID = Opdracht.Opdracht_ID " +
    "INNER JOIN Bedrijf ON Opdracht.Bedrijf_ID = Bedrijf.Bedrijf_ID " +
    "WHERE Bedrijf.Bedrijf_ID = '" + ID8 + "'");

    ps9 = conn.prepareStatement(tblA1);
    rs9 = ps9.executeQuery();
    md9 = rs9.getMetaData();

    int Count9 = md9.getColumnCount();

    columns9 = new Vector(Count9);

    for (int i = 1; i <= Count9; i++) {
    columns9.add(md9.getColumnName(i));
    }
    vector9 = new Vector();

    while (rs9.next()) {
    row9 = new Vector(Count9);
    for (int i = 1; i <= Count9; i++) {
    row9.add(rs9.getString(i));
    }
    vector9.add(row9);
    }

    } catch (Exception e) {
    }


    // query auto tabel 2
    try {
    String auto2 = ("SELECT Bedrijf.Bedrijf_ID FROM Bedrijf " +
    "INNER JOIN Opdracht ON Bedrijf.Bedrijf_ID = Opdracht.Bedrijf_ID " +
    "INNER JOIN OpdrachtWerknemer ON Opdracht.Opdracht_ID = OpdrachtWerknemer.Opdracht_ID " +
    "INNER JOIN Werknemer ON OpdrachtWerknemer.Werknemer_ID = Werknemer.Werknemer_ID " +
    "WHERE Werknemer.Werknemer_ID = " + Werknemer_ID + " ");

    ps3 = conn.prepareStatement(auto2);
    rs3 = ps3.executeQuery();
    md3 = rs3.getMetaData();
    rs3.next();
    rs3.next();
    int ID8 = rs3.getInt("Bedrijf_ID");

    String tblA2 = ("SELECT Auto.Auto_ID, Auto.Auto_Kenteken, Auto.Auto_Personen, Auto.Auto_Locatie FROM Auto " +
    "INNER JOIN OpdrachtAuto ON Auto.Auto_ID = OpdrachtAuto.Auto_ID " +
    "INNER JOIN Opdracht ON OpdrachtAuto.Opdracht_ID = Opdracht.Opdracht_ID " +
    "INNER JOIN Bedrijf ON Opdracht.Bedrijf_ID = Bedrijf.Bedrijf_ID " +
    "WHERE Bedrijf.Bedrijf_ID = '" + ID8 + "'");

    ps4 = conn.prepareStatement(tblA2);
    rs4 = ps4.executeQuery();
    md4 = rs4.getMetaData();

    int Count4 = md4.getColumnCount();

    columns4 = new Vector(Count4);

    for (int i = 1; i <= Count4; i++) {
    columns4.add(md4.getColumnName(i));
    }
    vector4 = new Vector();

    while (rs4.next()) {
    row4 = new Vector(Count4);
    for (int i = 1; i <= Count4; i++) {
    row4.add(rs4.getString(i));
    }
    vector4.add(row4);
    }

    } catch (Exception e) {
    }


    // query tabel bedrijf 1
    try {
    String bdid = ("SELECT Bedrijf.Bedrijf_ID FROM Bedrijf " +
    "INNER JOIN Opdracht ON Bedrijf.Bedrijf_ID = Opdracht.Bedrijf_ID " +
    "INNER JOIN OpdrachtWerknemer ON Opdracht.Opdracht_ID = OpdrachtWerknemer.Opdracht_ID " +
    "INNER JOIN Werknemer ON OpdrachtWerknemer.Werknemer_ID = Werknemer.Werknemer_ID " +
    "WHERE Werknemer.Werknemer_ID = " + Werknemer_ID + " ");

    ps = conn.prepareStatement(bdid);
    rs = ps.executeQuery();
    md = rs.getMetaData();
    rs.next();

    int ID = rs.getInt("Bedrijf_ID");

    String tblW1 = ("SELECT Werknemer.Werknemer_Naam, Bedrijf.Bedrijf_Naam, Werknemer.Werknemer_Locatie, " +
    "Opdracht.Starttijd, Opdracht.Ophaaltijd FROM Werknemer " +
    "INNER JOIN OpdrachtWerknemer ON Werknemer.Werknemer_ID = OpdrachtWerknemer.Werknemer_ID " +
    "INNER JOIN Opdracht ON OpdrachtWerknemer.Opdracht_ID = Opdracht.Opdracht_ID " +
    "INNER JOIN Bedrijf ON Opdracht.Bedrijf_ID = Bedrijf.Bedrijf_ID " +
    "WHERE Bedrijf.Bedrijf_ID = '" + ID + "'");

    ps1 = conn.prepareStatement(tblW1);
    rs1 = ps1.executeQuery();
    md1 = rs1.getMetaData();

    int Count1 = md1.getColumnCount();

    columns1 = new Vector(Count1);

    for (int i = 1; i <= Count1; i++) {
    columns1.add(md1.getColumnName(i));
    }
    vector1 = new Vector();

    while (rs1.next()) {
    row1 = new Vector(Count1);

    for (int i = 1; i <= Count1; i++) {
    row1.add(rs1.getString(i));
    }
    vector1.add(row1);
    }

    } catch (Exception e) {
    e.printStackTrace();
    JOptionPane.showMessageDialog(null, "Je bent niet bij een bedrijf ingeroosterd. ", "Let Op!!!", JOptionPane.INFORMATION_MESSAGE);
    }


    // query tabel bedrijf 2
    try {
    String bdid2 = ("SELECT Bedrijf.Bedrijf_ID FROM Bedrijf " +
    "INNER JOIN Opdracht ON Bedrijf.Bedrijf_ID = Opdracht.Bedrijf_ID " +
    "INNER JOIN OpdrachtWerknemer ON Opdracht.Opdracht_ID = OpdrachtWerknemer.Opdracht_ID " +
    "INNER JOIN Werknemer ON OpdrachtWerknemer.Werknemer_ID = Werknemer.Werknemer_ID " +
    "WHERE Werknemer.Werknemer_ID = " + Werknemer_ID + " ");

    ps6 = conn.prepareStatement(bdid2);
    rs6 = ps6.executeQuery();
    md6 = rs6.getMetaData();
    rs6.next();
    rs6.next();
    int ID6 = rs6.getInt("Bedrijf_ID");

    if (rs6 != null) {
    pnl.add(wslbl, BorderLayout.CENTER);

    }

    String tblW1 = ("SELECT Werknemer.Werknemer_Naam, Bedrijf.Bedrijf_Naam, Werknemer.Werknemer_Locatie, " +
    "Opdracht.Starttijd, Opdracht.Ophaaltijd FROM Werknemer " +
    "INNER JOIN OpdrachtWerknemer ON Werknemer.Werknemer_ID = OpdrachtWerknemer.Werknemer_ID " +
    "INNER JOIN Opdracht ON OpdrachtWerknemer.Opdracht_ID = Opdracht.Opdracht_ID " +
    "INNER JOIN Bedrijf ON Opdracht.Bedrijf_ID = Bedrijf.Bedrijf_ID " +
    "WHERE Bedrijf.Bedrijf_ID = '" + ID6 + "'");

    ps7 = conn.prepareStatement(tblW1);
    rs7 = ps7.executeQuery();
    md7 = rs7.getMetaData();

    int Count7 = md7.getColumnCount();

    columns7 = new Vector(Count7);

    for (int i = 1; i <= Count7; i++) {
    columns7.add(md7.getColumnName(i));
    }
    vector7 = new Vector();

    while (rs7.next()) {
    row7 = new Vector(Count7);

    for (int i = 1; i <= Count7; i++) {
    row7.add(rs7.getString(i));
    }
    vector7.add(row7);
    }

    } catch (Exception e) {
    }

    // query bedrijf 3


    try {
    String bdid3 = ("SELECT Bedrijf.Bedrijf_ID FROM Bedrijf " +
    "INNER JOIN Opdracht ON Bedrijf.Bedrijf_ID = Opdracht.Bedrijf_ID " +
    "INNER JOIN OpdrachtWerknemer ON Opdracht.Opdracht_ID = OpdrachtWerknemer.Opdracht_ID " +
    "INNER JOIN Werknemer ON OpdrachtWerknemer.Werknemer_ID = Werknemer.Werknemer_ID " +
    "WHERE Werknemer.Werknemer_ID = " + Werknemer_ID + " ");

    ps14 = conn.prepareStatement(bdid3);
    rs14 = ps14.executeQuery();
    md14 = rs14.getMetaData();
    rs14.next();
    rs14.next();
    rs14.next();

    int ID6 = rs14.getInt("Bedrijf_ID");

    if (rs14 != null) {
    Hoofdscherm2 = new Hoofdscherm2(conn);
    Hoofdscherm2.setVisible(true);
    dispose();

    }

    } catch (Exception e) {
    }



    // query tabel bedrijf info 1
    try {
    String bdinf1 = ("SELECT Bedrijf.Bedrijf_ID FROM Bedrijf " +
    "INNER JOIN Opdracht ON Bedrijf.Bedrijf_ID = Opdracht.Bedrijf_ID " +
    "INNER JOIN OpdrachtWerknemer ON Opdracht.Opdracht_ID = OpdrachtWerknemer.Opdracht_ID " +
    "INNER JOIN Werknemer ON OpdrachtWerknemer.Werknemer_ID = Werknemer.Werknemer_ID " +
    "WHERE Werknemer.Werknemer_ID = " + Werknemer_ID + " ");

    ps10 = conn.prepareStatement(bdinf1);
    rs10 = ps10.executeQuery();
    md10 = rs10.getMetaData();
    rs10.next();

    int ID10 = rs10.getInt("Bedrijf_ID");

    String tblBI1 = ("SELECT Bedrijf.Bedrijf_Info FROM Bedrijf WHERE Bedrijf.Bedrijf_ID = '" + ID10 + "'");

    ps11 = conn.prepareStatement(tblBI1);
    rs11 = ps11.executeQuery();
    md11 = rs11.getMetaData();

    int Count11 = md11.getColumnCount();

    columns11 = new Vector(Count11);

    for (int i = 1; i <= Count11; i++) {
    columns11.add(md11.getColumnName(i));
    }
    vector11 = new Vector();

    while (rs11.next()) {
    row11 = new Vector(Count11);

    for (int i = 1; i <= Count11; i++) {
    row11.add(rs11.getString(i));
    }
    vector11.add(row11);
    }

    } catch (Exception e) {
    }


    // query tabel bedrijf info 2
    try {
    String bdinf2 = ("SELECT Bedrijf.Bedrijf_ID FROM Bedrijf " +
    "INNER JOIN Opdracht ON Bedrijf.Bedrijf_ID = Opdracht.Bedrijf_ID " +
    "INNER JOIN OpdrachtWerknemer ON Opdracht.Opdracht_ID = OpdrachtWerknemer.Opdracht_ID " +
    "INNER JOIN Werknemer ON OpdrachtWerknemer.Werknemer_ID = Werknemer.Werknemer_ID " +
    "WHERE Werknemer.Werknemer_ID = " + Werknemer_ID + " ");

    ps12 = conn.prepareStatement(bdinf2);
    rs12 = ps12.executeQuery();
    md12 = rs12.getMetaData();
    rs12.next();
    rs12.next();
    int ID12 = rs12.getInt("Bedrijf_ID");

    String tblBI1 = ("SELECT Bedrijf.Bedrijf_Info FROM Bedrijf WHERE Bedrijf.Bedrijf_ID = '" + ID12 + "'");

    ps13 = conn.prepareStatement(tblBI1);
    rs13 = ps13.executeQuery();
    md13 = rs13.getMetaData();

    int Count13 = md13.getColumnCount();

    columns13 = new Vector(Count13);

    for (int i = 1; i <= Count13; i++) {
    columns13.add(md13.getColumnName(i));
    }
    vector13 = new Vector();

    while (rs13.next()) {
    row13 = new Vector(Count13);

    for (int i = 1; i <= Count13; i++) {
    row13.add(rs13.getString(i));
    }
    vector13.add(row13);
    }

    } catch (Exception e) {
    }


    tbl = new JTable(vector1, columns1);
    tb2 = new JTable(vector7, columns7);
    tb3 = new JTable(vector11, columns11);
    tb4 = new JTable(vector13, columns13);
    tb5 = new JTable(vector9, columns9);
    tb6 = new JTable(vector4, columns4);

    tb4.setFont(new Font("", Font.BOLD, 15));
    tb3.setFont(new Font("", Font.BOLD, 15));
    tb4.setRowHeight(22);
    tb3.setRowHeight(22);

    pn4 = new JPanel();
    pn4.setLayout(new BorderLayout());
    container.add(pn4);

    pndata = new JScrollPane(tbl);
    pndata.setBorder(BorderFactory.createLineBorder(Co lor.black));
    pndata2 = new JScrollPane(tb2);
    pndata2.setBorder(BorderFactory.createLineBorder(C olor.black));
    pndata5 = new JScrollPane(tb5);
    pndata5.setBorder(BorderFactory.createLineBorder(C olor.black));
    pndata6 = new JScrollPane(tb6);
    pndata6.setBorder(BorderFactory.createLineBorder(C olor.black));

    pn6 = new JPanel(new GridLayout());
    pndata5.setPreferredSize(new Dimension(0, 80));
    pndata6.setPreferredSize(new Dimension(0, 80));
    pn6.setBorder(BorderFactory.createLineBorder(Color .black));

    pn6.add(pndata5);
    pn6.add(pndata6);
    pn4.add(pn6, BorderLayout.NORTH);

    pn7 = new JPanel(new GridLayout(0, 2));
    pn7.add(pndata);
    pn7.add(pndata2);
    pn4.add(pn7);

    pndata3 = new JScrollPane(tb3);
    pndata3.setBorder(BorderFactory.createLineBorder(C olor.black));
    pndata4 = new JScrollPane(tb4);
    pndata4.setBorder(BorderFactory.createLineBorder(C olor.black));

    pn5 = new JPanel(new GridLayout());
    pndata3.setPreferredSize(new Dimension(130, 130));
    pndata4.setPreferredSize(new Dimension(130, 130));
    pn5.setAlignmentX(BOTTOM_ALIGNMENT);
    pn5.setBorder(BorderFactory.createLineBorder(Color .black));
    pn5.add(pndata3);
    pn5.add(pndata4);
    container.add(pn5, BorderLayout.SOUTH);

    try {
    stmt = conn.createStatement();
    rs = stmt.executeQuery("SELECT Datum FROM Datum");
    while (rs.next()) {
    String datum = rs.getString("Datum");
    datelbl = new JLabel(" " + datum);
    }
    } catch (Exception e) {
    System.err.println("Er is geen datum beschikbaar");
    System.err.println(e.getMessage());
    }

    datelbl.setFont(new Font("", Font.PLAIN, 18));


    try {
    stmt = conn.createStatement();
    rs = stmt.executeQuery("SELECT Werknemer.Werknemer_Naam FROM Werknemer WHERE Werknemer.Werknemer_ID = " + Werknemer_ID + "");
    while (rs.next()) {
    String login = rs.getString("Werknemer_Naam");
    wnlbl = new JLabel(login + " ");
    }
    } catch (Exception e) {
    JOptionPane.showMessageDialog(null, "Gebruikersnaam niet gevonden", "Error", JOptionPane.INFORMATION_MESSAGE);
    System.err.println(e.getMessage());
    }

    lubtn = new JButton("Loguit");
    bar = new JMenuBar();

    bar.add(datelbl);
    bar.add(Box.createHorizontalGlue());
    bar.add(wnlbl);
    bar.add(lubtn);
    pnl.add(bar, BorderLayout.SOUTH);

    // buttons actionlisteners
    btnNL.addActionListener(this);
    btnGBR.addActionListener(this);
    btnCZ.addActionListener(this);
    btnPL.addActionListener(this);
    btnGER.addActionListener(this);

    lubtn.addActionListener(new ActionListener() {

    LoginForm LoginForm;
    Connection conn;

    public void actionPerformed(ActionEvent evt) {
    if (conn == null) {
    DABA db = new DABA();
    conn = db.dbConnect("jdbc:jtds:sqlserver://82.148.216.83:1433/FHSons", "kees", "piet");
    }
    if (evt.getSource() == lubtn) {
    LoginForm = new LoginForm(conn);
    LoginForm.setVisible(true);
    dispose();
    }
    }
    });

    }

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,657
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Geraldo View Post
    Hello everybody,

    Can anybody tell me why in this code this dispose();

    int ID6 = rs14.getInt("Bedrijf_ID");

    if (rs14 != null) {
    Hoofdscherm2 = new Hoofdscherm2(conn);
    Hoofdscherm2.setVisible(true);
    dispose();

    }

    .... isn't working?
    Maybe rs14 is null so the code throws a NullPointerException; since you are hiding your Exceptions you won't see it and the dispose() call is never done.

    kind regards,

    Jos

  3. #3
    Geraldo is offline Member
    Join Date
    Jun 2010
    Posts
    7
    Rep Power
    0

    Default

    I don't think this is the problem cause this part is working just fine:

    Hoofdscherm2 = new Hoofdscherm2(conn);
    Hoofdscherm2.setVisible(true);

    I even tried to replace the dispose(); by a system.exit and this one is working fine aswell. How can a dispose not work and a system.exit in the same place do work??

    thank you for trying to help me anyway jos.

  4. #4
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,657
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Geraldo View Post
    I don't think this is the problem cause this part is working just fine:

    Hoofdscherm2 = new Hoofdscherm2(conn);
    Hoofdscherm2.setVisible(true);

    I even tried to replace the dispose(); by a system.exit and this one is working fine aswell. How can a dispose not work and a system.exit in the same place do work??

    thank you for trying to help me anyway jos.
    Well,dispose() does always work so you must be disposing() something else. Would you be so kind to put [code] ... [/code] tags around your code so it will be a bit more readable? (No need to repost, you can edit your original post).

    kind regards,

    Jos

  5. #5
    Geraldo is offline Member
    Join Date
    Jun 2010
    Posts
    7
    Rep Power
    0

    Default dispose().

    Hello everybody,

    Can anybody tell me why in this code this dispose();

    int ID6 = rs14.getInt("Bedrijf_ID");

    if (rs14 != null) {
    Hoofdscherm2 = new Hoofdscherm2(conn);
    Hoofdscherm2.setVisible(true);
    dispose();

    }

    .... isn't working?

    I hope somebody can help me it's a bit urgent.
    thanks in advanced

    Java Code:
     
    public class Hoofdscherm extends JFrame implements ActionListener {
    
        private Container container;
        private JButton btnGBR, btnPL, btnGER, btnNL, btnCZ;
        public JButton lubtn;
        private JLabel lbl, wnlbl, datelbl, wslbl;
        private JTable tbl, tb2, tb3, tb4, tb5, tb6;
        private JPanel pnl, pn2, pn3, pn4, pn5, pn6, pn7;
        private JScrollPane pndata, pndata2, pndata3, pndata4, pndata5, pndata6;
        private ImageIcon GBR, PL, GER, NL, CZ, FHSlogo;
        private Locale CurrentLocale;
        private ResourceBundle messages;
        private JMenuBar bar;
        private BorderLayout layout;
        public Connection conn;
        ResultSetMetaData md, md1, md2, md3, md4, md6, md7, md8, md9, md10, md11, md12, md13, md14, md15;
        Vector vector1, vector7, columns7, vector9, row9, columns9, columns11, vector11, vector13, row13, row14;
        Vector row, columns, columns4, vector4, vector, row1, row4, row7, columns1, row11, columns13, columns14, vector14;
        PreparedStatement ps, ps1, ps2, ps3, ps4, ps6, ps7, ps8, ps9, ps10, ps11, ps12, ps13, ps14, ps15;
        Statement stmt, stmt1;
        ResultSet rs, rs1, rs2, rs3, rs4, rs6, rs7, rs8, rs9, rs10, rs11, rs12, rs13, rs14, rs15;
        String language = new String();
        String Werknemer_ID;
        String Werknemer_Naam;
        private Hoofdscherm2 Hoofdscherm2;
        private Hoofdscherm Hoofdscherm;
    
        public Hoofdscherm(Connection conn) {
    
            this.conn = conn;
            setTitle("Hoofdscherm");
            setResizable(false);
            Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
            setSize(dim);
            setUndecorated(true);
            setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
            Color background1 = new Color(232, 232, 232);
    
            CurrentLocale = new Locale(language);
            messages = ResourceBundle.getBundle("GUI/Properties/MessagesBundle", CurrentLocale);
    
    
            Werknemer_ID = new String(LoginForm.txtUser.getText());
            container = getContentPane();
            layout = new BorderLayout();
            container.setLayout(layout);
    
    
            pnl = new JPanel();
            pnl.setLayout(new BorderLayout());
            container.add(pnl, BorderLayout.NORTH);
    
            pn3 = new JPanel();
            FHSlogo = new ImageIcon("/Users/Gerard/NetBeansProjects/WerkplanningWebviewer/src/GUI/resources/logoFHSapp.jpg");
            lbl = new JLabel();
            lbl.setIcon(FHSlogo);
            pn3.add(lbl);
            pnl.add(pn3, BorderLayout.LINE_START);
    
            pn2 = new JPanel();
            pn2.setLayout(new FlowLayout());
            pnl.add(pn2, BorderLayout.LINE_END);
    
            pnl.setBackground(background1);
            pn2.setBackground(background1);
            pn3.setBackground(background1);
    
             // waarschuwing meerdere bedrijven label
            wslbl = new JLabel("                     LET OP!!! JE WERKT BIJ 2 BEDRIJVEN!!!");
            wslbl.setFont(new Font("", Font.PLAIN, 20));
            wslbl.setForeground(Color.red);
    
            // query auto tabel 1
            try {
                String auto = ("SELECT Bedrijf.Bedrijf_ID FROM Bedrijf " +
                        "INNER JOIN Opdracht ON Bedrijf.Bedrijf_ID = Opdracht.Bedrijf_ID " +
                        "INNER JOIN OpdrachtWerknemer ON Opdracht.Opdracht_ID = OpdrachtWerknemer.Opdracht_ID " +
                        "INNER JOIN Werknemer ON OpdrachtWerknemer.Werknemer_ID = Werknemer.Werknemer_ID " +
                        "WHERE Werknemer.Werknemer_ID = " + Werknemer_ID + " ");
    
                ps8 = conn.prepareStatement(auto);
                rs8 = ps8.executeQuery();
                md8 = rs8.getMetaData();
    
                rs8.next();
                int ID8 = rs8.getInt("Bedrijf_ID");
    
                String tblA1 = ("SELECT Auto.Auto_ID, Auto.Auto_Kenteken, Auto.Auto_Personen, Auto.Auto_Locatie FROM Auto " +
                        "INNER JOIN OpdrachtAuto ON Auto.Auto_ID = OpdrachtAuto.Auto_ID " +
                        "INNER JOIN Opdracht ON OpdrachtAuto.Opdracht_ID = Opdracht.Opdracht_ID " +
                        "INNER JOIN Bedrijf ON Opdracht.Bedrijf_ID = Bedrijf.Bedrijf_ID " +
                        "WHERE Bedrijf.Bedrijf_ID = '" + ID8 + "'");
    
                ps9 = conn.prepareStatement(tblA1);
                rs9 = ps9.executeQuery();
                md9 = rs9.getMetaData();
    
                int Count9 = md9.getColumnCount();
    
                columns9 = new Vector(Count9);
    
                for (int i = 1; i <= Count9; i++) {
                    columns9.add(md9.getColumnName(i));
                }
                vector9 = new Vector();
    
                while (rs9.next()) {
                    row9 = new Vector(Count9);
                    for (int i = 1; i <= Count9; i++) {
                        row9.add(rs9.getString(i));
                    }
                    vector9.add(row9);
                }
    
            } catch (Exception e) {
            }
    
    
            // query auto tabel 2
            try {
                String auto2 = ("SELECT Bedrijf.Bedrijf_ID FROM Bedrijf " +
                        "INNER JOIN Opdracht ON Bedrijf.Bedrijf_ID = Opdracht.Bedrijf_ID " +
                        "INNER JOIN OpdrachtWerknemer ON Opdracht.Opdracht_ID = OpdrachtWerknemer.Opdracht_ID " +
                        "INNER JOIN Werknemer ON OpdrachtWerknemer.Werknemer_ID = Werknemer.Werknemer_ID " +
                        "WHERE Werknemer.Werknemer_ID = " + Werknemer_ID + " ");
    
                ps3 = conn.prepareStatement(auto2);
                rs3 = ps3.executeQuery();
                md3 = rs3.getMetaData();
                rs3.next();
                rs3.next();
                int ID8 = rs3.getInt("Bedrijf_ID");
    
                String tblA2 = ("SELECT Auto.Auto_ID, Auto.Auto_Kenteken, Auto.Auto_Personen, Auto.Auto_Locatie FROM Auto " +
                        "INNER JOIN OpdrachtAuto ON Auto.Auto_ID = OpdrachtAuto.Auto_ID " +
                        "INNER JOIN Opdracht ON OpdrachtAuto.Opdracht_ID = Opdracht.Opdracht_ID " +
                        "INNER JOIN Bedrijf ON Opdracht.Bedrijf_ID = Bedrijf.Bedrijf_ID " +
                        "WHERE Bedrijf.Bedrijf_ID = '" + ID8 + "'");
    
                ps4 = conn.prepareStatement(tblA2);
                rs4 = ps4.executeQuery();
                md4 = rs4.getMetaData();
    
                int Count4 = md4.getColumnCount();
    
                columns4 = new Vector(Count4);
    
                for (int i = 1; i <= Count4; i++) {
                    columns4.add(md4.getColumnName(i));
                }
                vector4 = new Vector();
    
                while (rs4.next()) {
                    row4 = new Vector(Count4);
                    for (int i = 1; i <= Count4; i++) {
                        row4.add(rs4.getString(i));
                    }
                    vector4.add(row4);
                }
    
            } catch (Exception e) {
            }
    
    
            // query tabel bedrijf 1
            try {
                String bdid = ("SELECT Bedrijf.Bedrijf_ID FROM Bedrijf " +
                        "INNER JOIN Opdracht ON Bedrijf.Bedrijf_ID = Opdracht.Bedrijf_ID " +
                        "INNER JOIN OpdrachtWerknemer ON Opdracht.Opdracht_ID = OpdrachtWerknemer.Opdracht_ID " +
                        "INNER JOIN Werknemer ON OpdrachtWerknemer.Werknemer_ID = Werknemer.Werknemer_ID " +
                        "WHERE Werknemer.Werknemer_ID = " + Werknemer_ID + " ");
    
                ps = conn.prepareStatement(bdid);
                rs = ps.executeQuery();
                md = rs.getMetaData();
                rs.next();
    
                int ID = rs.getInt("Bedrijf_ID");
    
                String tblW1 = ("SELECT Werknemer.Werknemer_Naam, Bedrijf.Bedrijf_Naam, Werknemer.Werknemer_Locatie, " +
                        "Opdracht.Starttijd, Opdracht.Ophaaltijd FROM Werknemer " +
                        "INNER JOIN OpdrachtWerknemer ON Werknemer.Werknemer_ID = OpdrachtWerknemer.Werknemer_ID " +
                        "INNER JOIN Opdracht ON OpdrachtWerknemer.Opdracht_ID = Opdracht.Opdracht_ID " +
                        "INNER JOIN Bedrijf ON Opdracht.Bedrijf_ID = Bedrijf.Bedrijf_ID " +
                        "WHERE Bedrijf.Bedrijf_ID = '" + ID + "'");
    
                ps1 = conn.prepareStatement(tblW1);
                rs1 = ps1.executeQuery();
                md1 = rs1.getMetaData();
    
                int Count1 = md1.getColumnCount();
    
                columns1 = new Vector(Count1);
    
                for (int i = 1; i <= Count1; i++) {
                    columns1.add(md1.getColumnName(i));
                }
                vector1 = new Vector();
    
                while (rs1.next()) {
                    row1 = new Vector(Count1);
    
                    for (int i = 1; i <= Count1; i++) {
                        row1.add(rs1.getString(i));
                    }
                    vector1.add(row1);
                }
    
            } catch (Exception e) {
                e.printStackTrace();
                JOptionPane.showMessageDialog(null, "Je bent niet bij een bedrijf ingeroosterd. ", "Let Op!!!", JOptionPane.INFORMATION_MESSAGE);
            }
    
    
            // query tabel bedrijf 2
            try {
                String bdid2 = ("SELECT Bedrijf.Bedrijf_ID FROM Bedrijf " +
                        "INNER JOIN Opdracht ON Bedrijf.Bedrijf_ID = Opdracht.Bedrijf_ID " +
                        "INNER JOIN OpdrachtWerknemer ON Opdracht.Opdracht_ID = OpdrachtWerknemer.Opdracht_ID " +
                        "INNER JOIN Werknemer ON OpdrachtWerknemer.Werknemer_ID = Werknemer.Werknemer_ID " +
                        "WHERE Werknemer.Werknemer_ID = " + Werknemer_ID + " ");
    
                ps6 = conn.prepareStatement(bdid2);
                rs6 = ps6.executeQuery();
                md6 = rs6.getMetaData();
                rs6.next();
                rs6.next();
                int ID6 = rs6.getInt("Bedrijf_ID");
    
                if (rs6 != null) {
                    pnl.add(wslbl, BorderLayout.CENTER);
    
                }
    
                String tblW1 = ("SELECT Werknemer.Werknemer_Naam, Bedrijf.Bedrijf_Naam, Werknemer.Werknemer_Locatie, " +
                        "Opdracht.Starttijd, Opdracht.Ophaaltijd FROM Werknemer " +
                        "INNER JOIN OpdrachtWerknemer ON Werknemer.Werknemer_ID = OpdrachtWerknemer.Werknemer_ID " +
                        "INNER JOIN Opdracht ON OpdrachtWerknemer.Opdracht_ID = Opdracht.Opdracht_ID " +
                        "INNER JOIN Bedrijf ON Opdracht.Bedrijf_ID = Bedrijf.Bedrijf_ID " +
                        "WHERE Bedrijf.Bedrijf_ID = '" + ID6 + "'");
    
                ps7 = conn.prepareStatement(tblW1);
                rs7 = ps7.executeQuery();
                md7 = rs7.getMetaData();
    
                int Count7 = md7.getColumnCount();
    
                columns7 = new Vector(Count7);
    
                for (int i = 1; i <= Count7; i++) {
                    columns7.add(md7.getColumnName(i));
                }
                vector7 = new Vector();
    
                while (rs7.next()) {
                    row7 = new Vector(Count7);
    
                    for (int i = 1; i <= Count7; i++) {
                        row7.add(rs7.getString(i));
                    }
                    vector7.add(row7);
                }
    
            } catch (Exception e) {
            }
            
                            // query bedrijf 3
    
    
            try {
                String bdid3 = ("SELECT Bedrijf.Bedrijf_ID FROM Bedrijf " +
                        "INNER JOIN Opdracht ON Bedrijf.Bedrijf_ID = Opdracht.Bedrijf_ID " +
                        "INNER JOIN OpdrachtWerknemer ON Opdracht.Opdracht_ID = OpdrachtWerknemer.Opdracht_ID " +
                        "INNER JOIN Werknemer ON OpdrachtWerknemer.Werknemer_ID = Werknemer.Werknemer_ID " +
                        "WHERE Werknemer.Werknemer_ID = " + Werknemer_ID + " ");
    
                ps14 = conn.prepareStatement(bdid3);
                rs14 = ps14.executeQuery();
                md14 = rs14.getMetaData();
                rs14.next();
                rs14.next();
                rs14.next();
    
                int ID6 = rs14.getInt("Bedrijf_ID");
    
                if (rs14 != null) {
                    Hoofdscherm2 = new Hoofdscherm2(conn);
                    Hoofdscherm2.setVisible(true);
                    dispose();
    
                }
    
            } catch (Exception e) {
            }
    
    
    
            // query tabel bedrijf info 1
            try {
                String bdinf1 = ("SELECT Bedrijf.Bedrijf_ID FROM Bedrijf " +
                        "INNER JOIN Opdracht ON Bedrijf.Bedrijf_ID = Opdracht.Bedrijf_ID " +
                        "INNER JOIN OpdrachtWerknemer ON Opdracht.Opdracht_ID = OpdrachtWerknemer.Opdracht_ID " +
                        "INNER JOIN Werknemer ON OpdrachtWerknemer.Werknemer_ID = Werknemer.Werknemer_ID " +
                        "WHERE Werknemer.Werknemer_ID = " + Werknemer_ID + " ");
    
                ps10 = conn.prepareStatement(bdinf1);
                rs10 = ps10.executeQuery();
                md10 = rs10.getMetaData();
                rs10.next();
    
                int ID10 = rs10.getInt("Bedrijf_ID");
    
                String tblBI1 = ("SELECT Bedrijf.Bedrijf_Info FROM Bedrijf WHERE Bedrijf.Bedrijf_ID = '" + ID10 + "'");
    
                ps11 = conn.prepareStatement(tblBI1);
                rs11 = ps11.executeQuery();
                md11 = rs11.getMetaData();
    
                int Count11 = md11.getColumnCount();
    
                columns11 = new Vector(Count11);
    
                for (int i = 1; i <= Count11; i++) {
                    columns11.add(md11.getColumnName(i));
                }
                vector11 = new Vector();
    
                while (rs11.next()) {
                    row11 = new Vector(Count11);
    
                    for (int i = 1; i <= Count11; i++) {
                        row11.add(rs11.getString(i));
                    }
                    vector11.add(row11);
                }
    
            } catch (Exception e) {
            }
    
    
            // query tabel bedrijf info 2
            try {
                String bdinf2 = ("SELECT Bedrijf.Bedrijf_ID FROM Bedrijf " +
                        "INNER JOIN Opdracht ON Bedrijf.Bedrijf_ID = Opdracht.Bedrijf_ID " +
                        "INNER JOIN OpdrachtWerknemer ON Opdracht.Opdracht_ID = OpdrachtWerknemer.Opdracht_ID " +
                        "INNER JOIN Werknemer ON OpdrachtWerknemer.Werknemer_ID = Werknemer.Werknemer_ID " +
                        "WHERE Werknemer.Werknemer_ID = " + Werknemer_ID + " ");
    
                ps12 = conn.prepareStatement(bdinf2);
                rs12 = ps12.executeQuery();
                md12 = rs12.getMetaData();
                rs12.next();
                rs12.next();
                int ID12 = rs12.getInt("Bedrijf_ID");
    
                String tblBI1 = ("SELECT Bedrijf.Bedrijf_Info FROM Bedrijf WHERE Bedrijf.Bedrijf_ID = '" + ID12 + "'");
    
                ps13 = conn.prepareStatement(tblBI1);
                rs13 = ps13.executeQuery();
                md13 = rs13.getMetaData();
    
                int Count13 = md13.getColumnCount();
    
                columns13 = new Vector(Count13);
    
                for (int i = 1; i <= Count13; i++) {
                    columns13.add(md13.getColumnName(i));
                }
                vector13 = new Vector();
    
                while (rs13.next()) {
                    row13 = new Vector(Count13);
    
                    for (int i = 1; i <= Count13; i++) {
                        row13.add(rs13.getString(i));
                    }
                    vector13.add(row13);
                }
    
            } catch (Exception e) {
            }
    
    
            tbl = new JTable(vector1, columns1);
            tb2 = new JTable(vector7, columns7);
            tb3 = new JTable(vector11, columns11);
            tb4 = new JTable(vector13, columns13);
            tb5 = new JTable(vector9, columns9);
            tb6 = new JTable(vector4, columns4);
    
            tb4.setFont(new Font("", Font.BOLD, 15));
            tb3.setFont(new Font("", Font.BOLD, 15));
            tb4.setRowHeight(22);
            tb3.setRowHeight(22);
    
            pn4 = new JPanel();
            pn4.setLayout(new BorderLayout());
            container.add(pn4);
    
            pndata = new JScrollPane(tbl);
            pndata.setBorder(BorderFactory.createLineBorder(Color.black));
            pndata2 = new JScrollPane(tb2);
            pndata2.setBorder(BorderFactory.createLineBorder(Color.black));
            pndata5 = new JScrollPane(tb5);
            pndata5.setBorder(BorderFactory.createLineBorder(Color.black));
            pndata6 = new JScrollPane(tb6);
            pndata6.setBorder(BorderFactory.createLineBorder(Color.black));
    
            pn6 = new JPanel(new GridLayout());
            pndata5.setPreferredSize(new Dimension(0, 80));
            pndata6.setPreferredSize(new Dimension(0, 80));
            pn6.setBorder(BorderFactory.createLineBorder(Color.black));
    
            pn6.add(pndata5);
            pn6.add(pndata6);
            pn4.add(pn6, BorderLayout.NORTH);
    
            pn7 = new JPanel(new GridLayout(0, 2));
            pn7.add(pndata);
            pn7.add(pndata2);
            pn4.add(pn7);
    
            pndata3 = new JScrollPane(tb3);
            pndata3.setBorder(BorderFactory.createLineBorder(Color.black));
            pndata4 = new JScrollPane(tb4);
            pndata4.setBorder(BorderFactory.createLineBorder(Color.black));
    
            pn5 = new JPanel(new GridLayout());
            pndata3.setPreferredSize(new Dimension(130, 130));
            pndata4.setPreferredSize(new Dimension(130, 130));
            pn5.setAlignmentX(BOTTOM_ALIGNMENT);
            pn5.setBorder(BorderFactory.createLineBorder(Color.black));
            pn5.add(pndata3);
            pn5.add(pndata4);
            container.add(pn5, BorderLayout.SOUTH);
    
            try {
                stmt = conn.createStatement();
                rs = stmt.executeQuery("SELECT Datum FROM Datum");
                while (rs.next()) {
                    String datum = rs.getString("Datum");
                    datelbl = new JLabel("  " + datum);
                }
            } catch (Exception e) {
                System.err.println("Er is geen datum beschikbaar");
                System.err.println(e.getMessage());
            }
    
            datelbl.setFont(new Font("", Font.PLAIN, 18));
    
    
            try {
                stmt = conn.createStatement();
                rs = stmt.executeQuery("SELECT Werknemer.Werknemer_Naam FROM Werknemer WHERE Werknemer.Werknemer_ID = " + Werknemer_ID + "");
                while (rs.next()) {
                    String login = rs.getString("Werknemer_Naam");
                    wnlbl = new JLabel(login + "   ");
                }
            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, "Gebruikersnaam niet gevonden", "Error", JOptionPane.INFORMATION_MESSAGE);
                System.err.println(e.getMessage());
            }
    
            lubtn = new JButton("Loguit");
            bar = new JMenuBar();
    
            bar.add(datelbl);
            bar.add(Box.createHorizontalGlue());
            bar.add(wnlbl);
            bar.add(lubtn);
            pnl.add(bar, BorderLayout.SOUTH);
    
            // buttons actionlisteners
            btnNL.addActionListener(this);
            btnGBR.addActionListener(this);
            btnCZ.addActionListener(this);
            btnPL.addActionListener(this);
            btnGER.addActionListener(this);
    
            lubtn.addActionListener(new ActionListener() {
    
                LoginForm LoginForm;
                Connection conn;
    
                public void actionPerformed(ActionEvent evt) {
                    if (conn == null) {
                        DABA db = new DABA();
                        conn = db.dbConnect("jdbc:jtds:sqlserver://82.148.216.83:1433/FHSons", "kees", "piet");
                    }
                    if (evt.getSource() == lubtn) {
                        LoginForm = new LoginForm(conn);
                        LoginForm.setVisible(true);
                        dispose();
                    }
                }
            });
    
        }

  6. #6
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,657
    Blog Entries
    7
    Rep Power
    21

    Default

    Your code is just too long: we can't run it because of all that database JDBC code in there. Can you post a short compiling and self contained example that shows the problem?

    kind regards,

    Jos

  7. #7
    StormyWaters is offline Senior Member
    Join Date
    Feb 2009
    Posts
    305
    Rep Power
    6

    Default

    Where is the Hoofdscherm2 class?

  8. #8
    Geraldo is offline Member
    Join Date
    Jun 2010
    Posts
    7
    Rep Power
    0

    Default

    ok jos here it is;

    Java Code:
    public class Hoofdscherm extends JFrame implements ActionListener {
    
    // some data
    
        public Hoofdscherm(Connection conn) {
    
            this.conn = conn;
            setTitle("Hoofdscherm");
            setResizable(false);
            Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
            setSize(dim);
            setUndecorated(true);
            setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
      
            // query bedrijf 3
    
            try {
                String bdid3 = ("SELECT Bedrijf.Bedrijf_ID FROM Bedrijf " +
                        "INNER JOIN Opdracht ON Bedrijf.Bedrijf_ID = Opdracht.Bedrijf_ID " +
                        "INNER JOIN OpdrachtWerknemer ON Opdracht.Opdracht_ID = OpdrachtWerknemer.Opdracht_ID " +
                        "INNER JOIN Werknemer ON OpdrachtWerknemer.Werknemer_ID = Werknemer.Werknemer_ID " +
                        "WHERE Werknemer.Werknemer_ID = " + Werknemer_ID + " ");
    
                ps14 = conn.prepareStatement(bdid3);
                rs14 = ps14.executeQuery();
                md14 = rs14.getMetaData();
                rs14.next();
                rs14.next();
                rs14.next();
    
                int ID6 = rs14.getInt("Bedrijf_ID");
    
                if (rs14 != null) {
                    Hoofdscherm2 = new Hoofdscherm2(conn);   // class in app
                    Hoofdscherm2.setVisible(true);
               
                    [COLOR="Red"][B]dispose();[/B][/COLOR]
    
    
                }
    
            } catch (Exception e) {
            }
    
    }
    
            lubtn.addActionListener(new ActionListener() {
    
                LoginForm LoginForm;          // class in app
                Connection conn;
    
                public void actionPerformed(ActionEvent evt) {
               //     if (conn == null) {
               //         DABA db = new DABA();
                //        conn = db.dbConnect("jdbc:jtds:sqlserver://82.148.216.83:1433/FHSons", "kees", "piet");
                //    }
                    if (evt.getSource() == lubtn) {
                        LoginForm = new LoginForm(conn);
                        LoginForm.setVisible(true);
                        dispose();
                    }
                }
            });
    
        }

  9. #9
    Geraldo is offline Member
    Join Date
    Jun 2010
    Posts
    7
    Rep Power
    0

    Default

    Where is the Hoofdscherm2 class?
    The Hoofdscherm2 class is exactly the same as Hoofdscherm class.
    There afre only 3 more scrollPanes with JTables

  10. #10
    StormyWaters is offline Senior Member
    Join Date
    Feb 2009
    Posts
    305
    Rep Power
    6

    Default

    Actually now that I look at it, that dispose() is in the Constructor before its set visible so its useless.
    Last edited by StormyWaters; 06-04-2010 at 02:59 PM.

  11. #11
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,657
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Geraldo View Post
    ok jos here it is;
    I had to change your code a bit more because it still wouldn't compile (nor run), but the following version works for me:

    Java Code:
    import java.awt.Dimension;
    import java.awt.Toolkit;
    
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.WindowConstants;
    
    public class Test extends JFrame {
    
    // some data
    
        public Test() {
    
            setTitle("Hoofdscherm");
            setResizable(false);
            Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
            setSize(dim);
            this.setLocation(0, 0);
            JLabel label= new JLabel("test");
    
            add(label);
            
            setUndecorated(true);
            setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
            pack();
            setVisible(true);
            
            // query bedrijf 3
    
            try {
            	
            		System.in.read();
                    dispose();
    
    
            } catch (Exception e) {
            }
    
        }
        
        public static void main(String[] args) {
        	new BBB();
        }
    }
    kind regards,

    Jos

  12. #12
    Geraldo is offline Member
    Join Date
    Jun 2010
    Posts
    7
    Rep Power
    0

    Default

    i tried this part of code and it actually redirects me to Hoofdscherm2 and closes Hoofdscherm, the only problem is that Hoofdscherm2 is blank...

    What could be the problem here?

    Java Code:
     
    try {
            	
            		System.in.read();
                    dispose();
    
    
            } catch (Exception e) {
            }

  13. #13
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,657
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Geraldo View Post
    i tried this part of code and it actually redirects me to Hoofdscherm2 and closes Hoofdscherm, the only problem is that Hoofdscherm2 is blank...

    What could be the problem here?
    Dunno ... you forgot to pack() the JFrame? You forgot to add the components to the content pane of the JFrame? Who knows ...

    kind regards,

    Jos

Similar Threads

  1. dispose() does not work here
    By arunkumarinfo in forum NetBeans
    Replies: 5
    Last Post: 12-28-2013, 05:42 PM
  2. dispose() method not working
    By R&R in forum New To Java
    Replies: 19
    Last Post: 11-15-2010, 01:46 AM
  3. dispose
    By simontkk2005 in forum AWT / Swing
    Replies: 3
    Last Post: 11-18-2009, 11:42 PM
  4. dispose all using Vector ?
    By sysout in forum New To Java
    Replies: 10
    Last Post: 08-31-2009, 04:51 PM
  5. How to dispose tooltip.
    By Preethi in forum New To Java
    Replies: 1
    Last Post: 07-22-2008, 07:06 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •