Page 3 of 11 FirstFirst 12345 ... LastLast
Results 41 to 60 of 219
Like Tree22Likes

Thread: How to do this?

  1. #41
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,401
    Rep Power
    25

    Default Re: How to do this?

    If you don't understand how to use your IDE, try using the javac command to compile the program.
    Open a command prompt, change to the folder with the source file and enter the javac command. The javac command will write the errors on the command prompt window.
    Copy the contents of the command prompt window and paste it here.
    If you don't understand my response, don't ignore it, ask a question.

  2. #42
    Tawi is offline Senior Member
    Join Date
    Feb 2013
    Posts
    118
    Rep Power
    0

    Default Re: How to do this?

    for (int up = 0; up < ulang.length; up++) {ulang[up] = false;}
    ^
    BaruFrame.java:2383: error: illegal start of type
    for (int up = 0; up < ulang.length; up++) {ulang[up] = false;}
    ^
    BaruFrame.java:2383: error: <identifier> expected
    for (int up = 0; up < ulang.length; up++) {ulang[up] = false;}
    ^
    BaruFrame.java:2383: error: ';' expected
    for (int up = 0; up < ulang.length; up++) {ulang[up] = false;}
    ^
    BaruFrame.java:2383: error: illegal start of type
    for (int up = 0; up < ulang.length; up++) {ulang[up] = false;}
    ^
    BaruFrame.java:2383: error: ';' expected
    for (int up = 0; up < ulang.length; up++) {ulang[up] = false;}
    ^
    BaruFrame.java:2384: error: class, interface, or enum expected
    for (int kli = 0; kli <2;kli++) {
    ^
    BaruFrame.java:2384: error: class, interface, or enum expected
    for (int kli = 0; kli <2;kli++) {
    ^
    BaruFrame.java:2384: error: class, interface, or enum expected
    for (int kli = 0; kli <2;kli++) {
    ^
    BaruFrame.java:2386: error: class, interface, or enum expected
    lanjutlah[kli] = new JButton("Lanjut");
    ^
    BaruFrame.java:2387: error: class, interface, or enum expected
    perhitunganKriteria[kli] = new JButton("Perhitungan Kriteria");
    ^
    BaruFrame.java:2388: error: class, interface, or enum expected
    kmbl[kli] = new JButton("");
    ^
    BaruFrame.java:2389: error: class, interface, or enum expected
    kriteriaLanjut[kli] = new JButton("");
    ^
    BaruFrame.java:2390: error: class, interface, or enum expected
    labelKriteria[kli] = new JLabel("");
    ^
    BaruFrame.java:2391: error: class, interface, or enum expected
    xyz[kli] = 0;
    ^
    BaruFrame.java:2392: error: class, interface, or enum expected
    kmbl[kli].setVisible(false);
    ^
    BaruFrame.java:2393: error: class, interface, or enum expected
    update[kli].setVisible(false);
    ^
    BaruFrame.java:2394: error: class, interface, or enum expected
    labelKriteria[kli].setVisible(false);
    ^
    BaruFrame.java:2395: error: class, interface, or enum expected
    kriteriaLanjut[kli].setVisible(false);
    ^
    BaruFrame.java:2396: error: class, interface, or enum expected
    perhitunganKriteria[kli].setVisible(false);
    ^
    BaruFrame.java:2397: error: class, interface, or enum expected
    lanjutlah[kli].setVisible(false);
    ^
    BaruFrame.java:2398: error: class, interface, or enum expected
    add(update[kli]);
    ^
    BaruFrame.java:2399: error: class, interface, or enum expected
    add(lanjutlah[kli]);
    ^
    BaruFrame.java:2400: error: class, interface, or enum expected
    add(perhitunganKriteria[kli]);
    ^
    BaruFrame.java:2401: error: class, interface, or enum expected
    add(kmbl[kli]);
    ^
    BaruFrame.java:2402: error: class, interface, or enum expected
    add(kriteriaLanjut[kli]);
    ^
    BaruFrame.java:2403: error: class, interface, or enum expected
    add(labelKriteria[kli]);}
    ^
    BaruFrame.java:2403: error: class, interface, or enum expected
    add(labelKriteria[kli]);}
    ^
    BaruFrame.java:2405: error: class, interface, or enum expected
    alternatifKriteria2.setVisible(false);
    ^
    BaruFrame.java:2406: error: class, interface, or enum expected
    alternatifKriteria3.setVisible(false);
    ^
    BaruFrame.java:2407: error: class, interface, or enum expected
    alternatifKriteria4.setVisible(false);
    ^
    BaruFrame.java:2408: error: class, interface, or enum expected
    myocardInfarc.setBounds(0,0,200,25);
    ^
    BaruFrame.java:2409: error: class, interface, or enum expected
    awal.setBounds(809,700,200,25);
    ^
    BaruFrame.java:2410: error: class, interface, or enum expected
    labelLuarKriteria[0][0].setBounds(0,150,100,25);
    ^
    BaruFrame.java:2411: error: class, interface, or enum expected
    labelLuarKriteria[1][0].setBounds(0,180,100,25);
    ^
    BaruFrame.java:2412: error: class, interface, or enum expected
    labelLuarKriteria[2][0].setBounds(0,210,100,25);
    ^
    BaruFrame.java:2413: error: class, interface, or enum expected
    labelLuarKriteria[3][0].setBounds(0,240,100,25);
    ^
    BaruFrame.java:2414: error: class, interface, or enum expected
    labelLuarKriteria1[0][0].setBounds(101,100,100,25);
    ^
    BaruFrame.java:2415: error: class, interface, or enum expected
    labelLuarKriteria1[1][0].setBounds(202,100,100,25);
    ^
    BaruFrame.java:2416: error: class, interface, or enum expected
    labelLuarKriteria1[2][0].setBounds(303,100,100,25);
    ^
    BaruFrame.java:2417: error: class, interface, or enum expected
    labelLuarKriteria1[3][0].setBounds(404,100,100,25);
    ^
    BaruFrame.java:2418: error: class, interface, or enum expected
    jawabKriteria1[0][0].setBounds(101,155,100,25);
    ^
    BaruFrame.java:2419: error: class, interface, or enum expected
    jawabKriteria1[1][0].setBounds(101,185,100,25);
    ^
    BaruFrame.java:2420: error: class, interface, or enum expected
    jawabKriteria1[2][0].setBounds(101,215,100,25);
    ^
    BaruFrame.java:2421: error: class, interface, or enum expected
    jawabKriteria1[3][0].setBounds(101,245,100,25);
    ^
    BaruFrame.java:2422: error: class, interface, or enum expected
    jawabKriteria1[4][0].setBounds(202,155,100,25);
    ^
    BaruFrame.java:2423: error: class, interface, or enum expected
    jawabKriteria1[5][0].setBounds(202,185,100,25);
    ^
    BaruFrame.java:2424: error: class, interface, or enum expected
    jawabKriteria1[6][0].setBounds(202,215,100,25);
    ^
    BaruFrame.java:2425: error: class, interface, or enum expected
    jawabKriteria1[7][0].setBounds(202,245,100,25);
    ^
    BaruFrame.java:2426: error: class, interface, or enum expected
    jawabKriteria1[8][0].setBounds(303,155,100,25);
    ^
    BaruFrame.java:2427: error: class, interface, or enum expected
    jawabKriteria1[9][0].setBounds(303,185,100,25);
    ^
    BaruFrame.java:2428: error: class, interface, or enum expected
    jawabKriteria1[10][0].setBounds(303,215,100,25);
    ^
    BaruFrame.java:2429: error: class, interface, or enum expected
    jawabKriteria1[11][0].setBounds(303,245,100,25);
    ^
    BaruFrame.java:2430: error: class, interface, or enum expected
    jawabKriteria1[12][0].setBounds(404,155,100,25);
    ^
    BaruFrame.java:2431: error: class, interface, or enum expected
    jawabKriteria1[13][0].setBounds(404,185,100,25);
    ^
    BaruFrame.java:2432: error: class, interface, or enum expected
    jawabKriteria1[14][0].setBounds(404,215,100,25);
    ^
    BaruFrame.java:2433: error: class, interface, or enum expected
    jawabKriteria1[15][0].setBounds(404,245,100,25);
    ^
    BaruFrame.java:2434: error: class, interface, or enum expected
    labelLuarAlternatif[0][0].setBounds(405,150,100,25);
    ^
    BaruFrame.java:2435: error: class, interface, or enum expected
    labelLuarAlternatif[1][0].setBounds(405,180,100,25);
    ^
    BaruFrame.java:2436: error: class, interface, or enum expected
    labelLuarAlternatif[2][0].setBounds(405,210,100,25);
    ^
    BaruFrame.java:2437: error: class, interface, or enum expected
    labelLuarAlternatif[3][0].setBounds(405,240,100,25);
    ^
    BaruFrame.java:2438: error: class, interface, or enum expected
    labelLuarAlternatif[4][0].setBounds(405,270,100,25);
    ^
    BaruFrame.java:2439: error: class, interface, or enum expected
    labelLuarAlternatif1[0][0].setBounds(506,100,100,25);
    ^
    BaruFrame.java:2440: error: class, interface, or enum expected
    labelLuarAlternatif1[1][0].setBounds(607,100,100,25);
    ^
    BaruFrame.java:2441: error: class, interface, or enum expected
    labelLuarAlternatif1[2][0].setBounds(708,100,100,25);
    ^
    BaruFrame.java:2442: error: class, interface, or enum expected
    labelLuarAlternatif1[3][0].setBounds(809,100,100,25);
    ^
    BaruFrame.java:2443: error: class, interface, or enum expected
    labelLuarAlternatif1[4][0].setBounds(910,100,100,25);
    ^
    BaruFrame.java:2444: error: class, interface, or enum expected
    lanjutlah[0].setBounds(403,300,100,25);
    ^
    BaruFrame.java:2445: error: class, interface, or enum expected
    for (int rows = 0; rows < 5; rows++) { // Iterate through rows.
    ^
    BaruFrame.java:2445: error: class, interface, or enum expected
    for (int rows = 0; rows < 5; rows++) { // Iterate through rows.
    ^
    BaruFrame.java:2445: error: class, interface, or enum expected
    for (int rows = 0; rows < 5; rows++) { // Iterate through rows.
    ^
    BaruFrame.java:2446: error: class, interface, or enum expected
    for (int columns = 0; columns < 5; columns++) { // Iterate through columns

    ^
    BaruFrame.java:2446: error: class, interface, or enum expected
    for (int columns = 0; columns < 5; columns++) { // Iterate through columns

    ^
    BaruFrame.java:2447: error: class, interface, or enum expected
    for (int element = 0; element < jawabAlternatif1.length; element = rows * 5
    + columns) { // Get the position inside the array.
    ^
    BaruFrame.java:2447: error: class, interface, or enum expected
    for (int element = 0; element < jawabAlternatif1.length; element = rows * 5
    + columns) { // Get the position inside the array.
    ^
    BaruFrame.java:2448: error: class, interface, or enum expected
    for (int klofpt = 0; klofpt < jawabAlternatif1[element].length; klofpt++)
    {
    ^
    BaruFrame.java:2448: error: class, interface, or enum expected
    for (int klofpt = 0; klofpt < jawabAlternatif1[element].length; klofpt++)
    {
    ^
    BaruFrame.java:2450: error: class, interface, or enum expected
    jawabAlternatif1[element + 25][klofpt].setBounds (startx + columns *
    zx, starty + rows * dy, 100, 25);
    ^
    BaruFrame.java:2451: error: class, interface, or enum expected
    jawabAlternatif1[element + 50][klofpt].setBounds (startx + columns *
    zx, starty + rows * dy, 100, 25);
    ^
    BaruFrame.java:2452: error: class, interface, or enum expected
    jawabAlternatif1[element + 75][klofpt].setBounds (startx + columns *
    zx, starty + rows * dy, 100, 25);
    ^
    BaruFrame.java:2453: error: class, interface, or enum expected
    }
    ^
    BaruFrame.java:2458: error: class, interface, or enum expected
    perhitunganKriteria[1].setBounds(506,630,200,25);
    ^
    BaruFrame.java:2459: error: class, interface, or enum expected
    for (int tql = 1; tql < 5; tql++){for (int wql = 0; wql < jawabAlternatif1[tql].
    length; wql++){jawabAlternatif1[tql][wql].setEnabled(false);}}
    ^
    BaruFrame.java:2459: error: class, interface, or enum expected
    for (int tql = 1; tql < 5; tql++){for (int wql = 0; wql < jawabAlternatif1[tql].
    length; wql++){jawabAlternatif1[tql][wql].setEnabled(false);}}
    ^
    BaruFrame.java:2459: error: class, interface, or enum expected
    for (int tql = 1; tql < 5; tql++){for (int wql = 0; wql < jawabAlternatif1[tql].
    length; wql++){jawabAlternatif1[tql][wql].setEnabled(false);}}
    ^
    BaruFrame.java:2459: error: class, interface, or enum expected
    for (int tql = 1; tql < 5; tql++){for (int wql = 0; wql < jawabAlternatif1[tql].
    length; wql++){jawabAlternatif1[tql][wql].setEnabled(false);}}
    ^
    BaruFrame.java:2459: error: class, interface, or enum expected
    for (int tql = 1; tql < 5; tql++){for (int wql = 0; wql < jawabAlternatif1[tql].
    length; wql++){jawabAlternatif1[tql][wql].setEnabled(false);}}

    ^
    BaruFrame.java:2459: error: class, interface, or enum expected
    for (int tql = 1; tql < 5; tql++){for (int wql = 0; wql < jawabAlternatif1[tql].
    length; wql++){jawabAlternatif1[tql][wql].setEnabled(false);}}

    ^
    BaruFrame.java:2460: error: class, interface, or enum expected
    for (int tql = 7; tql < 10; tql++){for (int wql = 0; wql < jawabAlternatif1[tql]
    .length; wql++){jawabAlternatif1[tql][wql].setEnabled(false);}}
    ^
    BaruFrame.java:2460: error: class, interface, or enum expected
    for (int tql = 7; tql < 10; tql++){for (int wql = 0; wql < jawabAlternatif1[tql]
    .length; wql++){jawabAlternatif1[tql][wql].setEnabled(false);}}
    ^
    BaruFrame.java:2460: error: class, interface, or enum expected
    for (int tql = 7; tql < 10; tql++){for (int wql = 0; wql < jawabAlternatif1[tql]
    .length; wql++){jawabAlternatif1[tql][wql].setEnabled(false);}}
    ^
    BaruFrame.java:2460: error: class, interface, or enum expected
    for (int tql = 7; tql < 10; tql++){for (int wql = 0; wql < jawabAlternatif1[tql]
    .length; wql++){jawabAlternatif1[tql][wql].setEnabled(false);}}

    ^
    100 errors

    Why was this happening? How to solve this? Why doesn't theJava show these errors?
    Last edited by Tawi; 03-03-2014 at 05:00 PM.

  3. #43
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,401
    Rep Power
    25

    Default Re: How to do this?

    BaruFrame.java:2383: error: illegal start of type
    There is a problem just before line 2383. Probably a misplaced }.

    Can you post the code from just before line 2383 through line 2383? Start at the beginning of the definition of the last method before line 2383.

    A suggestion: Don't type in more than 30 lines of code before doing a compile on that code. That way there will be fewer errors and the errors will be in or because of those 30 lines of code.
    Last edited by Norm; 03-03-2014 at 05:19 PM.
    If you don't understand my response, don't ignore it, ask a question.

  4. #44
    Tawi is offline Senior Member
    Join Date
    Feb 2013
    Posts
    118
    Rep Power
    0

    Default Re: How to do this?

    Quote Originally Posted by Norm View Post
    There is a problem just before line 2383. Probably a misplaced }.

    Can you post the code from just before line 2383 through line 2383? Start at the beginning of the definition of the last method before line 2383.

    A suggestion: Don't type in more than 30 lines of code before doing a compile on that code. That way there will be fewer errors and the errors will be in or because of those 30 lines of code.
    Java Code:
    setLayout(null); 
    for (int ijk = 0; ijk < labelLuarKriteria.length; ijk++) {for (int ikj = 0; ikj < labelLuarKriteria[ijk].length; ikj++) {labelLuarKriteria[ijk][ikj] = new JLabel(); }}
    for (int ijk = 0; ijk < prosesAlternatifInkonsisten.length; ijk++) {prosesAlternatifInkonsisten[ijk] = new JButton("Proses"); }
    for (int ijk = 0; ijk < prosesKriteriaInkonsisten.length; ijk++) {prosesKriteriaInkonsisten[ijk] = new JButton("Proses"); }
    for (int ijk = 0; ijk < alternatifTidakKonsistenSebelumnya.length; ijk++) {alternatifTidakKonsistenSebelumnya[ijk] = new JButton("Kriteria/Alternatif Tidak Konsisten Sebelumnya"); }
    for (int ijk = 0; ijk < kriteriaTidakKonsistenSebelumnya.length; ijk++) {kriteriaTidakKonsistenSebelumnya[ijk] = new JButton("Alternatif Tidak Konsisten Sebelumnya"); }
    for (int ijbak = 0; ijbak < labelLuarAlternatif.length; ijbak++) {for (int ikbaj = 0; ikbaj < labelLuarAlternatif[ijbak].length; ikbaj++) {labelLuarAlternatif[ijbak][ikbaj] = new JLabel(); }}  
    for (int ijbaki = 0; ijbaki < labelLuarAlternatif1.length; ijbaki++) {for (int ikbaji = 0; ikbaji < labelLuarAlternatif1[ijbaki].length; ikbaji++) {labelLuarAlternatif1[ijbaki][ikbaji] = new JLabel(); }}  
    for (int ijak = 0; ijak < labelLuarKriteria1.length; ijak++) {for (int ikaj = 0; ikaj < labelLuarKriteria1[ijak].length; ikaj++) {labelLuarKriteria1[ijak][ikaj] = new JLabel(); }}  
    for (int ijka = 0; ijka < lblKriteria.length; ijka++) {for (int ikja = 0; ikja < lblKriteria[ijka].length; ikja++) {lblKriteria[ijka][ikja] = new String(); }}  
    for (int ijkab = 0; ijkab < lblAlternatif.length; ijkab++) {for (int ikjab = 0; ikjab < lblAlternatif[ijkab].length; ikjab++) {lblAlternatif[ijkab][ikjab] = new String(); }}  
    for (int kijk = 0; kijk < jawabKriteria1.length; kijk++) {for (int kikj = 0; kikj < jawabKriteria1[kijk].length; kikj++) {jawabKriteria1[kijk][kikj] = new JTextField(); }}  
    for (int ijk = 0; ijk < prosesAlternatifInkonsisten.length; ijk++) {prosesAlternatifInkonsisten[ijk].setVisible(false); }
    for (int ijk = 0; ijk < prosesKriteriaInkonsisten.length; ijk++) {prosesKriteriaInkonsisten[ijk].setVisible(false); }
    for (int ijk = 0; ijk < alternatifTidakKonsistenSebelumnya.length; ijk++) {alternatifTidakKonsistenSebelumnya[ijk].setVisible(false); }
    for (int ijk = 0; ijk < kriteriaTidakKonsistenSebelumnya.length; ijk++) {kriteriaTidakKonsistenSebelumnya[ijk].setVisible(false); }
    for (int elementa = 0; elementa < jawabAlternatif1.length; elementa++) {for (int kofpt = 0; kofpt < jawabAlternatif1[elementa].length; kofpt++){
        jawabAlternatif1[elementa][kofpt] = new JTextField();
        jawabAlternatif1[elementa][kofpt].setEnabled(true);
        this.add(jawabAlternatif1[elementa][kofpt]);
    }}}
    for (int up = 0; up < ulang.length; up++) {ulang[up] = false;}
    for (int kli = 0; kli <2;kli++) {
        update[kli] = new JButton("Ubah Paduk Data");
        lanjutlah[kli] = new JButton("Lanjut");
        perhitunganKriteria[kli] = new JButton("Perhitungan Kriteria");
        kmbl[kli] = new JButton("");
        kriteriaLanjut[kli] = new JButton("");
        labelKriteria[kli] = new JLabel("");
        xyz[kli] = 0;    
        kmbl[kli].setVisible(false);
    so?

  5. #45
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,401
    Rep Power
    25

    Default Re: How to do this?

    so?
    That must be a joke. Nobody will look at that mess.

    That code is very POORLY coded.
    There should NEVER be more than one } on a line.
    There should not be more than one statement on a line.
    The code should have indentation that shows the logic levels.

    With the terrible coding style and formatting in that posted code, it is impossible to find the error.

    Correction: It would take someone with more patience than I have. See below:
    Last edited by Norm; 03-04-2014 at 02:57 PM.
    jim829 likes this.
    If you don't understand my response, don't ignore it, ask a question.

  6. #46
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,601
    Rep Power
    5

    Default Re: How to do this?

    I have to admit when I read it I started laughing! Who needs a code obfuscator when it's part of your style?

    Regards,
    Jim
    gimbal2 likes this.
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  7. #47
    gimbal2 is online now Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,000
    Rep Power
    6

    Default Re: How to do this?

    Some people just make a hobby out of making their life as difficult as possible.

    I'll just throw a few random statements at this.

    - compact code is not faster
    - compact code is not more elite
    - compact code is not better
    Last edited by gimbal2; 03-04-2014 at 09:23 AM.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  8. #48
    kneitzel is offline Senior Member
    Join Date
    Feb 2014
    Posts
    447
    Rep Power
    1

    Default Re: How to do this?

    Hi,

    as mentioned by the othes: Please write readable code. Which IDE do you use? All IDE that I know have the automatic spacing inside.

    I just went through your code and changed it:

    Java Code:
            setLayout(null);
            for (int ijk = 0; ijk < labelLuarKriteria.length; ijk++) {
                for (int ikj = 0; ikj < labelLuarKriteria[ijk].length; ikj++) {
                    labelLuarKriteria[ijk][ikj] = new JLabel(); 
                }
            }
            
            for (int ijk = 0; ijk < prosesAlternatifInkonsisten.length; ijk++) {
                prosesAlternatifInkonsisten[ijk] = new JButton("Proses"); 
            }
            
            for (int ijk = 0; ijk < prosesKriteriaInkonsisten.length; ijk++) {
                prosesKriteriaInkonsisten[ijk] = new JButton("Proses"); 
            }
            
            for (int ijk = 0; ijk < alternatifTidakKonsistenSebelumnya.length; ijk++) {
                alternatifTidakKonsistenSebelumnya[ijk] = new JButton("Kriteria/Alternatif Tidak Konsisten Sebelumnya"); 
            }
            
            for (int ijk = 0; ijk < kriteriaTidakKonsistenSebelumnya.length; ijk++) {
                kriteriaTidakKonsistenSebelumnya[ijk] = new JButton("Alternatif Tidak Konsisten Sebelumnya"); 
            }
            
            for (int ijbak = 0; ijbak < labelLuarAlternatif.length; ijbak++) {
                for (int ikbaj = 0; ikbaj < labelLuarAlternatif[ijbak].length; ikbaj++) {
                    labelLuarAlternatif[ijbak][ikbaj] = new JLabel(); 
                }
            } 
            
            for (int ijbaki = 0; ijbaki < labelLuarAlternatif1.length; ijbaki++) {
                for (int ikbaji = 0; ikbaji < labelLuarAlternatif1[ijbaki].length; ikbaji++) {
                    labelLuarAlternatif1[ijbaki][ikbaji] = new JLabel(); 
                }
            }
            
            for (int ijak = 0; ijak < labelLuarKriteria1.length; ijak++) {
                for (int ikaj = 0; ikaj < labelLuarKriteria1[ijak].length; ikaj++) {
                    labelLuarKriteria1[ijak][ikaj] = new JLabel(); 
                }
            }
            
            for (int ijka = 0; ijka < lblKriteria.length; ijka++) {
                for (int ikja = 0; ikja < lblKriteria[ijka].length; ikja++) {
                    lblKriteria[ijka][ikja] = new String(); 
                }
            }
            
            for (int ijkab = 0; ijkab < lblAlternatif.length; ijkab++) {
                for (int ikjab = 0; ikjab < lblAlternatif[ijkab].length; ikjab++) {
                    lblAlternatif[ijkab][ikjab] = new String(); 
                }
            }
            
            for (int kijk = 0; kijk < jawabKriteria1.length; kijk++) {
                for (int kikj = 0; kikj < jawabKriteria1[kijk].length; kikj++) {
                    jawabKriteria1[kijk][kikj] = new JTextField(); 
                }
            }
            
            for (int ijk = 0; ijk < prosesAlternatifInkonsisten.length; ijk++) {
                prosesAlternatifInkonsisten[ijk].setVisible(false); 
            }
            
            for (int ijk = 0; ijk < prosesKriteriaInkonsisten.length; ijk++) {
                prosesKriteriaInkonsisten[ijk].setVisible(false); 
            }
            
            for (int ijk = 0; ijk < alternatifTidakKonsistenSebelumnya.length; ijk++) {
                alternatifTidakKonsistenSebelumnya[ijk].setVisible(false); 
            }
            
            for (int ijk = 0; ijk < kriteriaTidakKonsistenSebelumnya.length; ijk++) {
                kriteriaTidakKonsistenSebelumnya[ijk].setVisible(false); 
            }
            
            for (int elementa = 0; elementa < jawabAlternatif1.length; elementa++) {
                for (int kofpt = 0; kofpt < jawabAlternatif1[elementa].length; kofpt++){
                    jawabAlternatif1[elementa][kofpt] = new JTextField();
                    jawabAlternatif1[elementa][kofpt].setEnabled(true);
                    this.add(jawabAlternatif1[elementa][kofpt]);
                }
            }
        }
    As you can easily see now: There is one { to much.

    First I wanted to not say anything about the logic but I just have to say some words:
    Why do you create so many controls that are not placed? I do not see any reason why it should be usefull to create lots of labels without putting some text that they should show and then place them somewhere. It would be some small, easy to understand code that simply creates the label and then directly uses it as it is intended. But disconnecting that code is simply hard to understand in my eyes.

    Keep stuff together that belongs together.

    But we are already at a completly different problem. Did you solve the first issue? Or did you just move on to more complex stuff without solving the first issue?

    I think it was said before: Always build small parts only and test them properly. If they do exactly what they should do: Move on to the next part. (I do not talk about automatic tests but even that is something that is simply required. That way you can modify working parts and you will have some confidence, that you didn't break stuff.)

    And from what I see, it seems that you overcomplicated the gui. At least you could separate it into multiple parts that are easier to understand and maintain (if it is really required to have something like that.)

    With kind regards,

    Konrad

  9. #49
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,601
    Rep Power
    5

    Default Re: How to do this?

    There is also another problem that is more subtle. Clearly the variables are long and in a foreign language (at least to me). So it is possible that the variable names might differ by one character and I would never know if it was correct or spot an error unless I used an IDE. But that wouldn't work unless I had all the code because I would need the context. And comments would not help me because they too would be in a foreign language.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  10. #50
    Tawi is offline Senior Member
    Join Date
    Feb 2013
    Posts
    118
    Rep Power
    0

    Default Re: How to do this?

    All of the control is needed. The label will be auto set by the user input. I have other problem which is the Java is running very long without any output, how to solve this?

    Here is the code:

    Java Code:
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package proyektesis;
    
    /**
     *
     * @author Tawi
     */
    import java.sql.*;   
    import javax.swing.*;
    
    public class ProyekTesis extends BaruFrame {
    int i; 
    public void connectToDB() { 
                    try {  
                        Class.forName(driver);  
                        connection = DriverManager.getConnection(uniRL, usrname, psswrd);  
                        statusKoneksi.setText("Terhubung ke Paduk Data"); }  
                    catch (Exception x) { 
                        x.printStackTrace();
                        statusKoneksi.setText("Gagal Terhubung ke Paduk Data"); }}
    public ProyekTesis() {
    setLayout(null);
    for (int itlo = 0; itlo < 2; itlo++) {lblPerhitunganKriteria[itlo] = new JLabel("Perhitungan Kriteria"); }
    for (int tlo = 0; tlo < 2; tlo++) {
           kriteria[0][tlo] = new JLabel("Kriteria 1");  
           kriteria[1][tlo] = new JLabel("Kriteria 2");  
           kriteria[2][tlo] = new JLabel("Kriteria 3");  
           kriteria[3][tlo] = new JLabel("Kriteria 4");  
           alternatif[0][tlo] = new JLabel("Alternatif 1");  
           alternatif[1][tlo] = new JLabel("Alternatif 2");  
           alternatif[2][tlo] = new JLabel("Alternatif 3");  
           alternatif[3][tlo] = new JLabel("Alternatif 4");  
           alternatif[4][tlo] = new JLabel("Alternatif 5"); }   
    for (int klof = 0; klof < 5; klof++) {for (int mobil = 0; mobil < 2; mobil++) {jawabAlternatif[klof][mobil] = new JTextField(10); }}
    for (int plof = 0; plof < 4; plof++) {for (int kekar = 0; kekar < 2; kekar++) {jawabKriteria[plof][kekar] = new JTextField(10); }}
    for (int m = 0; m <5; m++)  {for (int prodi = 0; prodi < 2; prodi++)  {
          jawabAlternatif[m][prodi].setEditable(false);    
          jawabAlternatif[m][prodi].setVisible(false); }}  
    for (int hki = 0; hki < 4; hki++)  {for (int hse = 0; hse < 2; hse++) {
          jawabKriteria[hki][hse].setEditable(false);    
          jawabKriteria[hki][hse].setVisible(false);}}   
    kriteria[0][0].setBounds(1,210,100,25);  
    kriteria[1][0].setBounds(1,240,100,25);  
    kriteria[2][0].setBounds(1,270,100,25);  
    kriteria[3][0].setBounds(1,300,100,25);  
    for (int lop = 0; lop < 4; lop++) {add(kriteria[lop][0]); }    
    jawabKriteria[0][0].setBounds(101,210,100,25);  
    jawabKriteria[1][0].setBounds(101,240,100,25);  
    jawabKriteria[2][0].setBounds(101,270,100,25);  
    jawabKriteria[3][0].setBounds(101,300,100,25);  
    for (int jki = 0; jki < 4; jki++) {add(jawabKriteria[jki][0]); }  
    alternatif[0][0].setBounds(200,210,100,25);  
    alternatif[1][0].setBounds(200,240,100,25);  
    alternatif[2][0].setBounds(200,270,100,25);  
    alternatif[3][0].setBounds(200,300,100,25);  
    alternatif[4][0].setBounds(200,330,100,25);  
    for (int loyo = 0; loyo < 5; loyo++) {add(alternatif[loyo][0]); }  
    jawabAlternatif[0][0].setBounds(360,210,70,25);  
    jawabAlternatif[1][0].setBounds(360,240,70,25);  
    jawabAlternatif[2][0].setBounds(360,270,70,25);  
    jawabAlternatif[3][0].setBounds(360,300,70,25);  
    jawabAlternatif[4][0].setBounds(360,330,70,25);  
    for (int gfk = 0; gfk < 5; gfk++) {add(jawabAlternatif[gfk][0]); }  
    stroke.setBounds(0,355,200,25);
    kriteria[0][1].setBounds(1,420,100,25);  
    kriteria[1][1].setBounds(1,450,100,25);  
    kriteria[2][1].setBounds(1,480,100,25);  
    kriteria[3][1].setBounds(1,510,100,25);  
    for (int gdu = 0; gdu < 4; gdu++) {add(kriteria[gdu][1]); }   
    jawabKriteria[0][1].setBounds(101,420,100,25);  
    jawabKriteria[1][1].setBounds(101,450,100,25);  
    jawabKriteria[2][1].setBounds(101,480,100,25);  
    jawabKriteria[3][1].setBounds(101,510,100,25);  
    for (int jku = 0; jku < 4; jku++) {add(jawabKriteria[jku][1]); }  
    alternatif[0][1].setBounds(200,420,100,25);  
    alternatif[1][1].setBounds(200,450,100,25);  
    alternatif[2][1].setBounds(200,480,100,25);  
    alternatif[3][1].setBounds(200,510,100,25);  
    alternatif[4][1].setBounds(200,540,100,25);  
    for (int loyom = 0; loyom < 5; loyom++) {add(alternatif[loyom][1]); }  
    jawabAlternatif[0][1].setBounds(360,420,70,25);  
    jawabAlternatif[1][1].setBounds(360,450,70,25);  
    jawabAlternatif[2][1].setBounds(360,480,70,25);  
    jawabAlternatif[3][1].setBounds(360,510,70,25);  
    jawabAlternatif[4][1].setBounds(360,540,70,25);  
    for (int gfki = 0; gfki < 5; gfki++) {add(jawabAlternatif[gfki][1]); }  
    add(logOff);
    add(lanjut);  
    lanjut.setEnabled(false);  
    lblNama.setBounds(0,10,100,25);  
    add(lblNama);  
    txtNama.setBounds(130,10,200,25);  
    add(txtNama);  
    kataSandi.setBounds(330,10,100,25);  
    add(kataSandi);  
    sandiKata.setBounds(410,10,200,25);  
    add(sandiKata);  
    masuk.setBounds(600,10,100,25);  
    add(masuk);  
    keluar.setBounds(700,10,100,25);  
    add(keluar);  
    myocardialInfarction.setBounds(0,90,200,25);
    lblPerhitunganKriteria[0].setBounds(0, 80, 200, 25);
    lblPerhitunganKriteria[1].setBounds(0, 375, 200, 25);
    for (int celt = 0; celt < 2; celt++) {
        lblPerhitunganKriteria[celt].setVisible(false);
        add(lblPerhitunganKriteria[celt]);
        lanjutlah[celt].setVisible(false);  
        perhitunganKriteria[celt].setVisible(false);  
        kmbl[celt].setVisible(false);  
        update[celt].setVisible(false); 
        kriteriaLanjut[celt].setVisible(false);}
    add(myocardialInfarction);
    tombolHubungkankePadukData.setBounds(0,50,250,25);  
    add(tombolHubungkankePadukData);  
    putuskanKoneksiKePadukData.setBounds(250,50,250,25);  
    add(putuskanKoneksiKePadukData);  
    tombolUbahPadukData.setBounds(480,50,250,25);  
    add(tombolUbahPadukData);  
    tombolBatal.setBounds(730,50,250,25);  
    add(tombolBatal);  
    statusKoneksi.setBounds(800,10,200,25);  
    add(statusKoneksi);  
    statusMasuk.setBounds(0,70,200,25);
    add(statusMasuk);
    tombolHubungkankePadukData.setEnabled(false);  
    putuskanKoneksiKePadukData.setEnabled(false);  
    tombolUbahPadukData.setEnabled(false);    
    tombolBatal.setEnabled(false);   
    statusKoneksi.setVisible(true);  
    lblNama.setVisible(true);  
    txtNama.setVisible(true);  
    kataSandi.setVisible(true);  
    sandiKata.setVisible(true);  
    masuk.setVisible(true);  
    keluar.setVisible(true);
    awal.setVisible(false);
    tombolHubungkankePadukData.setVisible(true);  
    putuskanKoneksiKePadukData.setVisible(true);  
    tombolUbahPadukData.setVisible(true);  
    tombolBatal.setVisible(true);  
    lanjut.setBounds(880,560,100,25);  
    add(lanjut);  
    lanjut.setEnabled(false);
    lanjut.setVisible(false);  
    jcboURL.setVisible(true);  
    jcboDriver.setVisible(true);  
    statusKoneksi.setVisible(true);
    padukData.setVisible(true);  
    myocardialInfarction.setVisible(false);  
    stroke.setVisible(false);  
    add(stroke); 
    for (int hklma = 0; hklma < kriteria.length; hklma++) {for (int kloaka = 0; kloaka < 2; kloaka++){kriteria[hklma][kloaka].setVisible(false); }}  
    for (int hklma = 0; hklma < alternatif.length; hklma++) {for (int kock = 0; kock <2; kock++) {alternatif[hklma][kock].setVisible(false);}}     
    statusMasuk.setVisible(true);  
    ubah.setVisible(false);  
    for (int hklma = 0; hklma < jawabKriteria1.length; hklma++) {for (int nyola = 0; nyola < jawabKriteria1[hklma].length; nyola++) {jawabKriteria1[hklma][nyola].setVisible(false); }}  
    for (int hklma = 0; hklma < jawabAlternatif1.length; hklma++) {for (int nyola = 0; nyola < jawabAlternatif1[hklma].length; nyola++) {jawabAlternatif1[hklma][nyola].setVisible(false); }}  
    for (int hklma = 0; hklma < labelLuarKriteria.length; hklma++) {for (int nyola = 0; nyola < labelLuarKriteria[hklma].length; nyola++) {labelLuarKriteria[hklma][nyola].setVisible(false); }}  
    for (int hklma = 0; hklma < labelLuarAlternatif.length; hklma++) {for (int nyola = 0; nyola < labelLuarAlternatif[hklma].length; nyola++) {labelLuarAlternatif[hklma][nyola].setVisible(false); }}  
    for (int hklma = 0; hklma < labelLuarAlternatif1.length; hklma++) {for (int nyola = 0; nyola < labelLuarAlternatif1[hklma].length; nyola++) {labelLuarAlternatif1[hklma][nyola].setVisible(false); }}  
    for (int hklm = 0; hklm < labelLuarKriteria1.length; hklm++) {for (int nyol = 0; nyol < labelLuarKriteria1[hklm].length; nyol++) {labelLuarKriteria1[hklm][nyol].setVisible(false); }}  
    masuk.addActionListener(new java.awt.event.ActionListener() {  
                String loginName;  
                String loginPassword;    
                String passwrd;
                @Override  
                public void actionPerformed(java.awt.event.ActionEvent evt) {  
                    usrname = txtNama.getText().trim();  
                    psswrd = new String(sandiKata.getPassword());
                    for (int celtf = 0; celtf < 2; celtf++) {lblPerhitunganKriteria[celtf].setVisible(false); }
                    if (("".equals(usrname)) && ("".equals(psswrd)))  {  
                                   tombolHubungkankePadukData.setEnabled(false);  
                                   putuskanKoneksiKePadukData.setEnabled(false);  
                                   tombolUbahPadukData.setEnabled(false);  
                                   tombolBatal.setEnabled(false);  
                                   masuk.setEnabled(true);
                                   statusKoneksi.setText(fx);
                                   keluar.setEnabled(true);  
                                   putuskanKoneksiKePadukData.setEnabled(false); 
                                   JOptionPane.showMessageDialog(null, cx, ex, JOptionPane.INFORMATION_MESSAGE); }  
                    else if ((!"".equals(usrname)) && ("".equals(psswrd))) {  
                                   JOptionPane.showMessageDialog(null, ax, ex, JOptionPane.INFORMATION_MESSAGE);  
                                   tombolHubungkankePadukData.setEnabled(false);  
                                   putuskanKoneksiKePadukData.setEnabled(false);  
                                   tombolUbahPadukData.setEnabled(false);  
                                   tombolBatal.setEnabled(false); 
                                   masuk.setEnabled(true);
                                   statusKoneksi.setText(fx);
                                   keluar.setEnabled(true);  
                                   putuskanKoneksiKePadukData.setEnabled(false); }  
                    else if ((("".equals(usrname)) && (!"".equals(psswrd)))) {      
                                   tombolHubungkankePadukData.setEnabled(false);  
                                   putuskanKoneksiKePadukData.setEnabled(false);  
                                   tombolUbahPadukData.setEnabled(false);  
                                   tombolBatal.setEnabled(false);  
                                   keluar.setEnabled(true);  
                                   masuk.setEnabled(true);
                                   statusKoneksi.setText(fx);
                                   putuskanKoneksiKePadukData.setEnabled(false);  
                                   JOptionPane.showMessageDialog(null, bx, ex, JOptionPane.INFORMATION_MESSAGE); }       
                    else if ((!"".equals(usrname)) && (!"".equals(psswrd))) {connectToDB(); }
                    masuklah(); }  
                private void masuklah() {  
                    try {
                        if (connection.isClosed()) {  
                            masuk.setEnabled(true);  
                            entryPrg(); }  
                        else {
                            masuk.setEnabled(false);
                            entryPrg(); }
                    } catch (SQLException ex) {ex.printStackTrace(); }}   
                private void entryPrg() {  
                          connectToDB();
                          try {
                              statement = connection.createStatement();
                              pernyataan = connection.createStatement();
                              loginName = "select Nama_Dokter from tblDokterAhli where Nama_Dokter = '"+usrname+"'";  
                              loginPassword = "select Kata_Kunci from tblDokterAhli where Kata_Kunci = '"+psswrd+"' and Nama_Dokter = '"+usrname+"'";
                              ResultSet logName = statement.executeQuery(loginName);  
                              ResultSet logPassword = pernyataan.executeQuery(loginPassword);
                              while (logName.next()) {namaPengguna1 = logName.getString("Nama_Dokter"); }  
                              while (logPassword.next()) {passwordPengguna1 = logPassword.getString("Kata_Kunci"); }  
                              if ((!"".equals(namaPengguna1)) && (!"".equals(passwordPengguna1))) {  
                                   tombolHubungkankePadukData.setEnabled(true);  
                                   putuskanKoneksiKePadukData.setEnabled(true);  
                                   tombolUbahPadukData.setEnabled(true);  
                                   tombolBatal.setEnabled(true);  
                                   masuk.setEnabled(false);
                                   statusKoneksi.setText("Belum Terhubung ke Paduk Data");
                                   statusMasuk.setText("Sudah Masuk");
                                   keluar.setEnabled(true);  
                                   putuskanKoneksiKePadukData.setEnabled(true);  
                                   statement.close();
                                   connection.close();
                                   connection = null;
                                   pernyataan.close(); }  
                              else if (("".equals(namaPengguna1)) && (!"".equals(passwordPengguna1))) {  
                                   tombolHubungkankePadukData.setEnabled(false);  
                                   putuskanKoneksiKePadukData.setEnabled(false);  
                                   tombolUbahPadukData.setEnabled(false);  
                                   tombolBatal.setEnabled(false);  
                                   keluar.setEnabled(true);
                                   masuk.setEnabled(true);
                                   statusKoneksi.setText(fx);
                                   putuskanKoneksiKePadukData.setEnabled(false);  
                                   JOptionPane.showMessageDialog(null, dx, ex, JOptionPane.INFORMATION_MESSAGE);  
                                   connection.close();
                                   connection = null;
                                   statement.close();
                                   pernyataan.close(); }  
                             else if ((!"".equals(namaPengguna1)) && ("".equals(passwordPengguna1))) {  
                                   tombolHubungkankePadukData.setEnabled(false);  
                                   putuskanKoneksiKePadukData.setEnabled(false);  
                                   tombolUbahPadukData.setEnabled(false);  
                                   tombolBatal.setEnabled(false);
                                   masuk.setEnabled(true);
                                   statusKoneksi.setText(fx);
                                   keluar.setEnabled(true);  
                                   putuskanKoneksiKePadukData.setEnabled(false);  
                                   JOptionPane.showMessageDialog(null, dx, ex, JOptionPane.INFORMATION_MESSAGE);  
                                   connection.close();
                                   connection = null;
                                   statement.close();
                                   pernyataan.close(); }
                             else if (("".equals(namaPengguna1)) && ("".equals(passwordPengguna1)))  {  
                                   tombolHubungkankePadukData.setEnabled(false);  
                                   putuskanKoneksiKePadukData.setEnabled(false);  
                                   tombolUbahPadukData.setEnabled(false);  
                                   tombolBatal.setEnabled(false);
                                   masuk.setEnabled(true);
                                   statusKoneksi.setText(fx);
                                   keluar.setEnabled(true);  
                                   putuskanKoneksiKePadukData.setEnabled(false);  
                                   JOptionPane.showMessageDialog(null, dx, ex, JOptionPane.INFORMATION_MESSAGE);  
                                   connection.close();
                                   connection = null;
                                   statement.close();
                                   pernyataan.close(); }}  
                          catch (java.lang.Exception ex){ 
                              ex.printStackTrace();
                              statusMasuk.setText("Gagal Masuk");  }}});
    putuskanKoneksiKePadukData.addActionListener(new java.awt.event.ActionListener() {  
                @Override  
                public void actionPerformed(java.awt.event.ActionEvent evt) {  
                    try {putuskan(); } catch (SQLException ex) {ex.printStackTrace();}}  
                private void putuskan() throws SQLException {      
                    if (connection != null)  {  
                         statusKoneksi.setText("Koneksi ke Paduk Data sudah Terputus");  
                      for (int lko = 0; lko < 4; lko++) {for (int ten = 0; ten < 2; ten++) {
                              kriteria[lko][ten].setVisible(false);
                              jawabKriteria[lko][ten].setEditable(false);  
                              jawabKriteria[lko][ten].setVisible(false); }}  
                      for (int lok = 0; lok < 5; lok++) {for (int songo = 0; songo < 2; songo++) {
                             alternatif[lok][songo].setVisible(false);
                             jawabAlternatif[lok][songo].setEditable(false);   
                             jawabAlternatif[lok][songo].setVisible(false); }}      
                      connection.close();
                      connection = null;
                      statement.close();
                      pernyataan.close();
                      lanjut.setVisible(false);
                      lanjut.setEnabled(false);}
                    else {
                       statusKoneksi.setText(fx);  
                       myocardialInfarction.setVisible(false);
                       stroke.setVisible(false);
                       for (int ltu = 0; ltu < 4; ltu++) {for (int wolu = 0; wolu < 2; wolu++) {
                               kriteria[ltu][wolu].setVisible(false);
                               jawabKriteria[ltu][wolu].setEditable(false);  
                               jawabKriteria[ltu][wolu].setVisible(false); }}  
                       for (int tlu = 0; tlu < 5; tlu++) {for (int papat = 0; papat < 2; papat++) {
                               jawabAlternatif[tlu][papat].setEditable(false);  
                               jawabAlternatif[tlu][papat].setVisible(false);  
                               alternatif[tlu][papat].setVisible(false); }}}  
                    myocardialInfarction.setVisible(false);
                    stroke.setVisible(false); }});  
    keluar.addActionListener(new java.awt.event.ActionListener() {  
             @Override  
             public void actionPerformed(java.awt.event.ActionEvent evt) {keluar();}  
             private void keluar() {System.exit(0);}});  
    tombolHubungkankePadukData.addActionListener(new java.awt.event.ActionListener() {  
                @Override  
                public void actionPerformed(java.awt.event.ActionEvent evt) {  
                        if (connection != null) {statusKoneksi.setText("Sudah Terhubung ke Paduk Data");}  
                        else {connectToDB(); }}});  
    tombolBatal.addActionListener(new java.awt.event.ActionListener() {  
                @Override  
                public void actionPerformed(java.awt.event.ActionEvent evt) {batal();  }  
                private void batal() { 
                        if (connection != null) {                      
                          myocardialInfarction.setVisible(false);
                          stroke.setVisible(false);
                          for (int k = 0; k < 4; k++)  {for (int kipas = 0; kipas < 2; kipas++) {
                                jawabKriteria[k][kipas].setText("");   
                                kriteria[k][kipas].setVisible(false); }}  
                          for (int lkm = 0; lkm < 5; lkm++) {for (int kitas = 0; kitas < 2; kitas++) {
                                jawabAlternatif[lkm][kitas].setText("");  
                                alternatif[lkm][kitas].setVisible(false); }}  
                          for (int lqj = 0; lqj < 4; lqj++) {for (int lopker = 0; lopker < 2; lopker++) {
                                jawabKriteria[lqj][lopker].setEditable(false);  
                                jawabKriteria[lqj][lopker].setVisible(false); }}  
                          for (int ljq = 0; ljq < 5; ljq++) {for (int klopker = 0; klopker < 2; klopker++){
                                jawabAlternatif[ljq][klopker].setEditable(false);    
                                jawabAlternatif[ljq][klopker].setVisible(false); }}
                                lanjut.setEnabled(false); 
                                lanjut.setVisible(false);}
                        else {JOptionPane.showMessageDialog(null, "Hubungkan Dahulu ke Paduk Data", fx, JOptionPane.INFORMATION_MESSAGE); }}});  
    lanjut.addActionListener(new java.awt.event.ActionListener() {  
          @Override  
          public void actionPerformed(java.awt.event.ActionEvent evt) {kontinu(); }  
          private void kontinu() {  
              setSize(1024,768);  
              setVisible(true);
              setTitle("Penghitungan Data");
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
              setLocationRelativeTo(null);  
              String[][] passCriteriaVariables = new String[4][2];  
              String[][] passAlternativeVariables = new String[5][2];  
              for (int ijkl = 0; ijkl < passCriteriaVariables.length; ijkl++) {for (int ikjl = 0; ikjl < passCriteriaVariables[ijkl].length; ikjl++) {passCriteriaVariables[ijkl][ikjl] = new String(); }}  
              for (int aijkl = 0; aijkl < 4; aijkl++) {for (int aikjl = 0; aikjl < 2; aikjl++) {passCriteriaVariables[aijkl][aikjl] = jawabKriteria[aijkl][aikjl].getText();  }}  
              for (int laijkl = 0; laijkl < passAlternativeVariables.length; laijkl++) {for (int laikjl = 0; laikjl < passAlternativeVariables[laijkl].length; laikjl++) {passAlternativeVariables[laijkl][laikjl] = new String(); }}  
              for (int lijkl = 0; lijkl < 5; lijkl++) {for (int likjl = 0; likjl < 2; likjl++) {passAlternativeVariables[lijkl][likjl] = jawabAlternatif[lijkl][likjl].getText(); }}  
              posisiKriteria();
              lblKriteria = passCriteriaVariables;
              lblAlternatif = passAlternativeVariables;
              for (int olp = 0; olp <4; olp++) {  
                   labelLuarKriteria[olp][0].setText(lblKriteria[olp][0]);  
                   labelLuarKriteria1[olp][0].setText(lblKriteria[olp][0]); }  
              for (int olt = 0; olt < 4; olt++) {  
                   labelLuarKriteria[olt][1].setText(lblKriteria[olt][1]);  
                   labelLuarKriteria1[olt][1].setText(lblKriteria[olt][1]); }  
              for (int yul = 0; yul < 4; yul++) {
                   labelLuarKriteria[yul][0].setVisible(true);  
                   labelLuarKriteria1[yul][0].setVisible(true);  
                   labelLuarKriteria[yul][1].setVisible(true);  
                   labelLuarKriteria1[yul][1].setVisible(true);}
              logOff.setBounds(506,700,200,25);
              lblNama.setVisible(false);  
              txtNama.setVisible(false);  
              kataSandi.setVisible(false);  
              sandiKata.setVisible(false);  
              masuk.setVisible(false);  
              keluar.setVisible(false); 
              awal.setVisible(true);
              myocardialInfarction.setBounds(0,60,200,25);
              tombolHubungkankePadukData.setVisible(false);  
              putuskanKoneksiKePadukData.setVisible(false);  
              tombolUbahPadukData.setVisible(false);  
              tombolBatal.setVisible(false);  
              lanjut.setVisible(false);  
              jcboURL.setVisible(false);  
              jcboDriver.setVisible(false);  
              statusKoneksi.setVisible(false);  
              padukData.setVisible(false);  
              myocardialInfarction.setVisible(true);  
              stroke.setVisible(true);  
              for (int hklma = 0; hklma < kriteria.length; hklma++) {for (int nyola = 0; nyola < kriteria[hklma].length; nyola++) {kriteria[hklma][nyola].setVisible(false); }}  
              for (int hklmaf = 0; hklmaf < jawabAlternatif1.length; hklmaf++) {for (int nyolaf = 0; nyolaf < jawabAlternatif1[hklmaf].length; nyolaf++) {jawabAlternatif1[hklmaf][nyolaf].setVisible(false); }}  
              for (int hklma = 0; hklma < alternatif.length; hklma++) {for (int nyola = 0; nyola < alternatif[hklma].length; nyola++) {alternatif[hklma][nyola].setVisible(false); }}  
              statusMasuk.setVisible(false);  
              for (int celta = 0; celta < lblPerhitunganKriteria.length; celta++) {lblPerhitunganKriteria[celta].setVisible(true); } 
              ubah.setVisible(true);
              for (int okb = 0; okb < 2; okb++){
                  lanjutlah[okb].setVisible(true);  
                  perhitunganKriteria[okb].setVisible(false);  
                  kmbl[okb].setVisible(false);  
                  update[okb].setVisible(false);  
                  kriteriaLanjut[okb].setVisible(false); 
                  jawabKriteria1[0][okb].setEnabled(false);
                  jawabKriteria1[0][okb].setVisible(true);
                  jawabKriteria1[0][okb].setText("1");
                  jawabKriteria1[5][okb].setEnabled(false);
                  jawabKriteria1[5][okb].setVisible(true);
                  jawabKriteria1[5][okb].setText("1");
                  jawabKriteria1[10][okb].setEnabled(false);
                  jawabKriteria1[10][okb].setVisible(true);
                  jawabKriteria1[10][okb].setText("1");
                  jawabKriteria1[15][okb].setEnabled(false);
                  jawabKriteria1[15][okb].setVisible(true);
                  jawabKriteria1[15][okb].setText("1");}  
              logOff.setVisible(true);
              for (int tql = 1; tql < 4; tql++){for (int wql = 0; wql < jawabKriteria1[tql].length; wql++){
                   jawabKriteria1[tql][wql].setEnabled(false);
                   jawabKriteria1[tql][wql].setVisible(true);}}
              for (int tql = 6; tql < 8; tql++){for (int wql = 0; wql < jawabKriteria1[tql].length; wql++){
                   jawabKriteria1[tql][wql].setEnabled(false);
                   jawabKriteria1[tql][wql].setVisible(true);}}
              for (int wql = 0; wql < jawabKriteria1[11].length; wql++){
                   jawabKriteria1[11][wql].setEnabled(false);
                   jawabKriteria1[11][wql].setVisible(true);}     
              for (int hklma = 12; hklma < 15; hklma++) {for (int kliop = 0; kliop < jawabKriteria1[hklma].length; kliop++) {
                   jawabKriteria1[hklma][kliop].setVisible(true); 
                   jawabKriteria1[hklma][kliop].setText("");
                   jawabKriteria1[hklma][kliop].setEnabled(true);}}
              for (int hklma = 8; hklma < 10; hklma++) {for (int kliop = 0; kliop < jawabKriteria1[hklma].length; kliop++) {
                   jawabKriteria1[hklma][kliop].setText("");
                   jawabKriteria1[hklma][kliop].setEnabled(true);
                   jawabKriteria1[hklma][kliop].setVisible(true);}}
              for (int kliop = 0; kliop < jawabKriteria1[4].length; kliop++) {
                   jawabKriteria1[4][kliop].setVisible(true); 
                   jawabKriteria1[4][kliop].setText("");
                   jawabKriteria1[4][kliop].setEnabled(true); }
              for (int hklma = 0; hklma < labelLuarKriteria.length; hklma++) {for (int nyola = 0; nyola < labelLuarKriteria[hklma].length; nyola++) {labelLuarKriteria[hklma][nyola].setVisible(true); }}  
              for (int hklma = 0; hklma < labelLuarAlternatif.length; hklma++) {for (int nyola = 0; nyola < labelLuarAlternatif[hklma].length; nyola++) {labelLuarAlternatif[hklma][nyola].setVisible(true); }}  
              for (int hklma = 0; hklma < labelLuarAlternatif1.length; hklma++) {for (int nyola = 0; nyola < labelLuarAlternatif1[hklma].length; nyola++) {labelLuarAlternatif1[hklma][nyola].setVisible(true); }}  
              for (int hklm = 0; hklm < labelLuarKriteria1.length; hklm++) {for (int nyol = 0; nyol < labelLuarKriteria1[hklm].length; nyol++) {labelLuarKriteria1[hklm][nyol].setVisible(true); }}  
              for (int hklmg = 0; hklmg < jawabKriteria.length; hklmg++) {for (int nyolg = 0; nyolg < jawabKriteria[hklmg].length; nyolg++) {jawabKriteria[hklmg][nyolg].setVisible(false); }}  
              for (int hklmga = 0; hklmga < jawabAlternatif.length; hklmga++) {for (int nyolga = 0; nyolga < jawabAlternatif[hklmga].length; nyolga++) {jawabAlternatif[hklmga][nyolga].setVisible(false); }}}}); //FrameBaru baru = new FrameBaru(passCriteriaVariables, passAlternativeVariables); // I want to make a class that is named FrameBaru to be visible   
    tombolUbahPadukData.addActionListener(new java.awt.event.ActionListener() {  
       @Override  
       public void actionPerformed(java.awt.event.ActionEvent evt) {  
           try {ubah();
           } catch (SQLException ex) {
               ex.printStackTrace();
               statusKoneksi.setText("Gagal Terhubung dengan Paduk Data"); }}   
       private void ubah() throws SQLException { 
               if (connection != null) {
                      for (int lmo = 0; lmo < 4; lmo++) {  
                          for (int jmo = 0; jmo < 2; jmo++){
                              jawabKriteria[lmo][jmo].setEditable(true);
                              jawabKriteria[lmo][jmo].setVisible(true);
                              jawabKriteria[lmo][jmo].setText("");
                              kriteria[lmo][jmo].setVisible(true); 
                              kriteria[lmo][jmo].setEnabled(true);}}  
                     for (int mlo = 0; mlo < 5; mlo++)  {
                         for (int hlok = 0; hlok < 2; hlok++) {
                              jawabAlternatif[mlo][hlok].setEditable(true);  
                              jawabAlternatif[mlo][hlok].setVisible(true);
                              jawabAlternatif[mlo][hlok].setText("");
                              alternatif[mlo][hlok].setVisible(true);
                              alternatif[mlo][hlok].setEnabled(true); }}  
                     lanjut.setEnabled(true); 
                     lanjut.setVisible(true);
                     logOff.setBounds(880,600,100,25);
                     logOff.setVisible(true);
                     myocardialInfarction.setBounds(0, 160, 200, 25);
                     myocardialInfarction.setVisible(true);
                     stroke.setVisible(true); }
               else {JOptionPane.showMessageDialog(null, "Hubungkan Dahulu ke Paduk Data", fx, JOptionPane.INFORMATION_MESSAGE); }}});}
    public static void main(String[] args) {  
            ProyekTesis tesis = new ProyekTesis();   
            tesis.setTitle("Program Pemilihan Obat dengan Cara Analytic Hierarchycal Process");  
            tesis.setSize(1024,768);  
            tesis.setVisible(true);  
            tesis.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
            tesis.setLocationRelativeTo(null); }}
    You can see the BaruFrame.java in:
    http://www.tawijakarta.blogspot.com under the title "Program Ralat".

    Please test the code.
    Last edited by Tawi; 03-04-2014 at 04:56 PM.

  11. #51
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,401
    Rep Power
    25

    Default Re: How to do this?

    other problem which is the Java is running very long without any output, how to solve this?
    Use the debugging techniques described many times earlier.
    Add lots of println() statements which create output so that the code does not run "without output" and so you can see where the code is executing and if it is executing in a long running loop.


    If you expect anyone else to test this code, you need to remove:
    the BaruFrame class
    and the database usage

    so that the code with the problem can be compiled and executed.
    Last edited by Norm; 03-04-2014 at 04:34 PM.
    If you don't understand my response, don't ignore it, ask a question.

  12. #52
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    946
    Rep Power
    2

    Default Re: How to do this?

    I wish I could help, but my eyes are bleeding.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2™ © 2013

  13. #53
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,401
    Rep Power
    25

    Default Re: How to do this?

    You should warn the others to stay back. My cataracts are thick enough to withstand this kind of stuff.
    If you don't understand my response, don't ignore it, ask a question.

  14. #54
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,601
    Rep Power
    5

    Default Re: How to do this?

    Actually, we are all on Candid Camera (---> showing my age) :)

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  15. #55
    gimbal2 is online now Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,000
    Rep Power
    6

    Default Re: How to do this?

    Quote Originally Posted by jim829 View Post
    Actually, we are all on Candid Camera (---> showing my age) :)

    Regards,
    Jim
    Hey, I've seen that show too :(

    SMILE!
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  16. #56
    Tawi is offline Senior Member
    Join Date
    Feb 2013
    Posts
    118
    Rep Power
    0

    Default Re: How to do this?

    I put plenty of printlns in BaruFrame. I do not have any problems other than NPE in ProyekTesis. Because it is an integrated program, I put it in here, so? What is the solution? If you do not trust me, click the link, you can find plenty of printlns, are that not enough? How many shall I create?

  17. #57
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,401
    Rep Power
    25

    Default Re: How to do this?

    How many shall I create?
    Keep adding them until you find the problem.

    What was the last println() that printed on the console? What code is between that last println() that printed and the next println() that did not print? I would suspect that is where the code is hanging.

    NPE in ProyekTesis
    Copy the full text of the error message and paste it here if you need help. The error message says where the error happened. Look at that line and find the variable with the null value.
    Last edited by Norm; 03-04-2014 at 05:41 PM.
    If you don't understand my response, don't ignore it, ask a question.

  18. #58
    Tawi is offline Senior Member
    Join Date
    Feb 2013
    Posts
    118
    Rep Power
    0

    Default Re: How to do this?

    Nothing is happening after I run the code so?

  19. #59
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,401
    Rep Power
    25

    Default Re: How to do this?

    Nothing is happening after I run the code so?
    That means you do NOT have the println() statements in the correct place.
    Add a println() after line 484 at the first line in the main() method. If that doesn't print, that means that you are NOT executing the code that you are making changes to.
    Add a second println() after line 24 the first thing in the constructor. If that doesn't print, there could be a problem in the super class's constructor.
    Last edited by Norm; 03-04-2014 at 06:00 PM.
    If you don't understand my response, don't ignore it, ask a question.

  20. #60
    Tawi is offline Senior Member
    Join Date
    Feb 2013
    Posts
    118
    Rep Power
    0

    Default Re: How to do this?

    Quote Originally Posted by Norm View Post
    That means you do NOT have the println() statements in the correct place.
    Add a println() after line 484 at the first line in the main() method. If that doesn't print, that means that you are NOT executing the code that you are making changes to.
    Add a second println() after line 24 the first thing in the constructor. If that doesn't print, there could be a problem in the super class's constructor.

    At BaruFrame or ProyekTesis?

Page 3 of 11 FirstFirst 12345 ... LastLast

Posting Permissions

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