1

what could be the reason that i cant scroll down my jtable? .. i also have a scrollPane.

i can see my table filled with data from the database, but i cant click on any row or scroll down or up why?

CONTROLLER

public void controllActionListenerShowEquipmentTable() {
    main.setActionListenerShowEquipmentTable(new ActionListener(){
        @Override
        public void actionPerformed(ActionEvent action) {
            if(action.getSource()== main.getShowEquipmentTable()){
                equ = new EquipmentDAO();
                try {
                    ResultSet re = equ.show();
                    main.showEquipmentTable(re);
                    main.showPanel("8");
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }   
        }
    });
}

MAIN

public void showEquipmentTable(ResultSet res){
    table = new JTable();
    scrollPane = new JScrollPane();
    scrollPane.setBounds(10,84,645,402);
    scrollPane.setBackground(new Color (0,0,0,50));
    showEquipment.add(scrollPane);
    scrollPane.setViewportView(table);
    table.setModel(DbUtils.resultSetToTableModel(res));
}

EQUIPMENT DAO CLASS IMPLEMENTS DAOINTERFACE

public class EquipmentDAO implements DaoInterface{

private Connection con;
private java.sql.PreparedStatement sta;
private Statement std;
private ResultSet res;
private DatabaseHandler handle;
private String query;

@Override
public ResultSet show() throws SQLException{
    handle = new DatabaseHandler();
    Connection con = handle.buildConnectionToServer();
    String query = "select EID as ID, EquipmentName as Name, EquipmentSection as Section, EquipmentType as Type, EquipmentValue as Value, EquipmentAmount as Amount from Equipment";
    sta = con.prepareStatement(query);
    res = sta.executeQuery(query);
    return res;
}
aktschnman
  • 27
  • 6
  • Can you post your full code.It is difficult to tell what might be causing the issue.check whether you have set `table.setEnabled(false)` anywhere – Madhan Jun 26 '15 at 18:54
  • my full code is really long ... like more than 1000 lines?... should i really put it in here? i mean would you check it? @Madhan – aktschnman Jun 26 '15 at 19:02
  • Put it in [pastebin](http://pastebin.com/) – Madhan Jun 26 '15 at 19:06
  • - controller class: http://pastebin.com/DepMUJcp mainframeclass: http://pastebin.com/R0tt9h71 EQUIPMENT DAO CLASS : http://pastebin.com/h7gWdD8W .. SHOW EQUIPMENT CLASS : http://pastebin.com/1RbsNCbu ... – aktschnman Jun 26 '15 at 19:56
  • @Madhan the comment above i copied my code into pastebin :) thx for taking a look if you need a class tell me? – aktschnman Jun 26 '15 at 20:09
  • you are also not able to edit the data in the JTable right.. – Madhan Jun 26 '15 at 20:10
  • and try removing the scrollPane.setBounds(10,84,645,402); – Madhan Jun 26 '15 at 20:11
  • i cant edit anything :/ ... when I click on a row nothing happens .. normaly i can click on a row and it will be lighten up blue r something so that you know that its clickedd right now ... :/ @Madhan – aktschnman Jun 26 '15 at 20:31
  • @madhan ... i deleted the line scrollPane.setBounds(10,84,645,402); ... and now i cant even see anything in the table :/ – aktschnman Jun 26 '15 at 20:33
  • ok dont remove that..and remove the `table = new JTable(); scrollPane = new JScrollPane();` from `showAllCustomer` and `showEquipmentTable` methods in MainFrameSoftware class and put those two lines inside constructor.because there is no need to create a new object everytime – Madhan Jun 26 '15 at 20:37
  • yeah you are right ... but still i cant scroll on my table or click on a row.. :/ @Madhan – aktschnman Jun 26 '15 at 20:41
  • and why are you setting .setLayout(null); for all panels – Madhan Jun 26 '15 at 20:44
  • i made the panels with a windowbuilder @madhan .. i mean it cant be whats the difference between show all customer and show equipment.. because when i run the programm and go on the panel of show all customer and click on show table i see the entries, i can click on them and scroll up and down .. :/ – aktschnman Jun 26 '15 at 20:51
  • So is it working now as you said *i can click on them and scroll up and down* – Madhan Jun 26 '15 at 20:52
  • 1
    If you have solved your problem post that as an answer – Madhan Jun 26 '15 at 21:13
  • @Madhan it is still not working :/ .. table is looking like this http://i.imgur.com/lPRSdvY.jpg and this is how it should look like .. plus scrolling http://i.imgur.com/216deyw.jpg – aktschnman Jun 27 '15 at 14:47
  • Refer [this](http://stackoverflow.com/questions/18069673/jtable-wont-scroll-in-jscrollpane) and [this](http://stackoverflow.com/questions/13115400/trying-to-get-a-jtable-jscrollpane-to-scroll) – Madhan Jun 27 '15 at 14:54
  • @MadProgrammer hey guys.. sry for tagging you but i read something about the other problems you solved and it was also about scrollpane and jtable.. so i wanted to ask you if you maybe know whats wrong ? ... thank you :) – aktschnman Jun 27 '15 at 15:29
  • @trashgod sry for tagging you but i am really desperate about this problem :/ – aktschnman Jun 27 '15 at 15:30
  • i solved the problem :) ... the problem was that i created two tables... one in my mainclass and added it into the mainframe .. but i just needed it on the class with the panel.. :) @Madhan – aktschnman Jun 28 '15 at 22:46

0 Answers0