Results 1 to 9 of 9
  1. #1
    mathansj is offline Member
    Join Date
    Feb 2009
    Posts
    9
    Rep Power
    0

    Exclamation Please post your suggestions about this code

    Hi

    I am developing one java project ..... i need some suggestions regarding the code which i have return .......

    creating new department group for a company ...... please post ur suggestions on this coding standard.....
    Last edited by mathansj; 02-15-2009 at 04:37 PM.

  2. #2
    ramsrocker is offline Member
    Join Date
    Feb 2009
    Posts
    48
    Rep Power
    0

    Default

    owww my head! ; (

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Suggestion number one: when posting your code, please use code tags so that your code will retain its formatting and be readable. To do this, you will need to paste already formatted code into the forum, highlight this code, and then press the "code" button at the top of the forum Message editor prior to posting the message. Another way is to place the tag [code] at the top of your block of code and the tag [/code] at the bottom, like so:

    Java Code:
    [code]
      // your code block goes here.
      // note the differences between the tag at the top vs the bottom.
    [/code]
    This will increase the number of folks who read your post and thus increases your chances of getting help. HTH though YMMV.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Other suggestions:
    i need some suggestions regarding the code which i have return .........
    please post ur suggestions on this coding standard
    I'm hopeful that someone knowledgeable will read your post and help you, but if not, or if not enough, please note that you'll get more specific and helpful answers if you ask specific questions. Again YMMV. Again, best of luck.

  5. #5
    mathansj is offline Member
    Join Date
    Feb 2009
    Posts
    9
    Rep Power
    0

    Default

    I Just formatted ....


    Java Code:
    
    public class GLDeptSubGroup extends JDialog {
        private BorderLayout layoutMain = new BorderLayout();
        private JToolBar toolBar = new JToolBar();
        JButton buttonNew = new JButton();
        private JButton buttonEdit = new JButton();
        private JButton buttonExit = new JButton();
        private String[] columnNames =
        { "Code", "Department", "Group", "Created By", "Date" };
        private Object[][] data;
        JScrollPane panelCenter = new JScrollPane();
    
        public DefaultTableModel model;
        private JTable tblDepartment;
    
        public GLDeptSubGroup() {
        }
    
        public GLDeptSubGroup(JDialog parent, String title, boolean modal) {
            super(parent, title, modal);
            try {
                jbInit();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    
        public GLDeptSubGroup(Frame parent, String title, boolean modal) {
            super(parent, title, modal);
            try {
                jbInit();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    
        private void jbInit() throws Exception {
            this.getContentPane().setLayout(layoutMain);
            this.setSize(new Dimension(487, 300));
    
            this.addWindowListener(new WindowAdapter() {
                    public void windowActivated(WindowEvent e) {
                        this_windowActivated(e);
                    }
                });
            buttonNew.setText("     New     ");
            buttonNew.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        buttonNew_actionPerformed(e);
                    }
                });
            buttonEdit.setText("     Edit     ");
            buttonEdit.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        buttonEdit_actionPerformed(e);
                    }
                });
            buttonExit.setText("     Exit     ");
            buttonExit.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        buttonExit_actionPerformed(e);
                    }
                });
    
    
            toolBar.add(buttonNew);
            toolBar.add(buttonEdit);
            toolBar.add(buttonExit);
    
            panelCenter.setBorder(BorderFactory.createLineBorder(Color.black, 1));
            this.getContentPane().add(toolBar, BorderLayout.NORTH);
            this.getContentPane().add(panelCenter, BorderLayout.CENTER);
        }
    
        private void fillData() {
            model = new DefaultTableModel(data, columnNames) {
                    public boolean isCellEditable(int rowIndex, int mColIndex) {
                        return false;
                    }
                };
            tblDepartment = new JTable(model);
            tblDepartment.setAutoscrolls(true);
            tblDepartment.setRowSelectionAllowed(true);
            tblDepartment.removeEditor();
            tblDepartment.addMouseListener(new MouseAdapter() {
                    public void mouseClicked(MouseEvent e) {
                        if ((e.getClickCount() == 2) && (!buttonNew.isEnabled())) {
                            getSelected();
                        }
                    }
                });
    
            tblDepartment.setGridColor(new Color(165, 165, 165));
            tblDepartment.setForeground(new Color(0, 49, 82));
            tblDepartment.setFont(new Font("Arial", 0, 12));
            tblDepartment.setRowMargin(2);
    
            try {
                SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy");
                dbConnect dbCon = new dbConnect();
                Connection conn = dbCon.Con;
                String strSQL;
                strSQL =
                        "select DEPT_CODE,DEPT_NAME," + "DEPT_GROUPS.DEPT_GROUP_NAME," +
                        "PAYROLL.FN_GET_EMPNAME(DEPT_CREATED_BY)," +
                        "DEPT_CREATED_DATE " +
                        "from DEPT_GROUPS,DEPT_MASTERS where " +
                        "DEPT_MASTERS.DEPT_GROUP_CODE=DEPT_GROUPS.DEPT_GROUP_CODE " +
                        "Order by DEPT_NAME";
                Statement theStatement = conn.createStatement();
                ResultSet theResult =
                    theStatement.executeQuery(strSQL); //Select GRN
                while (theResult.next()) {
                    model.insertRow(tblDepartment.getRowCount(),
                                    new Object[] { theResult.getString(1),
                                                   theResult.getString(2),
                                                   theResult.getString(3),
                                                   theResult.getString(4),
                                                   sdf.format(theResult.getDate(5)) });
                }
                theResult.close(); //Close the result set
                theStatement.close(); //Close statement
                conn.close();
            } catch (Exception e) {
                System.out.println(e);
            }
    
            tblDepartment.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    
            for (int i = 0; i < tblDepartment.getColumnCount(); i++) {
                TableColumn col = tblDepartment.getColumnModel().getColumn(i);
                switch (i) {
                case 0:
                    col.setPreferredWidth(75);
                    break;
                case 1:
                    col.setPreferredWidth(175);
                    break;
                case 2:
                    col.setPreferredWidth(75);
                    break;
                }
            }
            tblDepartment.addNotify();
            panelCenter.getViewport().add(tblDepartment, null);
            panelCenter.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
            panelCenter.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
            panelCenter.setAutoscrolls(true);
            panelCenter.setVisible(true);
        }
    
        private void buttonNew_actionPerformed(ActionEvent e) {
            GLDeptSubGroupNew GLSGNew =
                new GLDeptSubGroupNew(this, "Department - Create New Department",
                                      true);
            GLSGNew.bInsertFlag = true;
            GLSGNew.setLocationRelativeTo(this);
            GLSGNew.setVisible(true);
        }
    
        private void getSelected() {
            GLGetDetails GLD =
                new GLGetDetails((String)tblDepartment.getValueAt(tblDepartment.getSelectedRow(),
                                                                  0));
            GLD.setDepartmentSubGroups();
            this.dispose();
        }
    
        private void buttonEdit_actionPerformed(ActionEvent e) {
            if (tblDepartment.getSelectedRow() < 0) {
                JOptionPane.showMessageDialog(null,
                                              "Please select one record to edit",
                                              "Edit - Selection",
                                              JOptionPane.ERROR_MESSAGE);
                return;
            }
            GLDeptSubGroupNew GLSGEdit =
                new GLDeptSubGroupNew(this, "Departments - Modify", true);
            GLSGEdit.bInsertFlag = false;
            GLSGEdit.setLocationRelativeTo(this);
            String strData = null;
            strData =
                    (String)tblDepartment.getValueAt(tblDepartment.getSelectedRow(),
                                                     0);
            GLSGEdit.setSGData(strData);
            GLSGEdit.setVisible(true);
        }
    
        private void buttonExit_actionPerformed(ActionEvent e) {
            this.dispose();
        }
    
        private void this_windowActivated(WindowEvent e) {
            fillData();
        }
    }

  6. #6
    Nicholas Jordan's Avatar
    Nicholas Jordan is offline Senior Member
    Join Date
    Jun 2008
    Location
    Southwest
    Posts
    1,018
    Rep Power
    8

    Default

    You can probably put code tags around code in your original post and delete second one or ask moderator to do it.

    Use several classes that you are not using:

    JPasswordField + SecureRandom and / or some type of hashcode so that actual passwords are not written anywhere.

    Is this an actual codebase or is this a study project?
    Introduction to Programming Using Java.
    Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor

  7. #7
    mathansj is offline Member
    Join Date
    Feb 2009
    Posts
    9
    Rep Power
    0

    Default

    I dont know how to delete that existing code ... but i have put the formatted code again .....

    Please help me to delete the existing message

  8. #8
    mathansj is offline Member
    Join Date
    Feb 2009
    Posts
    9
    Rep Power
    0

    Default

    okey i did that

  9. #9
    mathansj is offline Member
    Join Date
    Feb 2009
    Posts
    9
    Rep Power
    0

    Default

    now i posted the formatted code with in the code tag .... this is not a study project ..... this is one sample class from the product which i am developing .... all other classes are in the same format ..... so i need some help like am i in the right way to do coding in JAVA because i am very new to JAVA platform


    Thanks in advance

Similar Threads

  1. any suggestions?
    By PureAwesomeness in forum New To Java
    Replies: 4
    Last Post: 01-19-2009, 08:34 AM
  2. Suggestions for my Java-project?
    By shabbee in forum New To Java
    Replies: 1
    Last Post: 01-01-2009, 11:11 PM
  3. Suggestions of crufty or otherwise bad APIs
    By Andre in forum Forum Lobby
    Replies: 8
    Last Post: 11-18-2008, 12:06 AM
  4. Any Datastructure Suggestions For An Unbalanced Tree?
    By markus-sukram in forum New To Java
    Replies: 0
    Last Post: 03-26-2008, 03:25 PM
  5. Java application help and suggestions required
    By bilal_ali_java in forum Advanced Java
    Replies: 0
    Last Post: 07-18-2007, 04:11 PM

Posting Permissions

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