Tela.java C:\Users\rodrig0\Documents\NetBeansProjects\grafo\src\grafo\Tela.java 1 /* 2 * To change this license header, choose License Headers in Project Properties. 3 * To change this template file, choose Tools | Templates 4 * and open the template in the editor. 5 */ 6 package grafo; 7 8 //import javax.swing.JTable; 9 import java.util.Arrays; 10 import javax.swing.JOptionPane; 11 import javax.swing.JTable; 12 import javax.swing.table.DefaultTableModel; 13 14 /** 15 * 16 * @author rodrig0 17 */ 18 public class Tela extends javax.swing.JFrame { 19 20 public int nv, na, contadorNa; 21 public Grafo novoGrafo = new Grafo(); 22 public int[][] matrizDeAdjacencia; 23 public int[][] matrizDeIncidencia; 24 25 /** 26 * Creates new form Tela 27 */ 28 public Tela() { 29 initComponents(); 30 txtNaresta.setDocument(new limitarCampo()); 31 txtNvertice.setDocument(new limitarCampo()); 32 33 } 34 35 /** 36 * This method is called from within the constructor to initialize the form. 37 * WARNING: Do NOT modify this code. The content of this method is always 38 * regenerated by the Form Editor. 39 */ 40 @SuppressWarnings("unchecked") 41 // <editor-fold defaultstate="collapsed" desc="Generated Code"> 42 private void initComponents() { 43 44 pnlFundo = new javax.swing.JPanel(); 45 pnlLigar = new javax.swing.JPanel(); 46 btnEsqDir = new javax.swing.JButton(); 47 btnDeletar = new javax.swing.JButton(); 48 btnCriarGrafo = new javax.swing.JButton(); 49 jScrollPane4 = new javax.swing.JScrollPane(); 50 tblVertice2 = new javax.swing.JTable(); 51 jScrollPane5 = new javax.swing.JScrollPane(); 52 tblVertice1 = new javax.swing.JTable(); 53 jScrollPane6 = new javax.swing.JScrollPane(); 54 tblLigacao = new javax.swing.JTable(); 55 btnGerarMatriz = new javax.swing.JButton(); 56 pnlCriar = new javax.swing.JPanel(); 57 jLabel1 = new javax.swing.JLabel(); 58 jLabel2 = new javax.swing.JLabel(); 59 btnCriar = new javax.swing.JButton(); Tela.html[11/29/2013 7:06:44 PM] Tela.java 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 txtNvertice = new javax.swing.JTextField(); txtNaresta = new javax.swing.JTextField(); pnlMatriz = new javax.swing.JPanel(); btnVoltarCriar = new javax.swing.JButton(); btnVoltar = new javax.swing.JButton(); jScrollPane1 = new javax.swing.JScrollPane(); lblMatrizes = new javax.swing.JLabel(); lblGrafo = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setMaximumSize(new java.awt.Dimension(1600, 900)); setMinimumSize(new java.awt.Dimension(1280, 720)); getContentPane().setLayout(null); pnlFundo.setLayout(null); btnEsqDir.setText("Ligar"); btnEsqDir.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnEsqDirActionPerformed(evt); } }); btnDeletar.setText("Deletar ligação"); btnDeletar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnDeletarActionPerformed(evt); } }); btnCriarGrafo.setText("Criar Novo Grafo"); btnCriarGrafo.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnCriarGrafoActionPerformed(evt); } }); tblVertice2.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {null}, {null}, {null} }, new String [] { "Vértices" } ){ Class[] types = new Class [] { java.lang.String.class }; boolean[] canEdit = new boolean [] { false }; public Class getColumnClass(int columnIndex) { return types [columnIndex]; } public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit [columnIndex]; } }); Tela.html[11/29/2013 7:06:44 PM] Tela.java 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 tblVertice2.setSelectionBackground(new java.awt.Color(0, 0, 0)); tblVertice2.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); jScrollPane4.setViewportView(tblVertice2); tblVertice2.getColumnModel().getColumn(0).setResizable(false); tblVertice1.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {null}, {null}, {null} }, new String [] { "Vértices" } ){ Class[] types = new Class [] { java.lang.String.class }; boolean[] canEdit = new boolean [] { false }; public Class getColumnClass(int columnIndex) { return types [columnIndex]; } public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit [columnIndex]; } }); tblVertice1.setSelectionBackground(new java.awt.Color(0, 0, 0)); tblVertice1.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); jScrollPane5.setViewportView(tblVertice1); tblVertice1.getColumnModel().getColumn(0).setResizable(false); tblLigacao.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {null}, {null}, {null} }, new String [] { "Ligações Feitas Entre Vértices" } ){ Class[] types = new Class [] { java.lang.String.class }; boolean[] canEdit = new boolean [] { false }; public Class getColumnClass(int columnIndex) { return types [columnIndex]; } public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit [columnIndex]; } }); tblLigacao.setSelectionBackground(new java.awt.Color(0, 0, 0)); tblLigacao.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); Tela.html[11/29/2013 7:06:44 PM] Tela.java 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 jScrollPane6.setViewportView(tblLigacao); tblLigacao.getColumnModel().getColumn(0).setResizable(false); btnGerarMatriz.setText("Gerar Matrizes"); btnGerarMatriz.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnGerarMatrizActionPerformed(evt); } }); javax.swing.GroupLayout pnlLigarLayout = new javax.swing.GroupLayout(pnlLigar); pnlLigar.setLayout(pnlLigarLayout); pnlLigarLayout.setHorizontalGroup( pnlLigarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(pnlLigarLayout.createSequentialGroup() .addGap(42, 42, 42) .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(btnEsqDir, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(112, 112, 112) .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(pnlLigarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(btnDeletar, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnGerarMatriz, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnCriarGrafo)) .addContainerGap(247, Short.MAX_VALUE)) ); pnlLigarLayout.setVerticalGroup( pnlLigarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(pnlLigarLayout.createSequentialGroup() .addGroup(pnlLigarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 330, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(pnlLigarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(pnlLigarLayout.createSequentialGroup() .addGap(190, 190, 190) .addComponent(btnEsqDir)) .addGroup(pnlLigarLayout.createSequentialGroup() .addGap(90, 90, 90) .addComponent(btnCriarGrafo) .addGap(18, 18, 18) .addComponent(btnDeletar) .addGap(34, 34, 34) .addComponent(btnGerarMatriz)) .addGroup(pnlLigarLayout.createSequentialGroup() .addGap(62, 62, 62) .addGroup(pnlLigarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 330, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 330, javax.swing.GroupLayout.PREFERRED_SIZE))))) .addGap(68, 68, 68)) ); pnlLigar.setVisible(false); pnlFundo.add(pnlLigar); pnlLigar.setBounds(10, 250, 1140, 250); jLabel1.setText("Número de Vértices"); jLabel2.setText("Número de Arestas"); Tela.html[11/29/2013 7:06:44 PM] Tela.java 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 btnCriar.setText("Criar Grafo"); btnCriar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnCriarActionPerformed(evt); } }); javax.swing.GroupLayout pnlCriarLayout = new javax.swing.GroupLayout(pnlCriar); pnlCriar.setLayout(pnlCriarLayout); pnlCriarLayout.setHorizontalGroup( pnlCriarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(pnlCriarLayout.createSequentialGroup() .addGroup(pnlCriarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(pnlCriarLayout.createSequentialGroup() .addGap(84, 84, 84) .addComponent(btnCriar)) .addGroup(pnlCriarLayout.createSequentialGroup() .addGap(30, 30, 30) .addGroup(pnlCriarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jLabel2) .addComponent(jLabel1))) .addGroup(pnlCriarLayout.createSequentialGroup() .addGap(30, 30, 30) .addComponent(txtNvertice, javax.swing.GroupLayout.PREFERRED_SIZE, 183, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(pnlCriarLayout.createSequentialGroup() .addGap(31, 31, 31) .addComponent(txtNaresta, javax.swing.GroupLayout.PREFERRED_SIZE, 183, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(76, Short.MAX_VALUE)) ); pnlCriarLayout.setVerticalGroup( pnlCriarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(pnlCriarLayout.createSequentialGroup() .addGap(24, 24, 24) .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(txtNvertice, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jLabel2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(txtNaresta, javax.swing.GroupLayout.DEFAULT_SIZE, 34, Short.MAX_VALUE) .addGap(18, 18, 18) .addComponent(btnCriar) .addContainerGap()) ); pnlFundo.add(pnlCriar); pnlCriar.setBounds(10, 20, 290, 190); pnlMatriz.setLayout(null); btnVoltarCriar.setText("Criar Novo Grafo"); btnVoltarCriar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnVoltarCriarActionPerformed(evt); } }); pnlMatriz.add(btnVoltarCriar); btnVoltarCriar.setBounds(110, 600, 130, 23); btnVoltar.setText("<<Voltar"); btnVoltar.addActionListener(new java.awt.event.ActionListener() { Tela.html[11/29/2013 7:06:44 PM] Tela.java 308 public void actionPerformed(java.awt.event.ActionEvent evt) { 309 btnVoltarActionPerformed(evt); 310 } 311 }); 312 pnlMatriz.add(btnVoltar); 313 btnVoltar.setBounds(10, 600, 90, 23); 314 315 lblMatrizes.setText("jLabel3"); 316 lblMatrizes.setVerticalAlignment(javax.swing.SwingConstants.TOP); 317 jScrollPane1.setViewportView(lblMatrizes); 318 319 pnlMatriz.add(jScrollPane1); 320 jScrollPane1.setBounds(0, 0, 1100, 580); 321 322 lblGrafo.setText("jLabel3"); 323 pnlMatriz.add(lblGrafo); 324 lblGrafo.setBounds(300, 600, 400, 40); 325 326 pnlMatriz.setVisible(false); 327 328 pnlFundo.add(pnlMatriz); 329 pnlMatriz.setBounds(720, 10, 310, 130); 330 331 getContentPane().add(pnlFundo); 332 pnlFundo.setBounds(0, 0, 1280, 720); 333 334 pack(); 335 }// </editor-fold> 336 337 private void btnDeletarActionPerformed(java.awt.event.ActionEvent evt) { 338 int selecionado = tblLigacao.getSelectedRow(); 339 if (selecionado > -1 && tblLigacao.getModel().getValueAt(selecionado, 0).equals("") == false) { 340 novoGrafo.getListaDeVertices().get(novoGrafo.getListaDeVertices().indexOf(novoGrafo.getListaDeArestas().get(selecionado).getOrigem())).getOriginario().remove(novoGrafo.getListaDeArestas().get(selecionado)); 341 novoGrafo.getListaDeVertices().get(novoGrafo.getListaDeVertices().indexOf(novoGrafo.getListaDeArestas().get(selecionado).getDestino())).getDestinatario().remove(novoGrafo.getListaDeArestas().get(selecionado)); 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 int x = novoGrafo.getListaDeVertices().indexOf(novoGrafo.getListaDeArestas().get(selecionado).getOrigem()); int y = novoGrafo.getListaDeVertices().indexOf(novoGrafo.getListaDeArestas().get(selecionado).getDestino()); matrizDeAdjacencia[x][y]--; matrizDeAdjacencia[y][x]--; matrizDeIncidencia[x][selecionado] = 0; matrizDeIncidencia[y][selecionado] = 0; novoGrafo.getListaDeArestas().get(selecionado).setDestino(null); novoGrafo.getListaDeArestas().get(selecionado).setOrigem(null); tblLigacao.getModel().setValueAt("", selecionado, 0); contadorNa++; } else { JOptionPane.showMessageDialog(rootPane, "Selecione uma Ligação válida para ser deletada"); } } private void btnCriarGrafoActionPerformed(java.awt.event.ActionEvent evt) { selecionarPainel(1); } private void btnEsqDirActionPerformed(java.awt.event.ActionEvent evt) { int selv1 = tblVertice1.getSelectedRow(); int selv2 = tblVertice2.getSelectedRow(); int posAresta = arestaVazia(); if (selv1 != -1 && selv2 != -1 && contadorNa > 0 && posAresta != -1) { Tela.html[11/29/2013 7:06:44 PM] Tela.java 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 novoGrafo.getListaDeArestas().get(posAresta).setOrigem(novoGrafo.getListaDeVertices().get(selv1)); novoGrafo.getListaDeArestas().get(posAresta).setDestino(novoGrafo.getListaDeVertices().get(selv2)); novoGrafo.getListaDeVertices().get(selv1).getOriginario().add(novoGrafo.getListaDeArestas().get(posAresta)); novoGrafo.getListaDeVertices().get(selv2).getDestinatario().add(novoGrafo.getListaDeArestas().get(posAresta)); matrizDeAdjacencia[selv1][selv2]++; matrizDeAdjacencia[selv2][selv1]++; matrizDeIncidencia[selv1][posAresta] = 1; matrizDeIncidencia[selv2][posAresta] = 1; String ligacao = novoGrafo.getListaDeVertices().get(selv1).getNome() + "--" + novoGrafo.getListaDeArestas().get(posAresta).getNome() + "--" + novoGrafo.getListaDeVertices().get(selv2).getNome(); tblLigacao.getModel().setValueAt(ligacao, posAresta, 0); contadorNa--; } } private void btnGerarMatrizActionPerformed(java.awt.event.ActionEvent evt) { String html = "<html><div>\n" + "<h1>Matriz de Adjacencia</br></h1>\n" + "<table style=\"background-color:black;color:white;\">\n" + "<tr style=\"background-color:black;color:white;\">\n" + "<th></th>"; for (int i = 0; i < nv; i++) { html = html + "<th>" + novoGrafo.getListaDeVertices().get(i).getNome() + "</th>"; } html = html + "</tr>"; for (int i = 0; i < nv; i++) { html = html + "<tr>\n" + "<td style=\"background-color:black;color:white;\">" + novoGrafo.getListaDeVertices().get(i).getNome() + "</td>"; for (int j = 0; j < nv; j++) { html = html + "<td style=\"background-color:white;color:black;\">" + matrizDeAdjacencia[i][j] + "</td>"; } html = html + "</tr>"; } html = html + "</table>\n" + "<h1></br></br>Matriz de Incidencia</br></h1>" + "<table style=\"background-color:black;color:white;\">\n" + "<tr style=\"background-color:black;color:white;\">\n" + "<th></th>"; for (int i = 0; i < na; i++) { html = html + "<th>" + novoGrafo.getListaDeArestas().get(i).getNome() + "</th>"; } html = html + "</tr>"; for (int i = 0; i < nv; i++) { html = html + "<tr>\n" + "<td style=\"background-color:black;color:white;\">" + novoGrafo.getListaDeVertices().get(i).getNome() + "</td>"; for (int j = 0; j < na; j++) { html = html + "<td style=\"background-color:white;color:black;\">" + matrizDeIncidencia[i][j] + "</td>"; } html = html + "</tr>"; } html = html + "</table>\n" + "</div></html>"; lblMatrizes.setText(html); int simples = 0; for (int i = 0; i < nv; i++) { for (int j = 0; j < nv; j++) { if(matrizDeAdjacencia[i][j] > 1){ simples = 1; break; } } } if(simples == 0){ Tela.html[11/29/2013 7:06:44 PM] Tela.java 429 lblGrafo.setText("<html><h1>O grafo é simples</h1></html>"); 430 }else{ 431 lblGrafo.setText("<html><h1>O grafo não é simples</h1></html>"); 432 } 433 selecionarPainel(3); 434 } 435 436 private void btnCriarActionPerformed(java.awt.event.ActionEvent evt) { 437 438 nv = Integer.parseInt(txtNvertice.getText()); 439 contadorNa = na = Integer.parseInt(txtNaresta.getText()); 440 if (nv > 0) { 441 matrizDeAdjacencia = null; 442 matrizDeIncidencia = null; 443 matrizDeAdjacencia = new int[nv][nv]; 444 matrizDeIncidencia = new int[nv][na]; 445 Arrays.fill(matrizDeIncidencia[0], 0); 446 Arrays.fill(matrizDeAdjacencia[0], 0); 447 novoGrafo = new Grafo(); 448 for (int i = 0; i < nv; i++) { 449 novoGrafo.getListaDeVertices().add(new vertice()); 450 novoGrafo.getListaDeVertices().get(i).setNome("V" + (i + 1)); 451 } 452 for (int i = 0; i < na; i++) { 453 novoGrafo.getListaDeArestas().add(new aresta()); 454 novoGrafo.getListaDeArestas().get(i).setNome("A" + (i + 1)); 455 } 456 int numLinha = tblVertice1.getRowCount(); 457 for (int i = 0; i < numLinha; i++) { 458 removeLinha(0, tblVertice1); 459 removeLinha(0, tblVertice2); 460 } 461 numLinha = tblLigacao.getRowCount(); 462 for (int i = 0; i < numLinha; i++) { 463 removeLinha(0, tblLigacao); 464 } 465 for (int i = 0; i < nv; i++) { 466 addLinha(tblVertice1); 467 addLinha(tblVertice2); 468 tblVertice1.getModel().setValueAt(novoGrafo.getListaDeVertices().get(i).getNome(), i, 0); 469 tblVertice2.getModel().setValueAt(novoGrafo.getListaDeVertices().get(i).getNome(), i, 0); 470 } 471 for (int i = 0; i < na; i++) { 472 addLinha(tblLigacao); 473 } 474 selecionarPainel(2); 475 } else { 476 JOptionPane.showMessageDialog(rootPane, "Informe um número de vertices maior que 0 (zero)"); 477 } 478 } 479 480 private void btnVoltarActionPerformed(java.awt.event.ActionEvent evt) { 481 selecionarPainel(2); 482 // TODO add your handling code here: 483 } 484 485 private void btnVoltarCriarActionPerformed(java.awt.event.ActionEvent evt) { 486 selecionarPainel(1); 487 // TODO add your handling code here: 488 } 489 490 public void selecionarPainel(int op) { Tela.html[11/29/2013 7:06:44 PM] Tela.java 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 switch (op) { case 1: pnlMatriz.setVisible(false); pnlLigar.setVisible(false); pnlCriar.setBounds(20, 20, 290, 190); pnlLigar.setBounds(0, 0, 0, 0); pnlMatriz.setBounds(1, 1, 0, 0); pnlCriar.setVisible(true); break; case 2: pnlMatriz.setVisible(false); pnlCriar.setVisible(false); pnlCriar.setBounds(0, 0, 0, 0); pnlLigar.setBounds(20, 20, 1100, 620); pnlMatriz.setBounds(1, 1, 0, 0); pnlLigar.setVisible(true); break; case 3: pnlCriar.setVisible(false); pnlLigar.setVisible(false); pnlCriar.setBounds(1, 1, 0, 0); pnlLigar.setBounds(0, 0, 0, 0); pnlMatriz.setBounds(20, 20, 1200, 680); pnlMatriz.setVisible(true); break; } } public int arestaVazia() { for (int i = 0; i < novoGrafo.getListaDeArestas().size(); i++) { if (novoGrafo.getListaDeArestas().get(i).getOrigem() == null) { return i; } } return -1; } public void addLinha(JTable tblLigacao) { DefaultTableModel c = (DefaultTableModel) tblLigacao.getModel(); Object[] linha = {null}; c.addRow(linha); } public void removeLinha(int posicao, JTable lista) { DefaultTableModel c = (DefaultTableModel) lista.getModel(); c.removeRow(posicao); } /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; Tela.html[11/29/2013 7:06:44 PM] Tela.java 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 } 601 } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(Tela.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(Tela.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(Tela.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(Tela.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Tela().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JButton btnCriar; private javax.swing.JButton btnCriarGrafo; private javax.swing.JButton btnDeletar; private javax.swing.JButton btnEsqDir; private javax.swing.JButton btnGerarMatriz; private javax.swing.JButton btnVoltar; private javax.swing.JButton btnVoltarCriar; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane4; private javax.swing.JScrollPane jScrollPane5; private javax.swing.JScrollPane jScrollPane6; private javax.swing.JLabel lblGrafo; private javax.swing.JLabel lblMatrizes; private javax.swing.JPanel pnlCriar; private javax.swing.JPanel pnlFundo; private javax.swing.JPanel pnlLigar; private javax.swing.JPanel pnlMatriz; private javax.swing.JTable tblLigacao; private javax.swing.JTable tblVertice1; private javax.swing.JTable tblVertice2; private javax.swing.JTextField txtNaresta; private javax.swing.JTextField txtNvertice; // End of variables declaration Tela.html[11/29/2013 7:06:44 PM]