1
I’m making a RBC system to verify the similarity between computers. I would like to sort my table rows by the value of probability. The problem is that the table has around 9,500,000 rows. Does anyone know how to sort lines by column?
Below is the method I’m using in my code:
package mce;
import java.util.ArrayList;
import java.util.Vector;
import javax.swing.DefaultListModel;
import javax.swing.table.DefaultTableModel;
public class MCE {
public static double retornaSimGabinete(String a1, String a2){
if (a1.equals("Full Tower") && a2.equals("Full Tower")) {
return 1;
} else if (a1.equals("Mid Tower") && a2.equals("Mid Tower")) {
return 1;
} else if ((a1.equals("Full Tower") && a2.equals("Mid Tower")) || (a2.equals("Full Tower") && a1.equals("Mid Tower"))) {
return 0.5;
} else {
return 0;
}
}
public static double retornaSimProc (String a1, String a2) {
if (a1.equals("i7 6700K") && a2.equals("i7 6700K")) {
return 1;
} else if (a1.equals("i7 6700") && a2.equals("i7 6700")) {
return 1;
} else if (a1.equals("i5 6600K") && a2.equals("i5 6600K")) {
return 1;
} else if (a1.equals("i5 6600") && a2.equals("i5 6600")) {
return 1;
} else if ((a1.equals("i7 6700K") && a2.equals("i7 6700")) || (a2.equals("i7 6700K") && a1.equals("i7 6700"))) {
return 0.8;
} else if ((a1.equals("i7 6700K") && a2.equals("i5 6600K")) || (a2.equals("i7 6700K") && a1.equals("i5 6600K"))) {
return 0.6;
} else if ((a1.equals("i7 6700K") && a2.equals("i5 6600")) || (a2.equals("i7 6700K") && a1.equals("i5 6600"))) {
return 0.4;
} else if ((a1.equals("i7 6700") && a2.equals("i5 6600K")) || (a2.equals("i7 6700") && a1.equals("i5 6600K"))) {
return 0.5;
} else if ((a1.equals("i7 6700") && a2.equals("i5 6600")) || (a2.equals("i7 6700") && a1.equals("i5 6600"))) {
return 0.7;
} else if ((a1.equals("i5 6600K") && a2.equals("i5 6600")) || (a2.equals("i5 6600K") && a1.equals("i5 6600"))) {
return 0.8;
} else {
return 0;
}
}
public static double retornaSimMem (String a1, String a2) {
if (a1.equals("HyperX 8GB 1600") && a2.equals("HyperX 8GB 1600")) {
return 1;
} else if (a1.equals("HyperX 8GB 1866") && a2.equals("HyperX 8GB 1866")) {
return 1;
} else if (a1.equals("HyperX 8GB 2133") && a2.equals("HyperX 8GB 2133")) {
return 1;
} else if (a1.equals("Vengeance 8GB 1600") && a2.equals("Vengeance 8GB 1600")) {
return 1;
} else if ((a1.equals("HyperX 8GB 1600") && a2.equals("HyperX 8GB 1866")) || (a2.equals("HyperX 8GB 1600") && a1.equals("HyperX 8GB 1866"))) {
return 0.8;
} else if ((a1.equals("HyperX 8GB 1600") && a2.equals("HyperX 8GB 2133")) || (a2.equals("HyperX 8GB 1600") && a1.equals("HyperX 8GB 2133"))) {
return 0.5;
} else if ((a1.equals("HyperX 8GB 1600") && a2.equals("Vengeance 8GB 1600")) || (a2.equals("HyperX 8GB 1600") && a1.equals("Vengeance 8GB 1600"))) {
return 0.9;
} else if ((a1.equals("HyperX 8GB 1866") && a2.equals("HyperX 8GB 2133")) || (a2.equals("HyperX 8GB 1866") && a1.equals("HyperX 8GB 2133"))) {
return 0.7;
} else if ((a1.equals("HyperX 8GB 1866") && a2.equals("Vengeance 8GB 1600")) || (a2.equals("HyperX 8GB 1866") && a1.equals("Vengeance 8GB 1600"))) {
return 0.8;
} else if ((a1.equals("HyperX 8GB 2133") && a2.equals("Vengeance 8GB 1600")) || (a2.equals("HyperX 8GB 2133") && a1.equals("Vengeance 8GB 1600"))) {
return 0.5;
} else {
return 0;
}
}
public static double retornaSimHd (String a1, String a2) {
if (a1.equals("WD 1TB 7200") && a2.equals("WD 1TB 7200")) {
return 1;
} else if (a1.equals("Seagate 1TB 7200") && a2.equals("Seagate 1TB 7200")) {
return 1;
} else if (a1.equals("Seagate 2TB 7200") && a2.equals("Seagate 2TB 7200")) {
return 1;
} else if ((a1.equals("WD 1TB 7200") && a2.equals("Seagate 1TB 7200")) || (a2.equals("WD 1TB 7200") && a1.equals("Seagate 1TB 7200"))) {
return 0.9;
} else if ((a1.equals("WD 1TB 7200") && a2.equals("Seagate 2TB 7200")) || (a2.equals("WD 1TB 7200") && a1.equals("Seagate 2TB 7200"))) {
return 0.7;
} else if ((a1.equals("Seagate 1TB 7200") && a2.equals("Seagate 2TB 7200")) || (a2.equals("Seagate 1TB 7200") && a1.equals("Seagate 2TB 7200"))) {
return 0.7;
} else {
return 0;
}
}
public static double retornaSimTeclado (String a1, String a2) {
if (a1.equals("Razer BlackWidow") && a2.equals("Razer BlackWidow")) {
return 1;
} else if (a1.equals("Razer DeathStalker") && a2.equals("Razer DeathStalker")) {
return 1;
} else if (a1.equals("Razer Cynosa") && a2.equals("Razer Cynosa")) {
return 1;
} else if ((a1.equals("Razer BlackWidow") && a2.equals("Razer DeathStalker")) || (a2.equals("Razer BlackWidow") && a1.equals("Razer DeathStalker"))) {
return 0.8;
} else if ((a1.equals("Razer BlackWidow") && a2.equals("Razer Cynosa")) || (a2.equals("Razer BlackWidow") && a1.equals("Razer Cynosa"))) {
return 0.6;
} else if ((a1.equals("Razer DeathStalker") && a2.equals("Razer Cynosa")) || (a2.equals("Razer DeathStalker") && a1.equals("Razer Cynosa"))) {
return 0.7;
} else {
return 0;
}
}
public static double retornaSimRefrigeracao(String a1, String a2){
if (a1.equals("Água") && a2.equals("Água")) {
return 1;
} else if (a1.equals("Ar") && a2.equals("Ar")) {
return 1;
} else if ((a1.equals("Água") && a2.equals("Ar")) || (a2.equals("Água") && a1.equals("Ar"))) {
return 0.5;
} else {
return 0;
}
}
public static double retornaSimSsd (String a1, String a2) {
if (a1.equals("Kingston 120GB") && a2.equals("Kingston 120GB")) {
return 1;
} else if (a1.equals("Sandisk 120GB") && a2.equals("Sandisk 120GB")) {
return 1;
} else if (a1.equals("Kingston 240GB") && a2.equals("Kingston 240GB")) {
return 1;
} else if (a1.equals("Sandisk 240GB") && a2.equals("Sandisk 240GB")) {
return 1;
} else if ((a1.equals("Kingston 120GB") && a2.equals("Sandisk 120GB")) || (a2.equals("Kingston 120GB") && a1.equals("Sandisk 120GB"))) {
return 0.9;
} else if ((a1.equals("Kingston 120GB") && a2.equals("Kingston 240GB")) || (a2.equals("Kingston 120GB") && a1.equals("Kingston 240GB"))) {
return 0.7;
} else if ((a1.equals("Kingston 120GB") && a2.equals("Sandisk 240GB")) || (a2.equals("Kingston 120GB") && a1.equals("Sandisk 240GB"))) {
return 0.6;
} else if ((a1.equals("Sandisk 120GB") && a2.equals("Kingston 240GB")) || (a2.equals("Sandisk 120GB") && a1.equals("Kingston 240GB"))) {
return 0.6;
} else if ((a1.equals("Sandisk 120GB") && a2.equals("Sandisk 240GB")) || (a2.equals("Sandisk 120GB") && a1.equals("Sandisk 240GB"))) {
return 0.7;
} else if ((a1.equals("Kingston 240GB") && a2.equals("Sandisk 240GB")) || (a2.equals("Kingston 240GB") && a1.equals("Sandisk 240GB"))) {
return 0.9;
} else {
return 0;
}
}
public static double retornaSimGpu(String a1, String a2) {
if (a1.equals("AMD R9 390") && a2.equals("AMD R9 390")) {
return 1;
} else if (a1.equals("AMD R9 Fury") && a2.equals("AMD R9 Fury")) {
return 1;
} else if (a1.equals("AMD R9 390X") && a2.equals("AMD R9 390X")) {
return 1;
} else if (a1.equals("GTX 980 TI") && a2.equals("GTX 980 TI")) {
return 1;
} else if ((a1.equals("AMD R9 390") && a2.equals("AMD R9 Fury")) || (a2.equals("AMD R9 390") && a1.equals("AMD R9 Fury"))) {
return 0.8;
} else if ((a1.equals("AMD R9 390") && a2.equals("AMD R9 390X")) || (a2.equals("AMD R9 390") && a1.equals("AMD R9 390X"))) {
return 0.7;
} else if ((a1.equals("AMD R9 390") && a2.equals("GTX 980 TI")) || (a2.equals("AMD R9 390") && a1.equals("GTX 980 TI"))) {
return 0.6;
} else if ((a1.equals("AMD R9 Fury") && a2.equals("AMD R9 390X")) || (a2.equals("AMD R9 Fury") && a1.equals("AMD R9 390X"))) {
return 0.7;
} else if ((a1.equals("AMD R9 Fury") && a2.equals("GTX 980 TI")) || (a2.equals("AMD R9 Fury") && a1.equals("GTX 980 TI"))) {
return 0.6;
} else if ((a1.equals("AMD R9 390X") && a2.equals("GTX 980 TI")) || (a2.equals("AMD R9 390X") && a1.equals("GTX 980 TI"))) {
return 0.8;
} else {
return 0;
}
}
public static double retornaSimMouse (String a1, String a2) {
if (a1.equals("Razer Naga") && a2.equals("Razer Naga")) {
return 1;
} else if (a1.equals("Razer Abyssus") && a2.equals("Razer Abyssus")) {
return 1;
} else if (a1.equals("Razer Krait") && a2.equals("Razer Krait")) {
return 1;
} else if (a1.equals("Razer Deathadder") && a2.equals("Razer Deathadder")) {
return 1;
} else if ((a1.equals("Razer Naga") && a2.equals("Razer Abyssus")) || (a2.equals("Razer Naga") && a1.equals("Razer Abyssus"))) {
return 0.7;
} else if ((a1.equals("Razer Naga") && a2.equals("Razer Krait")) || (a2.equals("Razer Naga") && a1.equals("Razer Krait"))) {
return 0.5;
} else if ((a1.equals("Razer Naga") && a2.equals("Razer Deathadder")) || (a2.equals("Razer Naga") && a1.equals("Razer Deathadder"))) {
return 0.3;
} else if ((a1.equals("Razer Abyssus") && a2.equals("Razer Krait")) || (a2.equals("Razer Abyssus") && a1.equals("Razer Krait"))) {
return 0.6;
} else if ((a1.equals("Razer Abyssus") && a2.equals("Razer Deathadder")) || (a2.equals("Razer Abyssus") && a1.equals("Razer Deathadder"))) {
return 0.7;
} else if ((a1.equals("Razer Deathadder") && a2.equals("Razer Krait")) || (a2.equals("Razer Deathadder") && a1.equals("Razer Krait"))) {
return 0.8;
} else {
return 0;
}
}
public static double retornaSimFonte (String a1, String a2) {
if (a1.equals("EVGA 1600W") && a2.equals("EVGA 1600W")) {
return 1;
} else if (a1.equals("Corsair 1500W") && a2.equals("Corsair 1500W")) {
return 1;
} else if (a1.equals("Coolermaster 1200W") && a2.equals("Coolermaster 1200W")) {
return 1;
} else if (a1.equals("Seasonic 1000W") && a2.equals("Seasonic 1000W")) {
return 1;
} else if ((a1.equals("EVGA 1600W") && a2.equals("Corsair 1500W")) || (a2.equals("EVGA 1500W") && a1.equals("Corsair 1500W"))) {
return 0.8;
} else if ((a1.equals("EVGA 1600W") && a2.equals("Coolermaster 1200W")) || (a2.equals("EVGA 1600W") && a1.equals("Coolermaster 1200W"))) {
return 0.6;
} else if ((a1.equals("EVGA 1600W") && a2.equals("Seasonic 1000W")) || (a2.equals("EVGA 1600W") && a1.equals("Seasonic 1000W"))) {
return 0.4;
} else if ((a1.equals("Corsair 1500W") && a2.equals("Coolermaster 1200W")) || (a2.equals("Corsair 1500W") && a1.equals("Coolermaster 1200W"))) {
return 0.7;
} else if ((a1.equals("Corsair 1500W") && a2.equals("Seasonic 1000W")) || (a2.equals("Corsair 1500W") && a1.equals("Seasonic 1000W"))) {
return 0.5;
} else if ((a1.equals("Coolermaster 1200W") && a2.equals("Seasonic 1000W")) || (a2.equals("Coolermaster 1200W") && a1.equals("Seasonic 1000W"))) {
return 0.8;
} else {
return 0;
}
}
public static double retornaSimMonitor (String a1, String a2) {
if (a1.equals("Benq 27p 144Hz") && a2.equals("Benq 27p 144Hz")) {
return 1;
} else if (a1.equals("Asus 27p 144Hz") && a2.equals("Asus 27p 144Hz")) {
return 1;
} else if (a1.equals("Asus 27p QuadHD") && a2.equals("Asus 27p QuadHD")) {
return 1;
} else if (a1.equals("LG 25p FullHD") && a2.equals("LG 25p FullHD")) {
return 1;
} else if ((a1.equals("Benq 27p 144Hz") && a2.equals("Asus 27p 144Hz")) || (a2.equals("Benq 27p 144Hz") && a1.equals("Asus 27p 144Hz"))) {
return 0.8;
} else if ((a1.equals("Benq 27p 144Hz") && a2.equals("Asus 27p QuadHD")) || (a2.equals("Benq 27p 144Hz") && a1.equals("Asus 27p QuadHD"))) {
return 0.6;
} else if ((a1.equals("Benq 27p 144Hz") && a2.equals("LG 25p FullHD")) || (a2.equals("Benq 27p 144Hz") && a1.equals("LG 25p FullHD"))) {
return 0.4;
} else if ((a1.equals("Asus 27p 144Hz") && a2.equals("Asus 27p QuadHD")) || (a2.equals("Asus 27p 144Hz") && a1.equals("Asus 27p QuadHD"))) {
return 0.7;
} else if ((a1.equals("Asus 27p 144Hz") && a2.equals("LG 25p FullHD")) || (a2.equals("Asus 27p 144Hz") && a1.equals("LG 25p FullHD"))) {
return 0.5;
} else if ((a1.equals("Asus 27p QuadHD") && a2.equals("LG 25p FullHD")) || (a2.equals("Asus 27p QuadHD") && a1.equals("LG 25p FullHD"))) {
return 0.8;
} else {
return 0;
}
}
public static double retornaSimHeadset (String a1, String a2) {
if (a1.equals("Razer Kraken") && a2.equals("Razer Kraken")) {
return 1;
} else if (a1.equals("Razer TiaMat") && a2.equals("Razer TiaMat")) {
return 1;
} else if (a1.equals("Razer Chiamera") && a2.equals("Razer Chiamera")) {
return 1;
} else if (a1.equals("Razer Manowar") && a2.equals("Razer Manowar")) {
return 1;
} else if ((a1.equals("Razer Kraken") && a2.equals("Razer TiaMat")) || (a2.equals("Razer Kraken") && a1.equals("Razer TiaMat"))) {
return 0.7;
} else if ((a1.equals("Razer Kraken") && a2.equals("Razer Chiamera")) || (a2.equals("Razer Kraken") && a1.equals("Razer Chiamera"))) {
return 0.6;
} else if ((a1.equals("Razer Kraken") && a2.equals("Razer Manowar")) || (a2.equals("Razer Kraken") && a1.equals("Razer Manowar"))) {
return 0.5;
} else if ((a1.equals("Razer TiaMat") && a2.equals("Razer Chiamera")) || (a2.equals("Razer TiaMat") && a1.equals("Razer Chiamera"))) {
return 0.7;
} else if ((a1.equals("Razer TiaMat") && a2.equals("Razer Manowar")) || (a2.equals("Razer TiaMat") && a1.equals("Razer Manowar"))) {
return 0.5;
} else if ((a1.equals("Razer Chiamera") && a2.equals("Razer Manowar")) || (a2.equals("Razer Chiamera") && a1.equals("Razer Manowar"))) {
return 0.8;
} else {
return 0;
}
}
public static double retornaSimMotherboard (String a1, String a2) {
if (a1.equals("ATX Maximus VIII") && a2.equals("ATX Maximus VIII")) {
return 1;
} else if (a1.equals("ATX ROG STRIX") && a2.equals("ATX ROG STRIX")) {
return 1;
} else if (a1.equals("ATX Sabertooth") && a2.equals("ATX Sabertooth")) {
return 1;
} else if (a1.equals("ATX 970 PRO") && a2.equals("ATX 970 PRO")) {
return 1;
} else if ((a1.equals("ATX Maximus VIII") && a2.equals("ATX ROG STRIX")) || (a2.equals("ATX Maximus VIII") && a1.equals("ATX ROG STRIX"))) {
return 0.8;
} else if ((a1.equals("ATX Maximus VIII") && a2.equals("ATX Sabertooth")) || (a2.equals("ATX Maximus VIII") && a1.equals("ATX Sabertooth"))) {
return 0.6;
} else if ((a1.equals("ATX Maximus VIII") && a2.equals("ATX 970 PRO")) || (a2.equals("ATX Maximus VIII") && a1.equals("ATX 970 PRO"))) {
return 0.5;
} else if ((a1.equals("ATX ROG STRIX") && a2.equals("ATX Sabertooth")) || (a2.equals("ATX ROG STRIX") && a1.equals("ATX Sabertooth"))) {
return 0.7;
} else if ((a1.equals("ATX ROG STRIX") && a2.equals("ATX 970 PRO")) || (a2.equals("ATX ROG STRIX") && a1.equals("ATX 970 PRO"))) {
return 0.6;
} else if ((a1.equals("ATX Sabertooth") && a2.equals("ATX 970 PRO")) || (a2.equals("ATX Sabertooth") && a1.equals("ATX 970 PRO"))) {
return 0.9;
} else {
return 0;
}
}
public static void main(String[] args) {
ArrayList<String> gabinete = new ArrayList<String>();
ArrayList<String> processador = new ArrayList<String>();
ArrayList<String> memoria = new ArrayList<String>();
ArrayList<String> hd = new ArrayList<String>();
ArrayList<String> ssd = new ArrayList<String>();
ArrayList<String> gpu = new ArrayList<String>();
ArrayList<String> teclado = new ArrayList<String>();
ArrayList<String> mouse = new ArrayList<String>();
ArrayList<String> fonte = new ArrayList<String>();
ArrayList<String> refrigeracao = new ArrayList<String>();
ArrayList<String> monitor = new ArrayList<String>();
ArrayList<String> headset = new ArrayList<String>();
ArrayList<String> motherboard = new ArrayList<String>();
gabinete.add("Mid Tower");
gabinete.add("Full Tower");
processador.add("i7 6700K");
processador.add("i7 6700");
processador.add("i5 6600K");
processador.add("i5 6600");
memoria.add("HyperX 8GB 1600");
memoria.add("Vengeance 8GB 1600");
memoria.add("HyperX 8GB 1866");
memoria.add("HyperX 8GB 2133");
hd.add("WD 1TB 7200");
hd.add("Seagate 1TB 7200");
hd.add("Seagate 2TB 7200");
ssd.add("Kingston 120GB");
ssd.add("Sandisk 120GB");
ssd.add("Kingston 240GB");
ssd.add("Sandisk 240GB");
gpu.add("AMD R9 390");
gpu.add("AMD R9 Fury");
gpu.add("AMD R9 390X");
gpu.add("GTX 980 TI");
teclado.add("Razer BlackWidow");
teclado.add("Razer DeathStalker");
teclado.add("Razer Cynosa");
mouse.add("Razer Naga");
mouse.add("Razer Abyssus");
mouse.add("Razer Krait");
mouse.add("Razer Deathadder");
fonte.add("EVGA 1600W");
fonte.add("Corsair 1500W");
fonte.add("Coolermaster 1200W");
fonte.add("SeaSonic 1000W");
refrigeracao.add("Água");
refrigeracao.add("Ar");
monitor.add("Benq 27p 144Hz");
monitor.add("Asus 27p 144Hz");
monitor.add("Asus 27p QuadHD");
monitor.add("LG 25p FullHD");
headset.add("Razer Kraken");
headset.add("Razer TiaMat");
headset.add("Razer Chiamera");
headset.add("Razer Manowar");
motherboard.add("ATX Maximus VIII");
motherboard.add("ATX ROG STRIX");
motherboard.add("ATX Sabertooth");
motherboard.add("ATX 970 PRO");
String gabinetesel;
String processadorsel;
String memoriasel;
String hdsel;
String ssdsel;
String gpusel;
String tecladosel;
String mousesel;
String fontesel;
String refrigeracaosel;
String monitorsel;
String headsetsel;
String motherboardsel;
// VARIAVEIS PARA RECEBER O PESO DE CADA VARIAVEL DO RBC
Double pesogabinete;
Double pesoprocessador;
Double pesomemoria;
Double pesohd;
Double pesossd;
Double pesogpu;
Double pesoteclado;
Double pesomouse;
Double pesofonte;
Double pesorefrigeracao;
Double pesomonitor;
Double pesoheadset;
Double pesomotherboard;
// PEGA O VALOR SELECIONADO DA LISTA E COLOCA NA VARIAVEL CRIADA PARA ISSO
gabinetesel = "Mid Tower";
processadorsel = "i7 6700K";
memoriasel = "HyperX 8GB 1600";
hdsel = "WD 1TB 7200";
ssdsel = "Kingston 120GB";
gpusel = "AMD R9 390";
tecladosel = "Razer BlackWidow";
mousesel = "Razer Naga";
fontesel = "EVGA 1600W";
refrigeracaosel = "Água";
monitorsel = "Benq 27p 144Hz";
headsetsel = "Razer Kraken";
motherboardsel = "ATX Maximus VIII";
// PEGA OS VALORES DE PESO DE CADA VARIAVEL
pesogabinete = 1.0;
pesoprocessador = 1.0;
pesomemoria = 1.0;
pesohd = 1.0;
pesossd = 1.0;
pesogpu = 1.0;
pesoteclado = 1.0;
pesomouse = 1.0;
pesofonte = 1.0;
pesorefrigeracao = 1.0;
pesomonitor = 1.0;
pesoheadset = 1.0;
pesomotherboard = 1.0;
Vector row = new Vector();
//cria tabela
DefaultTableModel model = (DefaultTableModel) jTable1.getModel();
double prob;
for (int i = 0; i < 2; i ++) {
for (int j = 0; j < 4; j++){
for (int k = 0; k < 4; k++){
for (int l = 0; l < 3; l++){
for (int m = 0; m < 4; m++){
for (int n = 0; n < 4; n++){
for (int o = 0; o < 3; o++){
for (int p = 0; p < 4; p++){
for (int q = 0; q < 4; q++) {
for (int r = 0; r < 2; r++){
for (int s = 0; s < 4; s++){
for (int t = 0; t < 4; t++){
for (int u = 0; u < 4; u++) {
prob = ((pesogabinete * retornaSimGabinete(gabinetesel,gabinete.get(i))) + (pesoprocessador *(retornaSimProc(processadorsel,processador.get(j)))) + (pesomemoria * (retornaSimMem(memoriasel,memoria.get(k)))) + (pesohd * (retornaSimHd(hdsel,hd.get(l)))) + (pesossd * (retornaSimSsd(ssdsel,ssd.get(m)))) + (pesogpu * (retornaSimGpu(gpusel,gpu.get(n)))) + (pesoteclado * (retornaSimTeclado(tecladosel,teclado.get(o)))) + (pesomouse * (retornaSimMouse(mousesel,mouse.get(p)))) + (pesofonte * (retornaSimFonte(fontesel,fonte.get(q)))) + (pesorefrigeracao * (retornaSimRefrigeracao(refrigeracaosel,refrigeracao.get(r)))) + (pesomonitor * (retornaSimMonitor(monitorsel,monitor.get(s)))) + (pesoheadset * (retornaSimHeadset(headsetsel,headset.get(t)))) + (pesomotherboard * (retornaSimMotherboard(motherboardsel,motherboard.get(u))))) / (pesogabinete+pesoprocessador+pesomemoria+pesohd+pesossd+pesomouse+pesoteclado+pesogpu+pesofonte+pesorefrigeracao+pesomonitor+pesoheadset+pesomotherboard);
System.out.println(gabinete.get(i) + "," + processador.get(j) + "," + memoria.get(k) + "," + hd.get(l) + "," + ssd.get(m) + "," + gpu.get(n) + "," + teclado.get(o) + "," + mouse.get(p) + "," + fonte.get(q) + "," + refrigeracao.get(r) + "," + monitor.get(s) + "," + headset.get(t) + "," + motherboard.get(u) + " --> " + (prob*100) + "%" );
row.add(gabinete.get(i));
row.add(processador.get(j));
row.add(memoria.get(k));
row.add(hd.get(l));
row.add(ssd.get(m));
row.add(gpu.get(n));
row.add(teclado.get(o));
row.add(mouse.get(p));
row.add(fonte.get(q));
row.add(refrigeracao.get(r));
row.add(monitor.get(s));
row.add(headset.get(t));
row.add(motherboard.get(u));
row.add(Double.toString(prob));
model.addRow (row);
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
Please add a [mcve] so that it is possible to reproduce the code.
– user28595
Or simply use
table.getRowSorter().toggleSortOrder(modelColumnIndex)
– user28595
Friend, the complete code has more than 50000 lines and here is only allowed to post 30000, could you show this method that you mentioned in my example above? Grateful.
– Mutante
On [mcve], recommended reading: http://meta.pt.stackoverflow.com/a/5368/28595
– user28595
I updated the post, I believe it is now possible to reproduce the problem.
– Mutante
I couldn’t reproduce the code, many components are missing.
– user28595
@diegofm edited the post again, removed all components of jFrame and already left a data entry ready, now it is possible to execute the code just pasting it, do not need to make any changes, my doubt now is the following, as I display the variable data
prob
in a table with 14 columns (13 of the attributes [cabinet, processor, memory,..] and 1 of the similarity [Prob variable]) ordered increasing by the variable Prob.– Mutante
Where is jtable? The code is executable but in the problem you talk about sort jtable by a certain column, and in the code you don’t have one. Hardly ask this comes from a database? Isn’t it easier to bring already ordered from there, since there are many data? Do this in Gui you will lock your application to every item you add.
– user28595
I’m not bringing it from a database, I’m doing it straight through the GUI itself, I took my code from the jtable because it wasn’t working, I’ll update it there.
– Mutante
Updated, the problem that happens now is that it error when adding the table when I use the method
row.clear()
, if I take out the methodrow.clear()
it works partially, the only problem is that it puts all the lines equal (it always gets the first attribute because it doesn’t clear the vector). You know how I can fix it the way I said it ?– Mutante
Ai is already a completely different problem than the question. You can sort in
TableModel
or directly in the table with the command I showed, but with this code there is no way to demonstrate in your program. I can demonstrate with a different example and you try to adapt to your code.– user28595
Could you show the example? I thought it was strange that the
row.clear()
...– Mutante
The answer below answered you?
– user28595