List of usage examples for javax.swing JFileChooser JFileChooser
public JFileChooser()
JFileChooser
pointing to the user's default directory. From source file:be.ugent.maf.cellmissy.gui.controller.TracksWriterController.java
/** * Choose Directory/* ww w . j a v a 2 s . co m*/ */ private void chooseDirectory() { // Open a JFile Chooser JFileChooser fileChooser = new JFileChooser(); fileChooser.setDialogTitle("Select directory to save the files"); fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fileChooser.setAcceptAllFileFilterUsed(false); // in response to the button click, show open dialog int returnVal = fileChooser.showOpenDialog(tracksWriterDialog); if (returnVal == JFileChooser.APPROVE_OPTION) { directory = fileChooser.getSelectedFile(); } tracksWriterDialog.getDirectoryTextField().setText(directory.getAbsolutePath()); }
From source file:tarea1.controlador.java
public void seleccionOpcion(int z) throws IOException, Exception { switch (z) {// w w w.ja v a 2 s. c om case 1: { //ELEGIR UN ARCHIVO// //EN CASO DE QUERER CAMBIAR EL TIPO DE ARCHIVO. FileNameExtensionFilter filter = new FileNameExtensionFilter("Image Files", "bmp"); JFileChooser abrir = new JFileChooser(); abrir.setFileSelectionMode(JFileChooser.FILES_ONLY); abrir.setFileFilter(filter); abrir.setCurrentDirectory(new File(System.getProperty("user.home"))); int result = abrir.showOpenDialog(inicio); if (result == JFileChooser.APPROVE_OPTION) { // se seleciona el archivo de imagen original File selectedFile = abrir.getSelectedFile(); ruta = selectedFile.getAbsolutePath(); System.out.println("El archivo es: " + ruta); //ruta img = ImageIO.read(new File(ruta)); //se lee el archivo rotate = false; zoomv = false; escalav = false; brillos = false; contrastes = false; undoDelete = false; undoIndex = 0; Change(); inicio.setTitle("PDI: Tarea 3 -" + ruta); } } break;//end case 1 case 2: //imagen en negativo { //se crea un buffer BufferedImage imagenNegativa = new BufferedImage(ancho, alto, BufferedImage.TYPE_INT_RGB); //se convierten los colores a negativo y se va guardando en el buffer for (int y = 0; y < alto; y++) { for (int x = 0; x < ancho; x++) { int p = img.getRGB(x, y); //obtenermos el valor r g b a de cada pixel // int a = (p>>24)&0xff; int r = (p >> 16) & 0xff; int g = (p >> 8) & 0xff; int b = p & 0xff; //se resta el rbg r = truncate(255 - r); g = truncate(255 - g); b = truncate(255 - b); //se guarda el rgb p = (r << 16) | (g << 8) | b; imagenNegativa.setRGB(x, y, p); } } //PARA LOS ROTACIONES img = imagenNegativa; ancho = img.getWidth(); alto = img.getHeight(); //se crea un buffer imagenNegativa = new BufferedImage(ancho, alto, BufferedImage.TYPE_INT_RGB); //se convierten los colores a negativo y se va guardando en el buffer for (int y = 0; y < alto; y++) { for (int x = 0; x < ancho; x++) { int p = original.getRGB(x, y); //obtenermos el valor r g b a de cada pixel int a = (p >> 24) & 0xff; int r = (p >> 16) & 0xff; int g = (p >> 8) & 0xff; int b = p & 0xff; //se resta el rbg r = 255 - r; g = 255 - g; b = 255 - b; //se guarda el rgb p = (a << 24) | (r << 16) | (g << 8) | b; imagenNegativa.setRGB(x, y, p); } } img = imagenNegativa; Change(); } break;//end case 2 case 3: //flip imagen vertical { //buffer para la imagen BufferedImage mirrorimgV = new BufferedImage(ancho, alto, BufferedImage.TYPE_INT_RGB); //recorremos pixel a pixel tooooooooooooodo el buffer for (int i = 0; i < alto; i++) { for (int izquierda = 0, derecha = ancho - 1; izquierda < alto; izquierda++, derecha--) { int p = img.getRGB(izquierda, i); mirrorimgV.setRGB(derecha, i, p); } } img = mirrorimgV; Change(); } break;//end case 3 case 4://flip imagen horizontal { BufferedImage mirrorimgH = new BufferedImage(ancho, alto, BufferedImage.TYPE_INT_RGB); for (int i = 0; i < ancho; i++) { for (int arriba = 0, abajo = alto - 1; arriba < alto; arriba++, abajo--) { int p = img.getRGB(i, arriba); mirrorimgH.setRGB(i, abajo, p); } } img = mirrorimgH; Change(); } break;//end case 4 case 5: { //boton de reset //RESET File f = null; //leer image try { f = new File(ruta); rotate = false; zoomv = false; escalav = false; brillos = false; contrastes = false; undoDelete = false; undoIndex = 0; img = ImageIO.read(f); } catch (IOException e) { System.out.println(e); } Change(); } break; //end case 5 case 6: { //leer en formato binario FileNameExtensionFilter filter = new FileNameExtensionFilter("Image Files", "bmp"); JFileChooser abrir = new JFileChooser(); abrir.setFileSelectionMode(JFileChooser.FILES_ONLY); abrir.setFileFilter(filter); //abrir.setCurrentDirectory(new File(System.getProperty("user.home"))); abrir.setCurrentDirectory(new File(System.getProperty("user.dir"))); int result = abrir.showOpenDialog(inicio); if (result == JFileChooser.APPROVE_OPTION) { try { File selectedFile = abrir.getSelectedFile(); ruta = selectedFile.getAbsolutePath(); FileInputStream is = null; is = new FileInputStream(ruta); bmp.read(is); System.out.println("aqui"); MemoryImageSource mis = bmp.crearImageSource(); System.out.println("hola"); Image im = Toolkit.getDefaultToolkit().createImage(mis); //Para poder colorcarlo en el label //Image image = createImage(new MemoryImageSource(bmp.crearImageSource())); BufferedImage newImage = new BufferedImage(im.getWidth(null), im.getHeight(null), BufferedImage.TYPE_INT_RGB); //obtenemos la imagen que si se puede desplgar Graphics2D g = newImage.createGraphics(); g.drawImage(im, 0, 0, null); g.dispose(); img = newImage; rotate = false; zoomv = false; escalav = false; brillos = false; contrastes = false; undoDelete = false; undoIndex = 0; Change(); //add img info inicio.setTitle("PDI: Tarea 3 -" + ruta); //dimensiones, profundidad de bits, Mb ocupados content = ("Size: " + (bmp.tamArchivo) / 1000 + "kb\nDimension: " + bmp.ancho + " x " + bmp.alto + "\nBpp: " + bmp.bitsPorPixel + "bits"); ancho = bmp.ancho; alto = bmp.alto; } catch (Exception ex) { Logger.getLogger(controlador.class.getName()).log(Level.SEVERE, null, ex); } } //end approval if } break; //end case 6 //girar CW case 7: { BufferedImage new_Image = new BufferedImage(alto, ancho, BufferedImage.TYPE_INT_RGB); for (int i = 0; i < ancho; i++) { for (int j = 0; j < alto; j++) { int p = img.getRGB(i, j); new_Image.setRGB(alto - j - 1, i, p); } } img = new_Image; Change(); } break;//end case 7 //girar CCW case 8: { BufferedImage new_Image = new BufferedImage(alto, ancho, BufferedImage.TYPE_INT_RGB); for (int i = 0; i < ancho; i++) { for (int j = 0; j < alto; j++) { int p = img.getRGB(i, j); new_Image.setRGB(j, ancho - i - 1, p); } } img = new_Image; Change(); } break;//end case 8 case 9: { //Guardar Imagen FileNameExtensionFilter filter = new FileNameExtensionFilter("Image Files", "bmp"); JFileChooser fileChooser = new JFileChooser(); fileChooser.setFileFilter(filter); fileChooser.setDialogTitle("Save"); fileChooser.setCurrentDirectory(new File(System.getProperty("user.home"))); int userSelection = fileChooser.showSaveDialog(inicio); if (userSelection == JFileChooser.APPROVE_OPTION) { File fileToSave = fileChooser.getSelectedFile(); System.out.println("Save as file: " + fileToSave.getAbsolutePath() + ".bmp"); System.out.println("Save as: " + fileToSave.getName()); bmp.saveMyLifeTonight(fileToSave, img); } } break; case 10: { //free rotation double anguloCartesiano = inicio.optionr; double aux; if (rotate == false) { original = img; } //para la ilusion de rotar sobre la "misma imagen" if (anguloCartesiano < 0) { aux = anguloCartesiano; anguloCartesiano = anguloCartesiano + angulo; angulo = anguloCartesiano; } else if (anguloCartesiano > 0) { aux = anguloCartesiano; anguloCartesiano = angulo + anguloCartesiano; angulo = anguloCartesiano; } anguloCartesiano = anguloCartesiano * Math.PI / 180; //CC coordinates int x, y; double distance, anguloPolar; int pisoX, techoX, pisoY, techoY; double rasterX, rasterY; // colores de los pixeles Color colorTL = null, colorTR, colorBL, colorBR = null; // interpolaciones double intX, intY; double rojoT, verdeT, azulT; double rojoB, verdeB, azulB; int centroX, centroY; centroX = original.getWidth() / 2; centroY = original.getHeight() / 2; BufferedImage imagenRotada = new BufferedImage(original.getWidth(), original.getHeight(), BufferedImage.TYPE_INT_ARGB);//fondo transparente for (int i = 0; i < original.getHeight(); ++i) for (int j = 0; j < original.getWidth(); ++j) { // convert raster to Cartesian x = j - centroX; y = centroY - i; // convert Cartesian to polar distance = Math.sqrt(x * x + y * y); anguloPolar = 0.0; if (x == 0) { if (y == 0) { // centre of image, no rotation needed imagenRotada.setRGB(j, i, original.getRGB(j, i)); continue; } else if (y < 0) anguloPolar = 1.5 * Math.PI; else anguloPolar = 0.5 * Math.PI; } else anguloPolar = Math.atan2((double) y, (double) x); // anguloPolar -= anguloCartesiano; //polr a carte rasterX = distance * Math.cos(anguloPolar); rasterY = distance * Math.sin(anguloPolar); // cartesiano a raster rasterX = rasterX + (double) centroX; rasterY = (double) centroY - rasterY; pisoX = (int) (Math.floor(rasterX)); pisoY = (int) (Math.floor(rasterY)); techoX = (int) (Math.ceil(rasterX)); techoY = (int) (Math.ceil(rasterY)); // check bounds /// AQUIWWIUEI if (pisoX < 0 || techoX < 0 || pisoX >= original.getWidth() || techoX >= original.getWidth() || pisoY < 0 || techoY < 0 || pisoY >= original.getHeight() || techoY >= original.getHeight()) continue; intX = rasterX - (double) pisoX; intY = rasterY - (double) pisoY; colorTL = new Color(original.getRGB(pisoX, pisoY)); colorTR = new Color(original.getRGB(techoX, pisoY)); colorBL = new Color(original.getRGB(pisoX, techoY)); colorBR = new Color(original.getRGB(techoX, techoY)); // interpolacion horizontal top rojoT = (1 - intX) * colorTL.getRed() + intX * colorTR.getRed(); verdeT = (1 - intX) * colorTL.getGreen() + intX * colorTR.getGreen(); azulT = (1 - intX) * colorTL.getBlue() + intX * colorTR.getBlue(); // interpolacion horizontal bot rojoB = (1 - intX) * colorBL.getRed() + intX * colorBR.getRed(); verdeB = (1 - intX) * colorBL.getGreen() + intX * colorBR.getGreen(); azulB = (1 - intX) * colorBL.getBlue() + intX * colorBR.getBlue(); // interpolacion vertical int p = original.getRGB(j, i); int a = (p >> 24) & 0xff; int r = (p >> 16) & 0xff; int g = (p >> 8) & 0xff; int b = p & 0xff; r = truncate(Math.round((1 - intY) * rojoT + intY * rojoB)); g = truncate(Math.round((1 - intY) * verdeT + intY * verdeB)); b = truncate(Math.round((1 - intY) * azulT + intY * azulB)); p = (a << 24) | (r << 16) | (g << 8) | b; imagenRotada.setRGB(j, i, p); } img = imagenRotada; rotate = true; inicio.jLabel3.setBounds(0, 0, ancho, alto); ImageIcon icon = new ImageIcon(img); inicio.jLabel3.setIcon(icon); } break; //case 10 case 11: { //histogram //para recorrer todos los valores y obtener los samples /* for (y) { for (x) { pixel = raster.getDataElements(x, y, pixel); } } */ int BINS = 256; HistogramDataset dataset = new HistogramDataset(); Raster raster = img.getRaster(); double[] r = new double[ancho * alto]; ChartPanel panelB = null; ChartPanel panelG = null; ChartPanel panelR = null; ChartPanel panel; if (bmp.bitsPorPixel == 1) { r = raster.getSamples(0, 0, ancho, alto, 0, r); ColorModel ColorM = img.getColorModel(); dataset.addSeries("Grey", r, BINS); //de aqui para abajo es el plotting // chart all JFreeChart chart = ChartFactory.createHistogram("Histogram", "Value", "Count", dataset, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = (XYPlot) chart.getPlot(); XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer(); renderer.setBarPainter(new StandardXYBarPainter()); Paint[] paintArray = { new Color(0x80ff0000, true) }; plot.setDrawingSupplier( new DefaultDrawingSupplier(paintArray, DefaultDrawingSupplier.DEFAULT_FILL_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE)); panel = new ChartPanel(chart); panel.setMouseWheelEnabled(true); } else { r = raster.getSamples(0, 0, ancho, alto, 0, r); dataset.addSeries("Red", r, BINS); r = raster.getSamples(0, 0, ancho, alto, 1, r); dataset.addSeries("Green", r, BINS); r = raster.getSamples(0, 0, ancho, alto, 2, r); dataset.addSeries("Blue", r, BINS); //de aqui para abajo es el plotting // chart all JFreeChart chart = ChartFactory.createHistogram("Histogram", "Value", "Count", dataset, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = (XYPlot) chart.getPlot(); XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer(); renderer.setBarPainter(new StandardXYBarPainter()); // translucent red, green & blue Paint[] paintArray = { new Color(0x80ff0000, true), new Color(0x8000ff00, true), new Color(0x800000ff, true) }; plot.setDrawingSupplier( new DefaultDrawingSupplier(paintArray, DefaultDrawingSupplier.DEFAULT_FILL_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE)); panel = new ChartPanel(chart); panel.setMouseWheelEnabled(true); //CHART Red HistogramDataset datasetR = new HistogramDataset(); r = raster.getSamples(0, 0, ancho, alto, 0, r); datasetR.addSeries("Red", r, BINS); JFreeChart chartR = ChartFactory.createHistogram("Histogram B", "Value", "Count", datasetR, PlotOrientation.VERTICAL, true, true, false); XYPlot plotR = (XYPlot) chartR.getPlot(); XYBarRenderer rendererR = (XYBarRenderer) plotR.getRenderer(); rendererR.setBarPainter(new StandardXYBarPainter()); // translucent red, green & blue Paint[] paintArrayR = { new Color(0x80ff0000, true) }; plotR.setDrawingSupplier( new DefaultDrawingSupplier(paintArrayR, DefaultDrawingSupplier.DEFAULT_FILL_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE)); panelR = new ChartPanel(chartR); panelR.setMouseWheelEnabled(true); //CHART GREEN HistogramDataset datasetG = new HistogramDataset(); r = raster.getSamples(0, 0, ancho, alto, 1, r); datasetG.addSeries("Green", r, BINS); JFreeChart chartG = ChartFactory.createHistogram("Histogram G ", "Value", "Count", datasetG, PlotOrientation.VERTICAL, true, true, false); XYPlot plotG = (XYPlot) chartG.getPlot(); XYBarRenderer rendererG = (XYBarRenderer) plotG.getRenderer(); rendererG.setBarPainter(new StandardXYBarPainter()); // translucent red, green & blue Paint[] paintArrayG = { new Color(0x8000ff00, true) }; plotG.setDrawingSupplier( new DefaultDrawingSupplier(paintArrayG, DefaultDrawingSupplier.DEFAULT_FILL_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE)); panelG = new ChartPanel(chartG); panelG.setMouseWheelEnabled(true); //CHART BLUE HistogramDataset datasetB = new HistogramDataset(); r = raster.getSamples(0, 0, ancho, alto, 2, r); datasetB.addSeries("Blue", r, BINS); JFreeChart chartB = ChartFactory.createHistogram("Histogram B ", "Value", "Count", datasetB, PlotOrientation.VERTICAL, true, true, false); XYPlot plotB = (XYPlot) chartB.getPlot(); XYBarRenderer rendererB = (XYBarRenderer) plotB.getRenderer(); rendererB.setBarPainter(new StandardXYBarPainter()); // translucent red, green & blue Paint[] paintArrayB = { new Color(0x800000ff, true) }; plotB.setDrawingSupplier( new DefaultDrawingSupplier(paintArrayB, DefaultDrawingSupplier.DEFAULT_FILL_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE)); panelB = new ChartPanel(chartB); panelB.setMouseWheelEnabled(true); } //JTabbedPane jtp=new JTabbedPane(); if (!viewH) { inicio.jTabbedPane1.addTab("Histogram", panel); inicio.jTabbedPane1.addTab("Histogram R", panelR); inicio.jTabbedPane1.addTab("Histogram G", panelG); inicio.jTabbedPane1.addTab("Histogram B", panelB); viewH = true; } else { inicio.jTabbedPane1.remove(inicio.jTabbedPane1.indexOfTab("Histogram")); inicio.jTabbedPane1.remove(inicio.jTabbedPane1.indexOfTab("Histogram R")); inicio.jTabbedPane1.remove(inicio.jTabbedPane1.indexOfTab("Histogram G")); inicio.jTabbedPane1.remove(inicio.jTabbedPane1.indexOfTab("Histogram B")); viewH = false; } } break; case 12: { //BRILLO int dif = inicio.brillo; if (brillos == false) { original = img; } int ancho = img.getWidth(); int alto = img.getHeight(); //se crea un buffer BufferedImage brillito = new BufferedImage(ancho, alto, BufferedImage.TYPE_INT_RGB); //se convierten los colores a negativo y se va guardando en el buffer for (int y = 0; y < alto; y++) { for (int x = 0; x < ancho; x++) { int p = original.getRGB(x, y); //obtenemos el valor r g b a de cada pixel int a = (p >> 24) & 0xff; int r = (p >> 16) & 0xff; int g = (p >> 8) & 0xff; int b = p & 0xff; //se resta el rbg r = truncate(r + dif); g = truncate(g + dif); b = truncate(b + dif); //se guarda el rgb p = (r << 16) | (g << 8) | b; brillito.setRGB(x, y, p); } } img = brillito; brillos = true; inicio.jLabel3.setBounds(0, 0, ancho, alto); ImageIcon icon = new ImageIcon(img); inicio.jLabel3.setIcon(icon); } break; //end case 12 case 13: { //CONTRAST double dif = inicio.contraste; double level = Math.pow(((100.0 + dif) / 100.0), 2.0); if (contrastes == false) { original = img; } int ancho = original.getWidth(); int alto = original.getHeight(); BufferedImage contraste = new BufferedImage(ancho, alto, BufferedImage.TYPE_INT_RGB); for (int y = 0; y < alto; y++) { for (int x = 0; x < ancho; x++) { int p = original.getRGB(x, y); int a = (p >> 24) & 0xff; int r = (p >> 16) & 0xff; int g = (p >> 8) & 0xff; int b = p & 0xff; b = truncate((int) ((((((double) b / 255.0) - 0.5) * level) + 0.5) * 255.0)); g = truncate((int) ((((((double) g / 255.0) - 0.5) * level) + 0.5) * 255.0)); r = truncate((int) ((((((double) r / 255.0) - 0.5) * level) + 0.5) * 255.0)); p = (r << 16) | (g << 8) | b; contraste.setRGB(x, y, p); } } img = contraste; contrastes = true; inicio.jLabel3.setBounds(0, 0, ancho, alto); ImageIcon icon = new ImageIcon(img); inicio.jLabel3.setIcon(icon); } break;// case 13 case 14: { //UMBRALIZACION double u = inicio.umbral; if (inicio.jCheckBox1.isSelected()) { int ancho = img.getWidth(); int alto = img.getHeight(); BufferedImage contraste = new BufferedImage(ancho, alto, BufferedImage.TYPE_INT_RGB); for (int y = 0; y < alto; y++) { for (int x = 0; x < ancho; x++) { int p = img.getRGB(x, y); int a = (p >> 24) & 0xff; int r = (p >> 16) & 0xff; int g = (p >> 8) & 0xff; int b = p & 0xff; double mediana = (double) (r + b + g); mediana /= 3; int med = (int) Math.round(mediana); b = med; g = med; r = med; if (r <= u) r = 0; else r = 255; if (g <= u) g = 0; else g = 255; if (b <= u) b = 0; else b = 255; p = (r << 16) | (g << 8) | b; contraste.setRGB(x, y, p); } } img = contraste; Change(); } } break; case 15: { BufferedImage equalized = new BufferedImage(ancho, alto, BufferedImage.TYPE_INT_RGB); int r, g, b, a; int pixel = 0; //look up table rgb int[] rhist = new int[256]; int[] ghist = new int[256]; int[] bhist = new int[256]; for (int i = 0; i < rhist.length; i++) rhist[i] = 0; for (int i = 0; i < ghist.length; i++) ghist[i] = 0; for (int i = 0; i < bhist.length; i++) bhist[i] = 0; for (int i = 0; i < img.getWidth(); i++) { for (int j = 0; j < img.getHeight(); j++) { int red = new Color(img.getRGB(i, j)).getRed(); int green = new Color(img.getRGB(i, j)).getGreen(); int blue = new Color(img.getRGB(i, j)).getBlue(); rhist[red]++; ghist[green]++; bhist[blue]++; } } //histograma color ArrayList<int[]> imageHist = new ArrayList<int[]>(); imageHist.add(rhist); imageHist.add(ghist); imageHist.add(bhist); //lookup table ArrayList<int[]> imgLT = new ArrayList<int[]>(); // llenar rhist = new int[256]; ghist = new int[256]; bhist = new int[256]; for (int i = 0; i < rhist.length; i++) rhist[i] = 0; for (int i = 0; i < ghist.length; i++) ghist[i] = 0; for (int i = 0; i < bhist.length; i++) bhist[i] = 0; long rojosT = 0; long verdesT = 0; long azulT = 0; // float factorDeEscala = (float) (255.0 / (ancho * alto)); for (int i = 0; i < rhist.length; i++) { rojosT += imageHist.get(0)[i]; int valor = (int) (rojosT * factorDeEscala); if (valor > 255) { rhist[i] = 255; } else rhist[i] = valor; verdesT += imageHist.get(1)[i]; int valg = (int) (verdesT * factorDeEscala); if (valg > 255) { ghist[i] = 255; } else ghist[i] = valg; azulT += imageHist.get(2)[i]; int valb = (int) (azulT * factorDeEscala); if (valb > 255) { bhist[i] = 255; } else bhist[i] = valb; } imgLT.add(rhist); imgLT.add(ghist); imgLT.add(bhist); for (int i = 0; i < ancho; i++) { for (int j = 0; j < alto; j++) { // colores a = new Color(img.getRGB(i, j)).getAlpha(); r = new Color(img.getRGB(i, j)).getRed(); g = new Color(img.getRGB(i, j)).getGreen(); b = new Color(img.getRGB(i, j)).getBlue(); // nuevos valoooooores r = imgLT.get(0)[r]; g = imgLT.get(1)[g]; b = imgLT.get(2)[b]; // rgb otra vez pixel = colorToRGB(a, r, g, b); //imagen final equalized.setRGB(i, j, pixel); } } img = equalized; Change(); } break; case 16: { //zoom double du = inicio.zoom; double u = du / 100; if (zoomv == false) { original = img; } BufferedImage zoom = new BufferedImage(ancho, alto, BufferedImage.TYPE_INT_RGB); for (int i = 0; i < zoom.getHeight(); ++i) for (int j = 0; j < zoom.getWidth(); ++j) { //nearest if (tipo == 1) { int ax = (int) (Math.floor(i / u)); int ay = (int) (Math.floor(j / u)); int p = original.getRGB(ax, ay); zoom.setRGB(i, j, p); } //bilinear if (tipo == 2) { } //no loss if (tipo == 0) { int ax = (int) (i / u); int ay = (int) (j / u); int p = original.getRGB(ax, ay); zoom.setRGB(i, j, p); } } img = zoom; zoomv = true; inicio.jLabel3.setBounds(0, 0, ancho, alto); ImageIcon icon = new ImageIcon(img); inicio.jLabel3.setIcon(icon); } break; case 17: { //escala double du = inicio.escala; double u = du / 100; if (escalav == false) { original = img; } int escalaX = (int) (ancho * u); int escalaY = (int) (alto * u); BufferedImage escala = new BufferedImage(escalaX, escalaY, BufferedImage.TYPE_INT_RGB); for (int i = 0; i < escala.getHeight(); ++i) for (int j = 0; j < escala.getWidth(); ++j) { //R(x,y):= A(x/ax, y/ay) //R(x,y):= A(Floor x/10 ,Floor /10) //nearest if (tipo == 1) { int ax = (int) (Math.floor(i / u)); int ay = (int) (Math.floor(j / u)); int p = original.getRGB(ax, ay); escala.setRGB(i, j, p); } //bilinear if (tipo == 2) { } //no loss if (tipo == 0) { int ax = (int) (i / u); int ay = (int) (j / u); int p = original.getRGB(ax, ay); escala.setRGB(i, j, p); } } img = escala; escalav = true; inicio.jLabel3.setBounds(0, 0, ancho, alto); ImageIcon icon = new ImageIcon(img); inicio.jLabel3.setIcon(icon); content = ("Dimension: " + img.getWidth() + " x " + img.getHeight() + "\nBpp: " + bmp.bitsPorPixel + "bits"); } break; case 18://prewitt both { BufferedImage aux = new BufferedImage(ancho, alto, BufferedImage.TYPE_INT_RGB); aux = img; BufferedImage y, x; float[][] arraya = { { -1, 0, 1 }, { -1, 0, 1 }, { -1, 0, 1 } }; float[][] arrayb = { { -2, -1, 0, 1, 2 }, { -2, -1, 0, 1, 2 }, { -2, -1, 0, 1, 2 }, { -2, -1, 0, 1, 2 }, { -2, -1, 0, 1, 2 }, }; float[][] arrayc = { { -3, -2, -1, 0, 1, 2, 3 }, { -3, -2, -1, 0, 1, 2, 3 }, { -3, -2, -1, 0, 1, 2, 3 }, { -3, -2, -1, 0, 1, 2, 3 }, { -3, -2, -1, 0, 1, 2, 3 }, { -3, -2, -1, 0, 1, 2, 3 }, { -3, -2, -1, 0, 1, 2, 3 }, }; float[][] array = { { -1, -1, -1 }, { 0, 0, 0 }, { 1, 1, 1 } }; float[][] array2 = { { -2, -2, -2, -2, -2 }, { -1, -1, -1, -1, -1 }, { 0, 0, 0, 0, 0 }, { 1, 1, 1, 1, 1 }, { 2, 2, 2, 2, 2 }, }; float[][] array3 = { { -3, -3, -3, -3, -3, -3, -3 }, { -2, -2, -2, -2, -2, -2, -2 }, { -1, -1, -1, -1, -1, -1, -1 }, { 0, 0, 0, 0, 0, 0, 0 }, { 1, 1, 1, 1, 1, 1, 1 }, { 2, 2, 2, 2, 2, 2, 2 }, { 3, 3, 3, 3, 3, 3, 3 }, }; if (inicio.size == 7) { y = generalKernel(array3, 7); img = aux; x = generalKernel(arrayc, 7); } else if (inicio.size == 5) { y = generalKernel(array2, 5); img = aux; x = generalKernel(arrayb, 5); } else { y = generalKernel(array, 3); img = aux; x = generalKernel(arraya, 3); } for (int i = 0; i < ancho; i++) { for (int j = 0; j < alto; j++) { int p = x.getRGB(i, j); int p2 = y.getRGB(i, j); //obtenemos el valor r g b a de cada pixel int r = (p >> 16) & 0xff; int g = (p >> 8) & 0xff; int b = p & 0xff; int r2 = (p2 >> 16) & 0xff; int g2 = (p2 >> 8) & 0xff; int b2 = p2 & 0xff; //process int resR = truncate(Math.sqrt(Math.pow(r, 2) + Math.pow(r2, 2))); int resG = truncate(Math.sqrt(Math.pow(g, 2) + Math.pow(g2, 2))); int resB = truncate(Math.sqrt(Math.pow(b, 2) + Math.pow(b2, 2))); //se guarda el rgb p = (resR << 16) | (resG << 8) | resB; img.setRGB(i, j, p); } Change(); } } break; case 19://prewitt x { BufferedImage x; float[][] arraya = { { -1, 0, 1 }, { -1, 0, 1 }, { -1, 0, 1 } }; float[][] arrayb = { { -2, -1, 0, 1, 2 }, { -2, -1, 0, 1, 2 }, { -2, -1, 0, 1, 2 }, { -2, -1, 0, 1, 2 }, { -2, -1, 0, 1, 2 }, }; float[][] arrayc = { { -3, -2, -1, 0, 1, 2, 3 }, { -3, -2, -1, 0, 1, 2, 3 }, { -3, -2, -1, 0, 1, 2, 3 }, { -3, -2, -1, 0, 1, 2, 3 }, { -3, -2, -1, 0, 1, 2, 3 }, { -3, -2, -1, 0, 1, 2, 3 }, { -3, -2, -1, 0, 1, 2, 3 }, }; if (inicio.size == 7) { x = generalKernel(arrayc, 7); } else if (inicio.size == 5) { x = generalKernel(arrayb, 5); } else { x = generalKernel(arraya, 3); } img = x; Change(); } break; case 20://prewitt y { BufferedImage y; float[][] array = { { -1, -1, -1 }, { 0, 0, 0 }, { 1, 1, 1 } }; float[][] array2 = { { -2, -2, -2, -2, -2 }, { -1, -1, -1, -1, -1 }, { 0, 0, 0, 0, 0 }, { 1, 1, 1, 1, 1 }, { 2, 2, 2, 2, 2 }, }; float[][] array3 = { { -3, -3, -3, -3, -3, -3, -3 }, { -2, -2, -2, -2, -2, -2, -2 }, { -1, -1, -1, -1, -1, -1, -1 }, { 0, 0, 0, 0, 0, 0, 0 }, { 1, 1, 1, 1, 1, 1, 1 }, { 2, 2, 2, 2, 2, 2, 2 }, { 3, 3, 3, 3, 3, 3, 3 }, }; if (inicio.size == 7) { y = generalKernel(array3, 7); } else if (inicio.size == 5) { y = generalKernel(array2, 5); } else { y = generalKernel(array, 3); } img = y; Change(); } break; case 21://Sobel x { BufferedImage x; float[][] arraya = { { -1, 0, 1 }, { -2, 0, 2 }, { -1, 0, 1 } }; float[][] arrayb = { { -5, -4, 0, 4, 5 }, { -8, -10, 0, 10, 8 }, { -10, -20, 0, 20, 10 }, { -8, -10, 0, 10, 8 }, { -5, -4, 0, 4, 5 }, }; float[][] arrayc = { { 3, 2, 1, 0, -1, -2, -3 }, { 4, 3, 2, 0, -2, -3, -4 }, { 5, 4, 3, 0, -3, -4, -5 }, { 6, 5, 4, 0, -4, -5, -6 }, { 5, 4, 3, 0, -3, -4, -5 }, { 4, 3, 2, 0, -2, -3, -4 }, { 3, 2, 1, 0, -1, -2, -3 }, }; if (inicio.size == 7) { x = generalKernel(arrayc, 7); } else if (inicio.size == 5) { x = generalKernel(arrayb, 5); } else { x = generalKernel(arraya, 3); } img = x; Change(); } break; case 22://sobel y { BufferedImage y; float[][] array1 = { { -1, -2, -1 }, { 0, 0, 0 }, { 1, 2, 1 } }; float[][] array2 = { { 5, 8, 10, 8, 5 }, { 4, 10, 20, 10, 4 }, { 0, 0, 0, 0, 0 }, { -4, -10, -20, -10, -4 }, { -5, -8, -10, -8, -5 }, }; float[][] array3 = { { 3, 4, 5, 6, 5, 4, 3 }, { 2, 3, 4, 5, 4, 3, 2 }, { 1, 2, 3, 4, 3, 2, 1 }, { 0, 0, 0, 0, 0, 0, 0 }, { -1, -2, -3, -4, -3, -2, -1 }, { -2, -3, -4, -5, -4, -3, -2 }, { -3, -4, -5, -6, -5, -4, -3 }, }; if (inicio.size == 7) { y = generalKernel(array3, 7); } else if (inicio.size == 5) { y = generalKernel(array2, 5); } else { y = generalKernel(array1, 3); } img = y; Change(); } break; case 23://sobel both { BufferedImage aux = new BufferedImage(ancho, alto, BufferedImage.TYPE_INT_RGB); aux = img; BufferedImage y, x; float[][] arraya = { { -1, 0, 1 }, { -2, 0, 2 }, { -1, 0, 1 } }; float[][] arrayb = { { -5, -4, 0, 4, 5 }, { -8, -10, 0, 10, 8 }, { -10, -20, 0, 20, 10 }, { -8, -10, 0, 10, 8 }, { -5, -4, 0, 4, 5 }, }; float[][] arrayc = { { 3, 2, 1, 0, -1, -2, -3 }, { 4, 3, 2, 0, -2, -3, -4 }, { 5, 4, 3, 0, -3, -4, -5 }, { 6, 5, 4, 0, -4, -5, -6 }, { 5, 4, 3, 0, -3, -4, -5 }, { 4, 3, 2, 0, -2, -3, -4 }, { 3, 2, 1, 0, -1, -2, -3 }, }; float[][] array1 = { { -1, -2, -1 }, { 0, 0, 0 }, { 1, 2, 1 } }; float[][] array2 = { { 5, 8, 10, 8, 5 }, { 4, 10, 20, 10, 4 }, { 0, 0, 0, 0, 0 }, { -4, -10, -20, -10, -4 }, { -5, -8, -10, -8, -5 }, }; float[][] array3 = { { 3, 4, 5, 6, 5, 4, 3 }, { 2, 3, 4, 5, 4, 3, 2 }, { 1, 2, 3, 4, 3, 2, 1 }, { 0, 0, 0, 0, 0, 0, 0 }, { -1, -2, -3, -4, -3, -2, -1 }, { -2, -3, -4, -5, -4, -3, -2 }, { -3, -4, -5, -6, -5, -4, -3 }, }; if (inicio.size == 7) { y = generalKernel(array3, 7); img = aux; x = generalKernel(arrayc, 7); } else if (inicio.size == 5) { y = generalKernel(array2, 5); img = aux; x = generalKernel(arrayb, 5); } else { y = generalKernel(array1, 3); img = aux; x = generalKernel(arraya, 3); } for (int i = 0; i < ancho; i++) { for (int j = 0; j < alto; j++) { int p = x.getRGB(i, j); int p2 = y.getRGB(i, j); //obtenermos el valor r g b a de cada pixel int r = (p >> 16) & 0xff; int g = (p >> 8) & 0xff; int b = p & 0xff; int r2 = (p2 >> 16) & 0xff; int g2 = (p2 >> 8) & 0xff; int b2 = p2 & 0xff; //process int resR = truncate(Math.sqrt(Math.pow(r, 2) + Math.pow(r2, 2))); int resG = truncate(Math.sqrt(Math.pow(g, 2) + Math.pow(g2, 2))); int resB = truncate(Math.sqrt(Math.pow(b, 2) + Math.pow(b2, 2))); //se guarda el rgb p = (resR << 16) | (resG << 8) | resB; img.setRGB(i, j, p); } Change(); } } break; case 24://Gauss { BufferedImage y; float[][] arraya = { { 1 / 16f, 1 / 8f, 1 / 16f }, { 1 / 8f, 1 / 4f, 1 / 8f }, { 1 / 16f, 1 / 8f, 1 / 16f }, }; float[][] arrayb = { { 1 / 273f, 4 / 273f, 7 / 273f, 4 / 273f, 1 / 273f }, { 4 / 273f, 16 / 273f, 26 / 273f, 16 / 273f, 4 / 273f }, { 7 / 273f, 26 / 273f, 41 / 273f, 26 / 273f, 7 / 273f }, { 4 / 273f, 16 / 273f, 26 / 273f, 16 / 273f, 4 / 273f }, { 1 / 273f, 4 / 273f, 7 / 273f, 4 / 273f, 1 / 273f }, }; float[][] arrayc = { { 0.00000067f, 0.00002292f, 0.00019117f, 0.00038771f, 0.00019117f, 0.00002292f, 0.00000067f }, { 0.00002292f, 0.00078634f, 0.00655965f, 0.01330373f, 0.00655965f, 0.00078633f, 0.00002292f }, { 0.00019117f, 0.00655965f, 0.05472157f, 0.11098164f, 0.05472157f, 0.00655965f, 0.00019117f }, { 0.00038771f, 0.01330373f, 0.11098164f, 0.22508352f, 0.11098164f, 0.01330373f, 0.00038771f }, { 0.00019117f, 0.00655965f, 0.05472157f, 0.11098164f, 0.05472157f, 0.00655965f, 0.00019117f }, { 0.00002292f, 0.00078634f, 0.00655965f, 0.01330373f, 0.00655965f, 0.00078633f, 0.00002292f }, { 0.00000067f, 0.00002292f, 0.00019117f, 0.00038771f, 0.00019117f, 0.00002292f, 0.00000067f } }; if (inicio.size == 7) { y = generalKernel(arrayc, 7); } else if (inicio.size == 5) { y = generalKernel(arrayb, 5); } else { y = generalKernel(arraya, 3); } img = y; Change(); } break; case 25: { BufferedImage y; float[][] arraya = { { 1 / 9f, 1 / 9f, 1 / 9f }, { 1 / 9f, 1 / 9f, 1 / 9f }, { 1 / 9f, 1 / 9f, 1 / 9f }, }; float[][] arrayb = { { 1 / 25f, 1 / 25f, 1 / 25f, 1 / 25f, 1 / 25f }, { 1 / 25f, 1 / 25f, 1 / 25f, 1 / 25f, 1 / 25f }, { 1 / 25f, 1 / 25f, 1 / 25f, 1 / 25f, 1 / 25f }, { 1 / 25f, 1 / 25f, 1 / 25f, 1 / 25f, 1 / 25f }, { 1 / 25f, 1 / 25f, 1 / 25f, 1 / 25f, 1 / 25f }, }; float[][] arrayc = { { 1 / 49f, 1 / 49f, 1 / 49f, 1 / 49f, 1 / 49f, 1 / 49f, 1 / 49f }, { 1 / 49f, 1 / 49f, 1 / 49f, 1 / 49f, 1 / 49f, 1 / 49f, 1 / 49f }, { 1 / 49f, 1 / 49f, 1 / 49f, 1 / 49f, 1 / 49f, 1 / 49f, 1 / 49f }, { 1 / 49f, 1 / 49f, 1 / 49f, 1 / 49f, 1 / 49f, 1 / 49f, 1 / 49f }, { 1 / 49f, 1 / 49f, 1 / 49f, 1 / 49f, 1 / 49f, 1 / 49f, 1 / 49f }, { 1 / 49f, 1 / 49f, 1 / 49f, 1 / 49f, 1 / 49f, 1 / 49f, 1 / 49f }, { 1 / 49f, 1 / 49f, 1 / 49f, 1 / 49f, 1 / 49f, 1 / 49f, 1 / 49f }, }; if (inicio.size == 7) { y = generalKernel(arrayc, 7); } else if (inicio.size == 5) { y = generalKernel(arrayb, 5); } else { y = generalKernel(arraya, 3); } img = y; Change(); } break; case 26://sharpen { BufferedImage y; float[][] arraya = { { -1, -1, -1 }, { -1, 9, -1 }, { -1, -1, -1 }, }; float[][] arrayb = { { -1, -1, -1, -1, -1 }, { -1, -1, -1, -1, -1 }, { -1, -1, 26, -1, -1 }, { -1, -1, -1, -1, -1 }, { -1, -1, -1, -1, -1 }, }; float[][] arrayc = { { -1, -1, -1, -1, -1, -1, -1 }, { -1, -2, -2, -2, -2, -2, -1 }, { -1, -2, -3, -3, -3, -2, -1 }, { -1, -2, -3, 81, -3, -2, -1 }, { -1, -2, -3, -3, -3, -2, -1 }, { -1, -2, -2, -2, -2, -2, -1 }, { -1, -1, -1, -1, -1, -1, -1 }, }; if (inicio.size == 7) { y = generalKernel(arrayc, 7); } else if (inicio.size == 5) { y = generalKernel(arrayb, 5); } else { y = generalKernel(arraya, 3); } img = y; Change(); } break; case 27: { kernel = new Kernel(); kernel.show(); kernel.setTitle("Kernel"); kernel.setVisible(true); kernel.setLocationRelativeTo(null); kernel.setResizable(false); kernel.pack(); } break; case 28: //valores { float[][] floatdata = new float[kernel.dim][kernel.dim]; for (int i = 0; i < kernel.dim; i++) { for (int j = 0; j < kernel.dim; j++) { floatdata[i][j] = floatValue(kernel.tableData[i][j]); } } kernel.dispose(); BufferedImage y; y = generalKernel(floatdata, kernel.dim); img = y; Change(); } break; case 29://motion blur { BufferedImage y; float[][] array = { { 1 / 9f, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 1 / 9f, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 1 / 9f, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 1 / 9f, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 1 / 9f, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 1 / 9f, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 1 / 9f, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 1 / 9f, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 1 / 9f }, }; /* float[][] arrayb = { {1/3f, 0, 0}, {0, 1/3f, 0}, {0, 0, 1/3f}, };*/ y = generalKernel(array, 9); img = y; Change(); } break; } //end switch }
From source file:com.josescalia.tumblr.form.PreferenceForm.java
/** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor./* www .j a v a 2 s .c om*/ */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { bindingGroup = new org.jdesktop.beansbinding.BindingGroup(); rbGroupUseProxy = new ButtonGroup(); folderChooser = new JFileChooser(); jTabbedPane1 = new JTabbedPane(); jPanel1 = new JPanel(); jPanel10 = new JPanel(); jLabel29 = new JLabel(); jLabel26 = new JLabel(); jLabel25 = new JLabel(); jLabel24 = new JLabel(); jLabel28 = new JLabel(); jLabel27 = new JLabel(); jPanel12 = new JPanel(); txtProxyPort = new JTextField(); rbUseProxy = new JRadioButton(); jLabel2 = new JLabel(); rbNoProxy = new JRadioButton(); txtProxyPassword = new JPasswordField(); jLabel3 = new JLabel(); txtProxyUsername = new JTextField(); btnSaveProxyConfig = new JButton(); jLabel1 = new JLabel(); jLabel4 = new JLabel(); txtProxyHost = new JTextField(); checkProxyNeedAuth = new JCheckBox(); jPanel2 = new JPanel(); jPanel11 = new JPanel(); jLabel35 = new JLabel(); jLabel30 = new JLabel(); jLabel33 = new JLabel(); jLabel32 = new JLabel(); jLabel31 = new JLabel(); jLabel34 = new JLabel(); jPanel14 = new JPanel(); txtDefaultFolderPath1 = new JTextField(); jLabel6 = new JLabel(); txtDefaultFolderPath = new JTextField(); jLabel7 = new JLabel(); btnChooseFolder = new JButton(); btnSaveAppConfig = new JButton(); jPanel7 = new JPanel(); jPanel9 = new JPanel(); jLabel18 = new JLabel(); jLabel23 = new JLabel(); jLabel19 = new JLabel(); jLabel21 = new JLabel(); jLabel20 = new JLabel(); jLabel22 = new JLabel(); jPanel13 = new JPanel(); jLabel8 = new JLabel(); btnOpenOtherCacheFolder = new JButton(); btnDeleteCache = new JButton(); jLabel9 = new JLabel(); txtTotalFileSize1 = new JTextField(); txtTotalFileSize = new JTextField(); jPanel3 = new JPanel(); jPanel5 = new JPanel(); txtTotalLogSize = new JTextField(); jLabel11 = new JLabel(); txtTotalLog = new JTextField(); btnCleanLog = new JButton(); jLabel13 = new JLabel(); jPanel6 = new JPanel(); jLabel12 = new JLabel(); jScrollPane1 = new JScrollPane(); txtLogContent = new JTextArea(); jPanel8 = new JPanel(); jLabel17 = new JLabel(); jLabel16 = new JLabel(); jLabel15 = new JLabel(); jLabel14 = new JLabel(); jPanel4 = new JPanel(); jPanel15 = new JPanel(); txtAppLookAndFeel = new JTextField(); jLabel10 = new JLabel(); btnSaveLF = new JButton(); btnSelectLF = new JButton(); jPanel16 = new JPanel(); jLabel41 = new JLabel(); jLabel36 = new JLabel(); jLabel40 = new JLabel(); jLabel37 = new JLabel(); jLabel38 = new JLabel(); jLabel39 = new JLabel(); jLabel5 = new JLabel(); jPanel1.setBorder(BorderFactory.createEtchedBorder()); jPanel10.setBackground(Color.white); jPanel10.setBorder(BorderFactory.createEtchedBorder()); jLabel29.setFont(new Font("Liberation Sans", 0, 12)); // NOI18N jLabel29.setText("set up this Proxy Connection."); jLabel26.setFont(new Font("Liberation Sans", 0, 12)); // NOI18N jLabel26.setText("if this application need to connect to the internet. The setting of this "); jLabel25.setFont(new Font("Liberation Sans", 0, 12)); // NOI18N jLabel25.setText("The Proxy Connection is a set of configuration which will be applied"); jLabel24.setFont(new Font("Liberation Sans", 1, 12)); // NOI18N jLabel24.setText("Info :"); jLabel28.setFont(new Font("Liberation Sans", 0, 12)); // NOI18N jLabel28.setText("configuration. Contact Computer Network Administrator to correctly"); jLabel27.setFont(new Font("Liberation Sans", 0, 12)); // NOI18N jLabel27.setText("Proxy Connection should be match with the computer network"); GroupLayout jPanel10Layout = new GroupLayout(jPanel10); jPanel10.setLayout(jPanel10Layout); jPanel10Layout.setHorizontalGroup(jPanel10Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel10Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel10Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(jLabel28).addComponent(jLabel25).addComponent(jLabel24) .addComponent(jLabel26).addComponent(jLabel27).addComponent(jLabel29)) .addContainerGap())); jPanel10Layout.setVerticalGroup(jPanel10Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel10Layout.createSequentialGroup().addContainerGap().addComponent(jLabel24) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel25) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel26) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel27) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel28) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel29) .addContainerGap())); jPanel12.setBorder(BorderFactory.createEtchedBorder()); txtProxyPort.setEnabled(false); org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${proxyConnection.proxyPort}"), txtProxyPort, org.jdesktop.beansbinding.BeanProperty.create("text")); bindingGroup.addBinding(binding); rbGroupUseProxy.add(rbUseProxy); rbUseProxy.setText("Use Proxy"); rbUseProxy.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { rbUseProxyActionPerformed(evt); } }); jLabel2.setText("Proxy Port"); rbGroupUseProxy.add(rbNoProxy); rbNoProxy.setText("No Proxy"); rbNoProxy.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { rbNoProxyActionPerformed(evt); } }); txtProxyPassword.setEnabled(false); binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${proxyConnection.proxyPassword}"), txtProxyPassword, org.jdesktop.beansbinding.BeanProperty.create("text")); bindingGroup.addBinding(binding); jLabel3.setText("Username "); txtProxyUsername.setEnabled(false); binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${proxyConnection.proxyUsername}"), txtProxyUsername, org.jdesktop.beansbinding.BeanProperty.create("text")); bindingGroup.addBinding(binding); btnSaveProxyConfig.setIcon(new ImageIcon(getClass().getResource("/icons/edit.png"))); // NOI18N btnSaveProxyConfig.setText("Save"); btnSaveProxyConfig.setHorizontalTextPosition(SwingConstants.CENTER); btnSaveProxyConfig.setVerticalTextPosition(SwingConstants.BOTTOM); btnSaveProxyConfig.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnSaveProxyConfigActionPerformed(evt); } }); jLabel1.setText("Proxy Host"); jLabel4.setText("Password"); txtProxyHost.setEnabled(false); binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${proxyConnection.proxyHost}"), txtProxyHost, org.jdesktop.beansbinding.BeanProperty.create("text")); bindingGroup.addBinding(binding); checkProxyNeedAuth.setText("Proxy Need Authentication"); binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${bUseProxyAuth}"), checkProxyNeedAuth, org.jdesktop.beansbinding.BeanProperty.create("selected")); bindingGroup.addBinding(binding); checkProxyNeedAuth.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { checkProxyNeedAuthActionPerformed(evt); } }); GroupLayout jPanel12Layout = new GroupLayout(jPanel12); jPanel12.setLayout(jPanel12Layout); jPanel12Layout.setHorizontalGroup(jPanel12Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel12Layout.createSequentialGroup().addContainerGap().addGroup(jPanel12Layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel12Layout.createSequentialGroup().addComponent(rbNoProxy) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(rbUseProxy)) .addGroup(jPanel12Layout.createSequentialGroup().addGroup(jPanel12Layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(jLabel1, GroupLayout.PREFERRED_SIZE, 80, GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2, GroupLayout.PREFERRED_SIZE, 80, GroupLayout.PREFERRED_SIZE) .addComponent(jLabel3).addComponent(jLabel4)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel12Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(txtProxyPort, GroupLayout.PREFERRED_SIZE, 105, GroupLayout.PREFERRED_SIZE) .addComponent(txtProxyHost, GroupLayout.PREFERRED_SIZE, 297, GroupLayout.PREFERRED_SIZE) .addGroup(jPanel12Layout .createParallelGroup(GroupLayout.Alignment.TRAILING, false) .addComponent(txtProxyPassword, GroupLayout.Alignment.LEADING) .addComponent(txtProxyUsername, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 227, GroupLayout.PREFERRED_SIZE)))) .addComponent(checkProxyNeedAuth).addComponent(btnSaveProxyConfig, GroupLayout.PREFERRED_SIZE, 89, GroupLayout.PREFERRED_SIZE)) .addContainerGap())); jPanel12Layout.setVerticalGroup(jPanel12Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel12Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel12Layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(rbNoProxy).addComponent(rbUseProxy)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel12Layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(jLabel1).addComponent(txtProxyHost, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel12Layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(jLabel2).addComponent(txtProxyPort, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGap(4, 4, 4).addComponent(checkProxyNeedAuth) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel12Layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(txtProxyUsername, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(jLabel3)) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel12Layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(txtProxyPassword, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(jLabel4)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(btnSaveProxyConfig) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); GroupLayout jPanel1Layout = new GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout .setHorizontalGroup( jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap() .addComponent(jPanel12, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel10, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addContainerGap(286, Short.MAX_VALUE))); jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addGap(11, 11, 11) .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(jPanel12, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(jPanel10, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addContainerGap(165, Short.MAX_VALUE))); jTabbedPane1.addTab("Proxy Connection", jPanel1); jPanel2.setBorder(BorderFactory.createEtchedBorder()); jPanel11.setBackground(Color.white); jPanel11.setBorder(BorderFactory.createEtchedBorder()); jLabel35.setFont(new Font("Liberation Sans", 0, 12)); // NOI18N jLabel35.setText("the application is trigger to open a folder."); jLabel30.setFont(new Font("Liberation Sans", 1, 12)); // NOI18N jLabel30.setText("Info :"); jLabel33.setFont(new Font("Liberation Sans", 0, 12)); // NOI18N jLabel33.setText("application downloading stuff from the internet."); jLabel32.setFont(new Font("Liberation Sans", 0, 12)); // NOI18N jLabel32.setText("Default Download Path is the default folder location when the "); jLabel31.setFont(new Font("Liberation Sans", 0, 12)); // NOI18N jLabel31.setText("This is the set of configuration will be used by this application."); jLabel34.setFont(new Font("Liberation Sans", 0, 12)); // NOI18N jLabel34.setText("Default Folder Viewer is the default of computer programs when "); GroupLayout jPanel11Layout = new GroupLayout(jPanel11); jPanel11.setLayout(jPanel11Layout); jPanel11Layout.setHorizontalGroup(jPanel11Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel11Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel11Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(jLabel30).addComponent(jLabel31).addComponent(jLabel32) .addComponent(jLabel33).addComponent(jLabel34).addComponent(jLabel35)) .addContainerGap())); jPanel11Layout.setVerticalGroup(jPanel11Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel11Layout.createSequentialGroup().addContainerGap().addComponent(jLabel30) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel31) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel32) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel33) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel34) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel35) .addContainerGap())); jPanel14.setBorder(BorderFactory.createEtchedBorder()); binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${defaultFolderViewer}"), txtDefaultFolderPath1, org.jdesktop.beansbinding.BeanProperty.create("text")); bindingGroup.addBinding(binding); jLabel6.setText("Default Download Path"); binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${defaultDownloadPath}"), txtDefaultFolderPath, org.jdesktop.beansbinding.BeanProperty.create("text")); bindingGroup.addBinding(binding); jLabel7.setText("Default Folder Viewer"); btnChooseFolder.setText("Change"); btnChooseFolder.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnChooseFolderActionPerformed(evt); } }); btnSaveAppConfig.setIcon(new ImageIcon(getClass().getResource("/icons/edit.png"))); // NOI18N btnSaveAppConfig.setText("Save"); btnSaveAppConfig.setHorizontalTextPosition(SwingConstants.CENTER); btnSaveAppConfig.setVerticalTextPosition(SwingConstants.BOTTOM); btnSaveAppConfig.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnSaveAppConfigActionPerformed(evt); } }); GroupLayout jPanel14Layout = new GroupLayout(jPanel14); jPanel14.setLayout(jPanel14Layout); jPanel14Layout.setHorizontalGroup(jPanel14Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel14Layout.createSequentialGroup().addContainerGap().addGroup(jPanel14Layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel14Layout.createSequentialGroup() .addComponent(jLabel7, GroupLayout.PREFERRED_SIZE, 161, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(txtDefaultFolderPath1, GroupLayout.PREFERRED_SIZE, 258, GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel14Layout.createSequentialGroup() .addComponent(jLabel6, GroupLayout.PREFERRED_SIZE, 161, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(txtDefaultFolderPath, GroupLayout.PREFERRED_SIZE, 346, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(btnChooseFolder)) .addComponent(btnSaveAppConfig, GroupLayout.PREFERRED_SIZE, 95, GroupLayout.PREFERRED_SIZE)) .addContainerGap())); jPanel14Layout.setVerticalGroup(jPanel14Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel14Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel14Layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(jLabel6) .addComponent(txtDefaultFolderPath, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(btnChooseFolder)) .addGap(4, 4, 4) .addGroup(jPanel14Layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(jLabel7).addComponent(txtDefaultFolderPath1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btnSaveAppConfig).addContainerGap())); GroupLayout jPanel2Layout = new GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout .setHorizontalGroup( jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap() .addComponent(jPanel14, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel11, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addContainerGap())); jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING, false) .addComponent(jPanel11, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel14, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap(285, Short.MAX_VALUE))); jTabbedPane1.addTab("Application Config", jPanel2); jPanel9.setBackground(Color.white); jPanel9.setBorder(BorderFactory.createEtchedBorder()); jLabel18.setFont(new Font("Liberation Sans", 1, 12)); // NOI18N jLabel18.setText("Info :"); jLabel23.setFont(new Font("Liberation Sans", 0, 12)); // NOI18N jLabel23.setText("make the application processing faster."); jLabel19.setFont(new Font("Liberation Sans", 0, 12)); // NOI18N jLabel19.setText("Cache Info contains a summary of how much space in hard drive"); jLabel21.setFont(new Font("Liberation Sans", 0, 12)); // NOI18N jLabel21.setText("hard drive space by this application, but if the application need to"); jLabel20.setFont(new Font("Liberation Sans", 0, 12)); // NOI18N jLabel20.setText("used by this application. Deleting cache will reduce the usage of"); jLabel22.setFont(new Font("Liberation Sans", 0, 12)); // NOI18N jLabel22.setText("fetch the data from internet, this cache will be used in order to"); GroupLayout jPanel9Layout = new GroupLayout(jPanel9); jPanel9.setLayout(jPanel9Layout); jPanel9Layout.setHorizontalGroup(jPanel9Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel9Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel9Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(jLabel18).addComponent(jLabel19).addComponent(jLabel20) .addComponent(jLabel21).addComponent(jLabel22).addComponent(jLabel23)) .addContainerGap())); jPanel9Layout.setVerticalGroup(jPanel9Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel9Layout.createSequentialGroup().addContainerGap().addComponent(jLabel18) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel19) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel20) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel21) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel22) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel23) .addContainerGap())); jPanel13.setBorder(BorderFactory.createEtchedBorder()); jLabel8.setText("Total Cache File Size"); btnOpenOtherCacheFolder.setIcon(new ImageIcon(getClass().getResource("/icons/folder_open.png"))); // NOI18N btnOpenOtherCacheFolder.setText("Open Dir"); btnOpenOtherCacheFolder.setHorizontalTextPosition(SwingConstants.CENTER); btnOpenOtherCacheFolder.setVerticalTextPosition(SwingConstants.BOTTOM); btnOpenOtherCacheFolder.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnOpenOtherCacheFolderActionPerformed(evt); } }); btnDeleteCache.setIcon(new ImageIcon(getClass().getResource("/icons/cross2.png"))); // NOI18N btnDeleteCache.setText("Delete Cache"); btnDeleteCache.setHorizontalTextPosition(SwingConstants.CENTER); btnDeleteCache.setVerticalTextPosition(SwingConstants.BOTTOM); btnDeleteCache.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnDeleteCacheActionPerformed(evt); } }); jLabel9.setText("Total Cache File"); txtTotalFileSize1.setEditable(false); binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${cacheFile.fileListSize}"), txtTotalFileSize1, org.jdesktop.beansbinding.BeanProperty.create("text")); bindingGroup.addBinding(binding); txtTotalFileSize.setEditable(false); binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${cacheFile.totalFolderSize}"), txtTotalFileSize, org.jdesktop.beansbinding.BeanProperty.create("text")); bindingGroup.addBinding(binding); GroupLayout jPanel13Layout = new GroupLayout(jPanel13); jPanel13.setLayout(jPanel13Layout); jPanel13Layout.setHorizontalGroup(jPanel13Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel13Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel13Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(jLabel8).addComponent(jLabel9).addComponent(btnDeleteCache)) .addGap(18, 18, 18) .addGroup(jPanel13Layout.createParallelGroup(GroupLayout.Alignment.TRAILING, false) .addComponent(txtTotalFileSize1, GroupLayout.Alignment.LEADING) .addComponent(btnOpenOtherCacheFolder, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 103, Short.MAX_VALUE) .addComponent(txtTotalFileSize)) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); jPanel13Layout.setVerticalGroup(jPanel13Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel13Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel13Layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(jLabel8).addComponent(txtTotalFileSize, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel13Layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(jLabel9).addComponent(txtTotalFileSize1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel13Layout.createParallelGroup(GroupLayout.Alignment.LEADING, false) .addComponent(btnDeleteCache, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btnOpenOtherCacheFolder)) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); GroupLayout jPanel7Layout = new GroupLayout(jPanel7); jPanel7.setLayout(jPanel7Layout); jPanel7Layout.setHorizontalGroup(jPanel7Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel7Layout.createSequentialGroup().addContainerGap() .addComponent(jPanel13, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(jPanel9, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addContainerGap(443, Short.MAX_VALUE))); jPanel7Layout.setVerticalGroup(jPanel7Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel7Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel7Layout.createParallelGroup(GroupLayout.Alignment.LEADING, false) .addComponent(jPanel9, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel13, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap(289, Short.MAX_VALUE))); jTabbedPane1.addTab("Cache Info", jPanel7); jPanel5.setBorder(BorderFactory.createEtchedBorder()); txtTotalLogSize.setEditable(false); binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${logFile.totalFolderSize}"), txtTotalLogSize, org.jdesktop.beansbinding.BeanProperty.create("text")); bindingGroup.addBinding(binding); jLabel11.setText("Total File on Log Folder"); txtTotalLog.setEditable(false); binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${logFile.fileListSize}"), txtTotalLog, org.jdesktop.beansbinding.BeanProperty.create("text")); bindingGroup.addBinding(binding); btnCleanLog.setIcon(new ImageIcon(getClass().getResource("/icons/cross2.png"))); // NOI18N btnCleanLog.setText("Clean Log File"); btnCleanLog.setHorizontalTextPosition(SwingConstants.CENTER); btnCleanLog.setVerticalTextPosition(SwingConstants.BOTTOM); btnCleanLog.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnCleanLogActionPerformed(evt); } }); jLabel13.setText("Total Size on Log Folder "); GroupLayout jPanel5Layout = new GroupLayout(jPanel5); jPanel5.setLayout(jPanel5Layout); jPanel5Layout.setHorizontalGroup(jPanel5Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel5Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel5Layout.createParallelGroup(GroupLayout.Alignment.TRAILING, false) .addComponent(btnCleanLog, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel5Layout.createSequentialGroup() .addGroup(jPanel5Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(jLabel13).addComponent(jLabel11)) .addGap(18, 18, 18) .addGroup(jPanel5Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(txtTotalLog, GroupLayout.PREFERRED_SIZE, 66, GroupLayout.PREFERRED_SIZE) .addComponent(txtTotalLogSize, GroupLayout.PREFERRED_SIZE, 123, GroupLayout.PREFERRED_SIZE)))) .addContainerGap(22, Short.MAX_VALUE))); jPanel5Layout.setVerticalGroup(jPanel5Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel5Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel5Layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(txtTotalLog, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(jLabel11)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel5Layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(jLabel13).addComponent(txtTotalLogSize, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(btnCleanLog, GroupLayout.PREFERRED_SIZE, 50, GroupLayout.PREFERRED_SIZE) .addContainerGap())); jPanel6.setBorder(BorderFactory.createEtchedBorder()); jLabel12.setText("Log File Data :"); txtLogContent.setEditable(false); txtLogContent.setColumns(20); txtLogContent.setLineWrap(true); txtLogContent.setRows(5); txtLogContent.setWrapStyleWord(true); binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${logFileData}"), txtLogContent, org.jdesktop.beansbinding.BeanProperty.create("text")); bindingGroup.addBinding(binding); jScrollPane1.setViewportView(txtLogContent); GroupLayout jPanel6Layout = new GroupLayout(jPanel6); jPanel6.setLayout(jPanel6Layout); jPanel6Layout.setHorizontalGroup(jPanel6Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel6Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel6Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 724, Short.MAX_VALUE) .addGroup(jPanel6Layout.createSequentialGroup().addComponent(jLabel12).addGap(0, 0, Short.MAX_VALUE))) .addContainerGap())); jPanel6Layout .setVerticalGroup(jPanel6Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel6Layout.createSequentialGroup().addContainerGap().addComponent(jLabel12) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(jScrollPane1, GroupLayout.PREFERRED_SIZE, 339, GroupLayout.PREFERRED_SIZE) .addContainerGap())); jPanel8.setBackground(Color.white); jPanel8.setBorder(BorderFactory.createEtchedBorder()); jLabel17.setFont(new Font("Liberation Sans", 0, 12)); // NOI18N jLabel17.setText("application use it as a log tracker."); jLabel16.setFont(new Font("Liberation Sans", 0, 12)); // NOI18N jLabel16.setText("These 2 log files cannot be delete, because the"); jLabel15.setFont(new Font("Liberation Sans", 0, 12)); // NOI18N jLabel15.setText("Minimal log files is 2 files."); jLabel14.setFont(new Font("Liberation Sans", 1, 12)); // NOI18N jLabel14.setText("Info :"); GroupLayout jPanel8Layout = new GroupLayout(jPanel8); jPanel8.setLayout(jPanel8Layout); jPanel8Layout.setHorizontalGroup(jPanel8Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel8Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel8Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(jLabel14).addComponent(jLabel15).addComponent(jLabel16) .addComponent(jLabel17)) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); jPanel8Layout.setVerticalGroup(jPanel8Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel8Layout.createSequentialGroup().addContainerGap().addComponent(jLabel14) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel15) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel16) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel17) .addContainerGap())); GroupLayout jPanel3Layout = new GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup(jPanel3Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup( GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel3Layout.createParallelGroup(GroupLayout.Alignment.LEADING, false) .addComponent(jPanel5, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel8, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jPanel6, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap())); jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup().addGap(20, 20, 20) .addGroup(jPanel3Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(jPanel6, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGroup(jPanel3Layout.createSequentialGroup() .addComponent(jPanel5, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel8, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))) .addContainerGap(41, Short.MAX_VALUE))); jTabbedPane1.addTab("Log Monitor", jPanel3); jPanel15.setBorder(BorderFactory.createEtchedBorder()); txtAppLookAndFeel.setEditable(false); binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${defaultLookAndFeel}"), txtAppLookAndFeel, org.jdesktop.beansbinding.BeanProperty.create("text")); bindingGroup.addBinding(binding); jLabel10.setText("Look And Feel "); btnSaveLF.setIcon(new ImageIcon(getClass().getResource("/icons/edit.png"))); // NOI18N btnSaveLF.setText("Save"); btnSaveLF.setHorizontalTextPosition(SwingConstants.CENTER); btnSaveLF.setVerticalTextPosition(SwingConstants.BOTTOM); btnSaveLF.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnSaveLFActionPerformed(evt); } }); btnSelectLF.setText("Change Look and Feel"); btnSelectLF.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnSelectLFActionPerformed(evt); } }); GroupLayout jPanel15Layout = new GroupLayout(jPanel15); jPanel15.setLayout(jPanel15Layout); jPanel15Layout.setHorizontalGroup(jPanel15Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel15Layout.createSequentialGroup().addContainerGap().addComponent(jLabel10) .addGap(4, 4, 4) .addGroup(jPanel15Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(btnSaveLF, GroupLayout.PREFERRED_SIZE, 90, GroupLayout.PREFERRED_SIZE) .addComponent(txtAppLookAndFeel, GroupLayout.PREFERRED_SIZE, 395, GroupLayout.PREFERRED_SIZE) .addComponent(btnSelectLF, GroupLayout.PREFERRED_SIZE, 176, GroupLayout.PREFERRED_SIZE)) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); jPanel15Layout.setVerticalGroup(jPanel15Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel15Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel15Layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(jLabel10).addComponent(txtAppLookAndFeel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(btnSelectLF) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(btnSaveLF) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); jPanel16.setBackground(Color.white); jPanel16.setBorder(BorderFactory.createEtchedBorder()); jLabel41.setFont(new Font("Liberation Sans", 0, 12)); // NOI18N jLabel41.setText("to be restarted."); jLabel36.setFont(new Font("Liberation Sans", 1, 12)); // NOI18N jLabel36.setText("Info :"); jLabel40.setFont(new Font("Liberation Sans", 0, 12)); // NOI18N jLabel40.setText("System. Changing Look and Feel requires application"); jLabel37.setFont(new Font("Liberation Sans", 0, 12)); // NOI18N jLabel37.setText("Changing the Look and Feel means changing this"); jLabel38.setFont(new Font("Liberation Sans", 0, 12)); // NOI18N jLabel38.setText("application theme, the theme provided by it's installed"); jLabel39.setFont(new Font("Liberation Sans", 0, 12)); // NOI18N jLabel39.setText("Look and Feel class in the Java Runtime Environment"); GroupLayout jPanel16Layout = new GroupLayout(jPanel16); jPanel16.setLayout(jPanel16Layout); jPanel16Layout.setHorizontalGroup(jPanel16Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel16Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel16Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(jLabel36).addComponent(jLabel37).addComponent(jLabel38) .addComponent(jLabel39).addComponent(jLabel40).addComponent(jLabel41)) .addContainerGap())); jPanel16Layout.setVerticalGroup(jPanel16Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel16Layout.createSequentialGroup().addContainerGap().addComponent(jLabel36) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel37) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel38) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel39) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel40) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel41) .addContainerGap())); GroupLayout jPanel4Layout = new GroupLayout(jPanel4); jPanel4.setLayout(jPanel4Layout); jPanel4Layout .setHorizontalGroup( jPanel4Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createSequentialGroup().addContainerGap() .addComponent(jPanel15, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel16, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addContainerGap(261, Short.MAX_VALUE))); jPanel4Layout.setVerticalGroup(jPanel4Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel4Layout.createParallelGroup(GroupLayout.Alignment.LEADING, false) .addComponent(jPanel16, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel15, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap(289, Short.MAX_VALUE))); jTabbedPane1.addTab("Look And Feel", jPanel4); jLabel5.setFont(new Font("DejaVu Sans", 1, 18)); // NOI18N jLabel5.setHorizontalAlignment(SwingConstants.CENTER); jLabel5.setText("System Configuration"); GroupLayout layout = new GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(jTabbedPane1).addComponent(jLabel5, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addComponent(jLabel5) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(jTabbedPane1))); bindingGroup.bind(); }
From source file:sample.fa.ScriptRunnerApplication.java
private void saveScript(ActionEvent ae) { JFileChooser jfc = new JFileChooser(); jfc.showOpenDialog(scriptContents);// w w w .j ava 2 s . c o m File f = jfc.getSelectedFile(); if (f != null) { try { Files.write(f.toPath(), scriptContents.getText().getBytes()); } catch (IOException ex) { JOptionPane.showMessageDialog(scriptContents, ex.getMessage(), "Error Saving Script", JOptionPane.ERROR_MESSAGE); } } }
From source file:MainWindow.java
public MainWindow() { // Login Routine loginDialog = new LoginDialog(); // loginDialog.nameField.setText("cornelius.preidel@googlemail.com"); // loginDialog.passwordField.setText("germany"); loginDialog.setSize(400, 150);//from w w w . j av a 2 s .c o m loginDialog.setModal(true); loginDialog.setLocationRelativeTo(null); loginDialog.setVisible(true); // Get the connected ApiCore core = loginDialog._core; // Init the UI mainFrame = new JFrame("MainApplication"); mainFrame.setSize(500, 500); mainFrame.setLocationRelativeTo(null); mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); mainFrame.setLayout(new GridLayout(5, 1)); // WebProjectsList webprojectlist = new WebProjectsList(core); // mainFrame.add(webprojectlist); // Create the APIS Teams teamsAPI = new Teams(core); final Projects projectsAPI = new Projects(core); final Divisions divisionsAPI = new Divisions(core); final Attachments attachmentAPI = new Attachments(core); final Issues issueAPI = new Issues(core); // TEAMS List TeamsList teamList = new TeamsList(); teamList.setTeams(teamsAPI.GetTeams()); mainFrame.add(teamList); // PROJECTS List projectsList = new ProjectsList(); mainFrame.add(projectsList); // DIVISIONS List divisionsList = new DivisionsList(); // mainFrame.add(divisionsList); // DIVISIONS Table divisionsTable = new DivisionsTable(core); mainFrame.add(divisionsTable); // Attachments attachmentsList = new AttachmentsList(); mainFrame.add(attachmentsList); // Attachments issuesList = new IssuesList(); mainFrame.add(issuesList); PropertyChangeListener propertyChangeListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent propertyChangeEvent) { String property = propertyChangeEvent.getPropertyName(); if ("selectedTeam".equals(property)) { DtoTeam selectedTeam = (DtoTeam) propertyChangeEvent.getNewValue(); // Set the global slug core.currentTeam = selectedTeam; projectsList.setProjects(projectsAPI.GetProjects()); } else if ("selectedProject".equals(property)) { DtoProject selectedProject = (DtoProject) propertyChangeEvent.getNewValue(); // Divisions divisionsList.setDivisions(divisionsAPI.GetDivisions(selectedProject.GetId())); divisionsTable.setDivisions(divisionsAPI.GetDivisions(selectedProject.GetId())); // Attachments attachmentsList.setAttachments(attachmentAPI.GetAttachments(selectedProject.GetId())); // Issues issuesList.setIssues(issueAPI.GetIssues(selectedProject.GetId())); } else if ("selectedDivision".equals(property)) { DtoDivision selectedDivision = (DtoDivision) propertyChangeEvent.getNewValue(); // What to do with the division? } else if ("selectedIssue".equals(property)) { DtoIssue selectedDivision = (DtoIssue) propertyChangeEvent.getNewValue(); // What to do with the division? } else { if ("selectedAttachment".equals(property)) { DtoAttachment selectedAttachment = (DtoAttachment) propertyChangeEvent.getNewValue(); InputStream stream = attachmentAPI.DownloadAttachment(selectedAttachment.GetId()); try { byte[] bytes = IOUtils.toByteArray(stream); JFileChooser chooser = new JFileChooser(); int returnVal = chooser.showSaveDialog(chooser); File file = chooser.getSelectedFile(); FileOutputStream fos = new FileOutputStream(file); fos.write(bytes); fos.flush(); fos.close(); } catch (IOException e) { LOG.error(e.getMessage(), e); } } } } }; // Add Listener teamList.addPropertyChangeListener(propertyChangeListener); projectsList.addPropertyChangeListener(propertyChangeListener); divisionsList.addPropertyChangeListener(propertyChangeListener); divisionsTable.addPropertyChangeListener(propertyChangeListener); attachmentsList.addPropertyChangeListener(propertyChangeListener); issuesList.addPropertyChangeListener(propertyChangeListener); }
From source file:SaveImage.java
public void actionPerformed(ActionEvent e) { JComboBox cb = (JComboBox) e.getSource(); if (cb.getActionCommand().equals("SetFilter")) { setOpIndex(cb.getSelectedIndex()); repaint();// ww w . ja v a 2s.c o m } else if (cb.getActionCommand().equals("Formats")) { /* * Save the filtered image in the selected format. The selected item will * be the name of the format to use */ String format = (String) cb.getSelectedItem(); /* * Use the format name to initialise the file suffix. Format names * typically correspond to suffixes */ File saveFile = new File("savedimage." + format); JFileChooser chooser = new JFileChooser(); chooser.setSelectedFile(saveFile); int rval = chooser.showSaveDialog(cb); if (rval == JFileChooser.APPROVE_OPTION) { saveFile = chooser.getSelectedFile(); /* * Write the filtered image in the selected format, to the file chosen * by the user. */ try { ImageIO.write(biFiltered, format, saveFile); } catch (IOException ex) { } } } }
From source file:net.atomique.ksar.ui.GraphView.java
private String askSaveFilename(String title, File chdirto) { String filename = null;/*from w w w. j a v a 2 s . c om*/ JFileChooser chooser = new JFileChooser(); chooser.setDialogTitle(title); if (chdirto != null) { chooser.setCurrentDirectory(chdirto); } int returnVal = chooser.showSaveDialog(GlobalOptions.getUI()); if (returnVal == JFileChooser.APPROVE_OPTION) { filename = chooser.getSelectedFile().getAbsolutePath(); } if (filename == null) { return null; } if (new File(filename).exists()) { String[] choix = { "Yes", "No" }; int resultat = JOptionPane.showOptionDialog(null, "Overwrite " + filename + " ?", "File Exist", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, choix, choix[1]); if (resultat != 0) { return null; } } return filename; }
From source file:modnlp.capte.AlignmentInterfaceWS.java
public AlignmentInterfaceWS() { //Setup file chooser super(new BorderLayout()); Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); this.setSize(dim.width, dim.height); //Create the log first, because the action listeners //need to refer to it. log = new JTextArea(5, 20); log.setMargin(new Insets(5, 5, 5, 5)); log.setEditable(false);// w ww. j av a 2 s . c o m JScrollPane logScrollPane = new JScrollPane(log); //Create a file chooser fc = new JFileChooser(); //Uncomment one of the following lines to try a different //file selection mode. The first allows just directories //to be selected (and, at least in the Java look and feel, //shown). The second allows both files and directories //to be selected. If you leave these lines commented out, //then the default mode (FILES_ONLY) will be used. // //fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); //fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); //Create the open button. We use the image from the JLF //Graphics Repository (but we extracted it from the jar). alignButton = new JButton("Align Texts"); alignButton.addActionListener(this); openButton = new JButton("Open Source File..."); openButton.addActionListener(this); //Create the save button. We use the image from the JLF //Graphics Repository (but we extracted it from the jar). saveButton = new JButton("Open Target File..."); saveButton.addActionListener(this); //Create two JText fields for input source and target language codes sl = new JTextField("en"); sourcel = sl.getText(); sol = new JLabel("Source"); tl = new JTextField("es"); targetl = tl.getText(); tol = new JLabel("Target"); splitButton = new JCheckBox("Splitter"); splitButton.setMnemonic(KeyEvent.VK_C); splitButton.setSelected(true); splitButton.addItemListener(this); convLine = new JCheckBox("Convert EOL"); convLine.setMnemonic(KeyEvent.VK_S); convLine.setSelected(true); convLine.addItemListener(this); sl.addActionListener(this); tl.addActionListener(this); //For layout purposes, put the buttons in a separate panel JPanel buttonPanel = new JPanel(); //use FlowLayout buttonPanel.add(openButton); buttonPanel.add(saveButton); //Make another panel for the aligner button JPanel alignPanel = new JPanel(); alignPanel.add(convLine); alignPanel.add(splitButton); alignPanel.add(sol); alignPanel.add(sl); alignPanel.add(tol); alignPanel.add(tl); alignPanel.add(alignButton); //Add the buttons and the log to this panel. add(buttonPanel, BorderLayout.PAGE_START); add(logScrollPane, BorderLayout.CENTER); add(alignPanel, BorderLayout.PAGE_END); }
From source file:net.lldp.checksims.ui.results.ScrollViewer.java
/** * Create a scroll viewer from a sortable Matrix Viewer * @param results the sortableMatrix to view * @param toRevalidate frame to revalidate sometimes *//*from www .j a v a 2 s . c om*/ public ScrollViewer(SimilarityMatrix exportMatrix, SortableMatrixViewer results, JFrame toRevalidate) { resultsView = new JScrollPane(results); setBackground(Color.black); resultsView.addComponentListener(new ComponentListener() { @Override public void componentHidden(ComponentEvent arg0) { } @Override public void componentMoved(ComponentEvent arg0) { } @Override public void componentResized(ComponentEvent ce) { Dimension size = ce.getComponent().getSize(); results.padToSize(size); } @Override public void componentShown(ComponentEvent arg0) { } }); resultsView.getViewport().addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { Rectangle r = resultsView.getViewport().getViewRect(); results.setViewAt(r); } }); resultsView.setBackground(Color.black); sidebar = new JPanel(); setPreferredSize(new Dimension(900, 631)); setMinimumSize(new Dimension(900, 631)); sidebar.setPreferredSize(new Dimension(200, 631)); sidebar.setMaximumSize(new Dimension(200, 3000)); resultsView.setMinimumSize(new Dimension(700, 631)); resultsView.setPreferredSize(new Dimension(700, 631)); sidebar.setBackground(Color.GRAY); setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); this.add(sidebar); this.add(resultsView); resultsView.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); resultsView.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); resultsView.getVerticalScrollBar().setUnitIncrement(16); resultsView.getHorizontalScrollBar().setUnitIncrement(16); Integer[] presetThresholds = { 80, 60, 40, 20, 0 }; JComboBox<Integer> threshHold = new JComboBox<Integer>(presetThresholds); threshHold.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent event) { if (event.getStateChange() == ItemEvent.SELECTED) { Integer item = (Integer) event.getItem(); results.updateThreshold(item / 100.0); toRevalidate.revalidate(); toRevalidate.repaint(); } } }); threshHold.setSelectedIndex(0); results.updateThreshold((Integer) threshHold.getSelectedItem() / 100.0); JTextField student1 = new JTextField(15); JTextField student2 = new JTextField(15); KeyListener search = new KeyListener() { @Override public void keyPressed(KeyEvent e) { } @Override public void keyReleased(KeyEvent e) { results.highlightMatching(student1.getText(), student2.getText()); toRevalidate.revalidate(); toRevalidate.repaint(); } @Override public void keyTyped(KeyEvent e) { } }; student1.addKeyListener(search); student2.addKeyListener(search); Collection<MatrixPrinter> printerNameSet = MatrixPrinterRegistry.getInstance() .getSupportedImplementations(); JComboBox<MatrixPrinter> exportAs = new JComboBox<>(new Vector<>(printerNameSet)); JButton exportAsSave = new JButton("Save"); JFileChooser fc = new JFileChooser(); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); fc.setCurrentDirectory(new java.io.File(".")); fc.setDialogTitle("Save results"); exportAsSave.addActionListener(ae -> { MatrixPrinter method = (MatrixPrinter) exportAs.getSelectedItem(); int err = fc.showDialog(toRevalidate, "Save"); if (err == JFileChooser.APPROVE_OPTION) { try { FileUtils.writeStringToFile(fc.getSelectedFile(), method.printMatrix(exportMatrix)); } catch (InternalAlgorithmError | IOException e1) { // TODO log / show error } } }); JPanel thresholdLabel = new JPanel(); JPanel studentSearchLabel = new JPanel(); JPanel fileOutputLabel = new JPanel(); thresholdLabel.setBorder(BorderFactory.createTitledBorder("Matching Threshold")); studentSearchLabel.setBorder(BorderFactory.createTitledBorder("Student Search")); fileOutputLabel.setBorder(BorderFactory.createTitledBorder("Save Results")); thresholdLabel.add(threshHold); studentSearchLabel.add(student1); studentSearchLabel.add(student2); fileOutputLabel.add(exportAs); fileOutputLabel.add(exportAsSave); studentSearchLabel.setPreferredSize(new Dimension(200, 100)); studentSearchLabel.setMinimumSize(new Dimension(200, 100)); thresholdLabel.setPreferredSize(new Dimension(200, 100)); thresholdLabel.setMinimumSize(new Dimension(200, 100)); fileOutputLabel.setPreferredSize(new Dimension(200, 100)); fileOutputLabel.setMinimumSize(new Dimension(200, 100)); sidebar.setMaximumSize(new Dimension(200, 4000)); sidebar.add(thresholdLabel); sidebar.add(studentSearchLabel); sidebar.add(fileOutputLabel); }
From source file:ImageProcessingTest.java
/** * Open a file and load the image.//from ww w.j a v a 2 s . c om */ public void openFile() { JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new File(".")); String[] extensions = ImageIO.getReaderFileSuffixes(); chooser.setFileFilter(new FileNameExtensionFilter("Image files", extensions)); int r = chooser.showOpenDialog(this); if (r != JFileChooser.APPROVE_OPTION) return; try { Image img = ImageIO.read(chooser.getSelectedFile()); image = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_RGB); image.getGraphics().drawImage(img, 0, 0, null); } catch (IOException e) { JOptionPane.showMessageDialog(this, e); } repaint(); }