Skip to content

Instantly share code, notes, and snippets.

View HashRaygoza's full-sized avatar

David Raygoza Gómez HashRaygoza

View GitHub Profile
@HashRaygoza
HashRaygoza / listarImpresoras.java
Last active March 16, 2018 06:13
Lista las impresoras del sistema
/**
* Muestra en pantalla la lista de todas las impresoras disponibles en el
* sistema
*/
public void listarImpresoras() {
PrintService[] printServices = PrintServiceLookup.lookupPrintServices(null, null);
System.out.println("Lista de impresoras disponibles");
for (PrintService printService: printServices) {
System.out.println("\t" + printService.getName());
@HashRaygoza
HashRaygoza / findPrintService.java
Last active March 16, 2018 06:15
Encuentra el objeto PrintService que representa la impresora que deseamos usar
/**
* Nos regresa el PrintService que representa la impresora con el nombre que
* le indiquemos
* @param printerName nombre de la impresora que deseamos usar
* @return PrintService que representa la impresora que deseamos usar
*/
private PrintService findPrintService(String printerName) {
PrintService[] printServices = PrintServiceLookup.lookupPrintServices(null, null);
for (PrintService printService: printServices) {
System.out.println(printService.getName());
@HashRaygoza
HashRaygoza / hosts
Created March 23, 2018 04:14
Dominios que agregar a /etc/hotst para bloquear a facebook
############################################
# To Completely Block Facebook
# Add these entries below to your hosts file
#
# Your hosts file Location:
# Linux, Unix and Mac OS X -> /etc/hosts
# Windows XP, Vista and Windows 7 -> C:\WINDOWS\system32\drivers\etc\hosts
# Windows 2000 -> C:\WINNT\system32\drivers\etc\hosts
# Windows 98/ME -> C:\WINDOWS\hosts
#
@HashRaygoza
HashRaygoza / Tabla.java
Last active April 11, 2018 21:20
Tabla.java
package mx.hashCode.table;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
@HashRaygoza
HashRaygoza / VentanaPrincipal.java
Created April 21, 2018 00:25
Una aplicación que evita una instancia duplicada
package mx.hashCode.unica;
import java.awt.BorderLayout;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.IOException;
import java.net.BindException;
import java.net.ServerSocket;
import javax.swing.BorderFactory;
@HashRaygoza
HashRaygoza / App.java
Created April 21, 2018 00:25
Aplicacion de instancia unica
package mx.hashCode.unica;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
@HashRaygoza
HashRaygoza / FontSizeExample.java
Created May 1, 2018 06:09
Ejemplo de como especificar el tamaño de fuente en iText 7
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mx.hash.fontsize.fontsizeitext;
import com.itextpdf.kernel.geom.PageSize;
import com.itextpdf.kernel.pdf.PdfDocument;
import com.itextpdf.kernel.pdf.PdfWriter;
@HashRaygoza
HashRaygoza / setFontSize.java
Created May 1, 2018 06:43
Método que cambia el tamaño de la fuente
.setFontSize(tamaño)
@HashRaygoza
HashRaygoza / Cell.java
Created May 1, 2018 19:43
Especificar la altura de una celda en iText 7
// Creamos una celda
Cell celda1 = new Cell();
// Agregamos el contenido de la celda
celda1.add(new Paragraph("Celda 1"));
// indicamos la altura para la celda
celda1.setHeight(altura);
// agregamos esa celda a la tabla
@HashRaygoza
HashRaygoza / CellHeight.java
Created May 1, 2018 21:24
Ejemplo de como cambiar la altura de las celdas en una tabla iText 7
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mx.hash.fontsize.tablecellheight;
import com.itextpdf.kernel.geom.PageSize;
import com.itextpdf.kernel.pdf.PdfDocument;
import com.itextpdf.kernel.pdf.PdfWriter;