| | |
Problem with GUI!
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Nov 2009
Posts: 3
Reputation:
Solved Threads: 0
At the moment Im developing a java application but Im having a problem.
Im using a JFrame that takes different JPanels, I mean i change its ContentPane for another JPanel everytime i want to show new information.
Im using a database too, im reading data from it im writing them in a JTable, But... when i try to do this my program freeze and stop working until i minimize and maximize my JFrame.!!
I need help with this.!!
What should i do?, Should i add some Threads??
This is part of the code im using:
Any help would be appreciated!
Im using a JFrame that takes different JPanels, I mean i change its ContentPane for another JPanel everytime i want to show new information.
Im using a database too, im reading data from it im writing them in a JTable, But... when i try to do this my program freeze and stop working until i minimize and maximize my JFrame.!!
I need help with this.!!
What should i do?, Should i add some Threads??
This is part of the code im using:
Java Syntax (Toggle Plain Text)
// Class Search table = bd.getPreparedJTable(sentencia); public JTable getPreparedJTable(String sentencia) { JTable table = null; try { startConnection(); prepararStatement(); Vector columnNames = new Vector(); Vector data = new Vector(); setResultSet(getStatement().executeQuery(sentencia)); ResultSetMetaData md = getResultSet().getMetaData(); int columns = md.getColumnCount(); // Get column names for (int i = 1; i <= columns; i++) { columnNames.addElement( md.getColumnName(i) ); } // Get row data while (getResultSet().next()) { Vector row = new Vector(columns); for (int i = 1; i <= columns; i++) { row.addElement( getResultSet().getObject(i) ); } data.addElement( row ); } getResultSet().close(); getStatement().close(); closeConnection(); // Create table with database data table = new JTable(data, columnNames) { public boolean isCellEditable(int row, int col){ return false; } }; } catch(SQLException e) { e.printStackTrace(); } return table; } // And this is how i change the background of my JFrame void setPanel(final JPanel screen) { try{ SwingUtilities.invokeLater( new Runnable(){ public void run() { getContentPane().removeAll(); setContentPane(screen); } }); } catch(Exception e) { e.printStackTrace(); } SwingUtilities.updateComponentTreeUI(this); }
Any help would be appreciated!
•
•
Join Date: Nov 2009
Posts: 3
Reputation:
Solved Threads: 0
•
•
•
•
Try adding a revalidate() and possibly a repaint() in your runnable after you set the new screen.
Thanks Ezzaral for the help, I added a SwingWorker that reads the data from the database and when it finish looking for the data, it revalidate the JTable and repaint the JFrame.!!
![]() |
Similar Threads
- Problem with GUI (Java)
- Java compiler (Java)
- GUI - very simple, but still couldnt solve, help pls (C#)
- Integrating code to GUI help please (Java)
- JSP shopping cart (JSP)
- what do i do here??? (Java)
- making a desktop application with c++ (C++)
- "cannot resolve symbol"problem (Java)
- problems with referring to class variables (Java)
Other Threads in the Java Forum
- Previous Thread: web audio stream and jmf
- Next Thread: how to check the value in a TextField if it is equel to specific string ?
Views: 534 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for database, freeze, gui, problem, stop, working
.net access acquisition age amd array asp asp.net assignment avatar backup basic bigbrother bluegene bug c# c++ chips code connection crash daniweb data database databaseconnection datagridview development display dos ecommerce economy energy enter enterprise enterprisesoftware error examples formview freeze freezes.hangs glitch gui hardware html ibm ibm.news images ingres intelibm java javascript linux medicine memory microsoft mosaic mssqlserver2005 mssqlserverandasp myaggfun mysql news openoffice opensource operatingsystem oracle pause pc php preview problem programming ps3 python recession record redhat russia search security server sql sqlite sqlserver stop sun supercomputer supercomputing survey technology test trends ubuntu uk update vb vb.net win32 windows working x86







