List of usage examples for javax.swing JPanel setSize
public void setSize(int width, int height)
From source file:Form.Principal.java
public void PanelClientes() { int i = 0;// w w w.j a v a2 s . c om int Altura = 0; Color gris = new Color(44, 44, 44); Color rojo = new Color(221, 76, 76); Color azul = new Color(0, 153, 255); try { //Consultamos todos los clientes ResultSet Comandos = Funcion.Select(st, "SELECT * FROM cliente;"); //Ciclo para crear un panel para cada uno while (Comandos.next()) { //Creamos un panel con alineacion a la izquierda JPanel Panel = new JPanel(); Panel.setLayout(null); jPanel8.add(Panel); //Tamao del panel Panel.setSize(700, 195); // La posicion y del panel ira incrementando para que no se encimen Altura = 30 + (i * 205); Panel.setLocation(50, Altura); Panel.setBackground(Color.white); Panel.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED)); //Creamos label para mostrar los datos del cliente, el codigo html es para que al llegar al final del panel //se pase a la siguiente linea y para el margen izquierdo JLabel RFC = new JLabel(); RFC.setText("RFC: " + Comandos.getString("RFC")); JLabel Nombre = new JLabel(); Nombre.setText("Nombre: " + Comandos.getString("NombreCliente")); JTextArea Direccion = new JTextArea(); Direccion.setLineWrap(true); Direccion.setBorder(null); Direccion.setText("Direccin: " + Comandos.getString("Direccion")); JLabel Correo = new JLabel(); Correo.setText("Correo: " + Comandos.getString("correo")); JButton VerMas = new JButton(); VerMas.setText("Ver ms"); VerMas.setName(Comandos.getString("idCliente")); VerMas.setBackground(azul); JButton Eliminar = new JButton(); Eliminar.setText("Eliminar"); Eliminar.setName(Comandos.getString("idCliente")); Eliminar.setBackground(rojo); MouseListener mlVerMas = new MouseListener() { @Override public void mouseReleased(MouseEvent e) { //System.out.println("Released!"); } @Override public void mousePressed(MouseEvent e) { //System.out.println("Pressed!"); } @Override public void mouseExited(MouseEvent e) { //System.out.println("Exited!"); } @Override public void mouseEntered(MouseEvent e) { //System.out.println("Entered!"); e.getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } @Override public void mouseClicked(MouseEvent e) { JButton source = (JButton) e.getSource(); id = Integer.parseInt(source.getName()); jTabbedPane2.setSelectedIndex(4); jButton16.setVisible(true); jButton17.setVisible(true); jButtonEditar.setVisible(true); jPanel9.setVisible(true); jPanel10.setVisible(true); jPanel14.setVisible(false); LlenarPanel(); } }; VerMas.addMouseListener(mlVerMas); MouseListener mlEliminar = new MouseListener() { @Override public void mouseReleased(MouseEvent e) { //System.out.println("Released!"); } @Override public void mousePressed(MouseEvent e) { //System.out.println("Pressed!"); } @Override public void mouseExited(MouseEvent e) { //System.out.println("Exited!"); } @Override public void mouseEntered(MouseEvent e) { //System.out.println("Entered!"); e.getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } @Override public void mouseClicked(MouseEvent e) { JButton source = (JButton) e.getSource(); Funcion.Update(st, "DELETE FROM cliente WHERE idCliente = " + source.getName() + ";"); Autocompletar.removeAllItems(); Autocompletar = new TextAutoCompleter(jTextField2); ResultSet Comandos = Funcion.Select(st, "SELECT * FROM cliente;"); try { while (Comandos.next()) { Autocompletar.addItem(Comandos.getString("RFC")); } } catch (SQLException ex) { //Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex); } jPanel8.removeAll(); PanelClientes(); jPanel8.repaint(); } }; Eliminar.addMouseListener(mlEliminar); //Fuente del texto RFC.setFont(new Font("Verdana", Font.PLAIN, 14)); RFC.setForeground(gris); Nombre.setFont(new Font("Verdana", Font.PLAIN, 14)); Nombre.setForeground(gris); Direccion.setFont(new Font("Verdana", Font.PLAIN, 14)); Direccion.setForeground(gris); Correo.setFont(new Font("Verdana", Font.PLAIN, 14)); Correo.setForeground(gris); VerMas.setFont(new Font("Verdana", Font.PLAIN, 14)); VerMas.setForeground(Color.white); Eliminar.setFont(new Font("Verdana", Font.PLAIN, 14)); Eliminar.setForeground(Color.white); /*VERMAS.setFont(new Font("Verdana", Font.PLAIN, 13)); VERMAS.setForeground(azul);*/ //Aadimos los label al panel correspondiente del cliente Panel.add(RFC); Panel.add(Nombre); Panel.add(Direccion); Panel.add(Correo); Panel.add(VerMas); Panel.add(Eliminar); RFC.setLocation(30, 10); RFC.setSize(610, 30); Nombre.setLocation(30, 40); Nombre.setSize(610, 30); Direccion.setLocation(30, 75); Direccion.setSize(610, 40); Correo.setLocation(30, 115); Correo.setSize(610, 30); VerMas.setLocation(210, 150); VerMas.setSize(120, 35); Eliminar.setLocation(390, 150); Eliminar.setSize(120, 35); //Panel.add(VERMAS); i++; } } catch (SQLException ex) { Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex); } //Dependiendo de cuantos clientes se agregaron, se ajusta el tamao del panel principal para que el scroll llegue hasta ahi jPanel8.setPreferredSize(new Dimension(jPanel8.getWidth(), Altura + 205)); }
From source file:Form.Principal.java
public void PanelUsuarios() { int i = 0;/* w w w . j a v a 2 s. c o m*/ int Altura = 0; Color gris = new Color(44, 44, 44); Color azul = new Color(0, 153, 255); Color rojo = new Color(221, 76, 76); try { //Consultamos todos los clientes ResultSet Comandos = Funcion.Select(st, "SELECT * FROM usuarios where Tipo!='Administrador';"); //Ciclo para crear un panel para cada uno while (Comandos.next()) { //Creamos un panel con alineacion a la izquierda JPanel Panel = new JPanel(); Panel.setLayout(null); jPanel12.add(Panel); //Tamao del panel Panel.setSize(500, 200); // La posicion y del panel ira incrementando para que no se encimen Altura = 40 + (i * 220); Panel.setLocation(175, Altura); Panel.setBackground(Color.white); Panel.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED)); //Creamos label para mostrar los datos del cliente, el codigo html es para que al llegar al final del panel //se pase a la siguiente linea y para el margen izquierdo JLabel Foto = new JLabel(); Foto.setSize(150, 150); File FotoPerfil = new File("Imagenes/Fotos Perfil/" + Comandos.getInt("id") + ".png"); File FotoPerfil2 = new File("Imagenes/Fotos Perfil/" + Comandos.getInt("id") + ".jpg"); if (FotoPerfil.exists()) { ImageIcon Imagen = new ImageIcon("Imagenes/Fotos Perfil/" + Comandos.getInt("id") + ".png"); Image ImagenEscalada = Imagen.getImage().getScaledInstance(Foto.getWidth(), Foto.getHeight(), Image.SCALE_SMOOTH); Icon IconoEscalado = new ImageIcon(ImagenEscalada); Foto.setIcon(IconoEscalado); } else if (FotoPerfil2.exists()) { ImageIcon Imagen = new ImageIcon("Imagenes/Fotos Perfil/" + Comandos.getInt("id") + ".jpg"); Image ImagenEscalada = Imagen.getImage().getScaledInstance(Foto.getWidth(), Foto.getHeight(), Image.SCALE_SMOOTH); Icon IconoEscalado = new ImageIcon(ImagenEscalada); Foto.setIcon(IconoEscalado); } else { ImageIcon Imagen = new ImageIcon(getClass().getResource("/Imagen/Default.png")); Image ImagenEscalada = Imagen.getImage().getScaledInstance(Foto.getWidth(), Foto.getHeight(), Image.SCALE_SMOOTH); Icon IconoEscalado = new ImageIcon(ImagenEscalada); Foto.setIcon(IconoEscalado); } JLabel Nombre = new JLabel(); Nombre.setText("Nombre de Usuario: " + Comandos.getString("Nombre")); JLabel Contrasena = new JLabel(); Contrasena.setText(("Contrasea: " + Comandos.getString("contrasena"))); JButton Editar = new JButton(); Editar.setText("Editar"); Editar.setName(Comandos.getString("id")); Editar.setBackground(azul); JButton Eliminar = new JButton(); Eliminar.setText("Eliminar"); Eliminar.setName(Comandos.getString("id")); Eliminar.setBackground(rojo); MouseListener mlEditar = new MouseListener() { @Override public void mouseReleased(MouseEvent e) { //System.out.println("Released!"); } @Override public void mousePressed(MouseEvent e) { //System.out.println("Pressed!"); } @Override public void mouseExited(MouseEvent e) { //System.out.println("Exited!"); } @Override public void mouseEntered(MouseEvent e) { //System.out.println("Entered!"); } @Override public void mouseClicked(MouseEvent e) { presionadoactual = 24; Color azul = new Color(0, 182, 230); jButton24.setBackground(azul); JButton source = (JButton) e.getSource(); System.out.println(source.getName()); jPanel17.setVisible(false); jButton30.setLocation(470, 480); jButton31.setLocation(270, 480); jLabel2.setToolTipText(null); jTabbedPane2.setSelectedIndex(5); editando = true; PerfilUsuario(Integer.parseInt(source.getName())); Color gris = new Color(44, 44, 44); jButton4.setBackground(gris); } }; MouseListener mlEliminar = new MouseListener() { @Override public void mouseReleased(MouseEvent e) { //System.out.println("Released!"); } @Override public void mousePressed(MouseEvent e) { //System.out.println("Pressed!"); } @Override public void mouseExited(MouseEvent e) { //System.out.println("Exited!"); } @Override public void mouseEntered(MouseEvent e) { //System.out.println("Entered!"); } @Override public void mouseClicked(MouseEvent e) { JButton source = (JButton) e.getSource(); System.out.println(source.getName()); Funcion.Update(st, "DELETE FROM usuarios WHERE id = " + source.getName() + ";"); jPanel12.removeAll(); PanelUsuarios(); jPanel12.repaint(); } }; Editar.addMouseListener(mlEditar); Eliminar.addMouseListener(mlEliminar); //Fuente del texto; Nombre.setFont(new Font("Verdana", Font.PLAIN, 15)); Nombre.setForeground(gris); Contrasena.setFont(new Font("Verdana", Font.PLAIN, 15)); Contrasena.setForeground(gris); Editar.setFont(new Font("Verdana", Font.PLAIN, 15)); Editar.setForeground(Color.white); Eliminar.setFont(new Font("Verdana", Font.PLAIN, 15)); Eliminar.setForeground(Color.white); //Aadimos los label al panel correspondiente del cliente Panel.add(Foto); Panel.add(Nombre); Panel.add(Contrasena); Panel.add(Editar); Panel.add(Eliminar); Foto.setLocation(10, 20); Nombre.setLocation(170, 30); Nombre.setSize(300, 45); Contrasena.setLocation(170, 60); Contrasena.setSize(300, 45); Editar.setLocation(170, 100); Editar.setSize(120, 40); Eliminar.setLocation(315, 100); Eliminar.setSize(120, 40); i++; } } catch (SQLException ex) { Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex); } //Dependiendo de cuantos clientes se agregaron, se ajusta el tamao del panel principal para que el scroll llegue hasta ahi jPanel12.setPreferredSize(new Dimension(jPanel12.getWidth(), Altura + 150)); }
From source file:Form.Principal.java
public void PanelFacturas() { int i = 0;/*from w w w.java2 s . com*/ int Altura = 0; Color gris = new Color(44, 44, 44); Color azul = new Color(0, 153, 255); Color rojo = new Color(221, 76, 76); try { //Consultamos todos los clientes ResultSet Comandos = Funcion.Select(st, "SELECT factura_emitida.*, cliente.* FROM cliente,factura_emitida WHERE factura_emitida.idCliente = cliente.idCliente;"); //Ciclo para crear un panel para cada uno while (Comandos.next()) { Variables.Comentario = Comandos.getString("Observaciones"); //Creamos un panel con alineacion a la izquierda JPanel Panel = new JPanel(); Panel.setLayout(null); jPanel11.add(Panel); //Tamao del panel Panel.setSize(680, 200); // La posicion y del panel ira incrementando para que no se encimen Altura = 30 + (i * 250); Panel.setLocation(50, Altura); Panel.setBackground(Color.white); Panel.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED)); //Creamos label para mostrar los datos del cliente, el codigo html es para que al llegar al final del panel //se pase a la siguiente linea y para el margen izquierdo JLabel FolioFactura = new JLabel(); FolioFactura.setText("Folio de factura: " + Comandos.getString("idFacturaEmitida")); JLabel RFC = new JLabel(); RFC.setText("RFC: " + Comandos.getString("RFC")); JLabel Nombre = new JLabel(); Nombre.setText("Nombre: " + Comandos.getString("NombreCliente")); JLabel Direccion = new JLabel(); Direccion.setText("Direccion: " + Comandos.getString("Direccion")); JLabel Correo = new JLabel(); Correo.setText("Correo: " + Comandos.getString("correo")); JLabel Fecha = new JLabel(); Fecha.setText("Fecha y Hora de emisin: " + Comandos.getString("FechaEmision")); JButton Abre = new JButton(); Abre.setText("Abrir"); Abre.setName(Comandos.getString("idFacturaEmitida")); Abre.setBackground(azul); JButton Cancelar = new JButton(); Cancelar.setText("Cancelar"); Cancelar.setName(Comandos.getString("idFacturaEmitida")); Cancelar.setBackground(rojo); MouseListener mlAbre = new MouseListener() { @Override public void mouseReleased(MouseEvent e) { //System.out.println("Released!"); } @Override public void mousePressed(MouseEvent e) { //System.out.println("Pressed!"); } @Override public void mouseExited(MouseEvent e) { //System.out.println("Exited!"); } @Override public void mouseEntered(MouseEvent e) { //System.out.println("Entered!"); } @Override public void mouseClicked(MouseEvent e) { try { JButton source = (JButton) e.getSource(); idFacClien = Integer.parseInt(source.getName()); ResultSet Comandos = Funcion.Select(st, "SELECT *FROM factura_emitida WHERE idfacturaEmitida=" + idFacClien + ";"); while (Comandos.next()) { Variables.FechaFactura = Comandos.getString("FechaEmision"); Variables.FechaSistema = Comandos.getString("fechasistema"); Variables.idFactura = Comandos.getInt("idFacturaEmitida"); } Consulta(); Variables.guardar = false; NuevoPdf pdf = new NuevoPdf("Factura.pdf"); pdf.main(); File myfile = new File("Factura.pdf"); Desktop.getDesktop().open(myfile); Comandos = Funcion.Select(st, "SELECT * FROM factura_emitida;"); try { if (Comandos.next()) { Comandos.last(); Variables.idFactura = Comandos.getInt("idFacturaEmitida") + 1; } else { Variables.idFactura = 1; } } catch (SQLException ex) { Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex); } } catch (Exception ex) { Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex); } } }; MouseListener mlCancelar = new MouseListener() { @Override public void mouseReleased(MouseEvent e) { //System.out.println("Released!"); } @Override public void mousePressed(MouseEvent e) { //System.out.println("Pressed!"); } @Override public void mouseExited(MouseEvent e) { //System.out.println("Exited!"); } @Override public void mouseEntered(MouseEvent e) { //System.out.println("Entered!"); } @Override public void mouseClicked(MouseEvent e) { JButton source = (JButton) e.getSource(); Variables.Cancelar = Integer.parseInt(source.getName()); String Comando = "UPDATE factura_emitida SET Observaciones='Factura Cancelada' WHERE idFacturaEmitida=" + Variables.Cancelar + ";"; Funcion.Update(st, Comando); jPanel11.removeAll(); PanelFacturas(); jPanel11.repaint(); } }; Abre.addMouseListener(mlAbre); Cancelar.addMouseListener(mlCancelar); //Fuente del texto; FolioFactura.setFont(new Font("Verdana", Font.PLAIN, 13)); FolioFactura.setForeground(gris); RFC.setFont(new Font("Verdana", Font.PLAIN, 13)); RFC.setForeground(gris); Nombre.setFont(new Font("Verdana", Font.PLAIN, 13)); Nombre.setForeground(gris); Direccion.setFont(new Font("Verdana", Font.PLAIN, 13)); Direccion.setForeground(gris); Correo.setFont(new Font("Verdana", Font.PLAIN, 13)); Correo.setForeground(gris); Fecha.setFont(new Font("Verdana", Font.PLAIN, 13)); Fecha.setForeground(gris); /// Botones Abre.setFont(new Font("Verdana", Font.PLAIN, 15)); Abre.setForeground(Color.white); Cancelar.setFont(new Font("Verdana", Font.PLAIN, 15)); Cancelar.setForeground(Color.white); //Aadimos los label al panel correspondiente del cliente Panel.add(FolioFactura); Panel.add(RFC); Panel.add(Nombre); Panel.add(Direccion); Panel.add(Correo); Panel.add(Fecha); Panel.add(Abre); FolioFactura.setLocation(15, 5); FolioFactura.setSize(400, 45); RFC.setLocation(15, 25); RFC.setSize(400, 45); Nombre.setLocation(15, 45); Nombre.setSize(500, 45); Direccion.setLocation(15, 65); Direccion.setSize(650, 45); Correo.setLocation(15, 85); Correo.setSize(500, 45); Fecha.setLocation(15, 105); Fecha.setSize(500, 45); /// Botones Tamao y localizacion if (Variables.Tipo.equalsIgnoreCase("Administrador")) { // Verificamos que sea un Administrador Panel.add(Cancelar); Abre.setLocation(185, 160); Abre.setSize(120, 30); Cancelar.setLocation(350, 160); Cancelar.setSize(120, 30); if (Variables.Comentario.equalsIgnoreCase("Factura Cancelada")) { Cancelar.setVisible(false); Abre.setLocation(290, 160); Abre.setSize(120, 30); } } else { Abre.setLocation(290, 160); Abre.setSize(120, 30); } i++; } } catch (SQLException ex) { Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex); } //Dependiendo de cuantos clientes se agregaron, se ajusta el tamao del panel principal para que el scroll llegue hasta ahi jPanel11.setPreferredSize(new Dimension(jPanel11.getWidth(), Altura + 300)); }
From source file:table.TablePanel.java
public TablePanel(JPanel parent, GridBagConstraints c) { this.parent = parent; this.c = c;/*ww w . j av a 2 s . c o m*/ dataHandler = null; data = new ArrayList<>(); selectedRows = new ArrayList<>(); tableModel = new MyTableModel(data); table = new JTable(tableModel); table.getColumnModel().getColumn(0).setResizable(false); table.getColumnModel().getColumn(0).setMaxWidth(60); table.getColumnModel().getColumn(1).setResizable(false); table.getColumnModel().getColumn(1).setMaxWidth(50); table.getColumnModel().getColumn(2).setMaxWidth(90); table.getColumnModel().getColumn(49).setMaxWidth(60); for (int i = 0; i < tableModel.getColumnCount(); i++) { if (i > 14 && i < 31) { table.getColumnModel().getColumn(i).setMaxWidth(70); } else if (tableModel.columnNamesTemp[i].contains("LEVEL")) { if (tableModel.columnNamesTemp[i].equals("QEC LEVEL")) { table.getColumnModel().getColumn(i).setMinWidth(90); table.getColumnModel().getColumn(i).setMaxWidth(200); } else { table.getColumnModel().getColumn(i).setMaxWidth(90); } if (tableModel.columnNamesTemp[i - 1].equals("Work Pace")) { table.getColumnModel().getColumn(i - 1).setMinWidth(90); table.getColumnModel().getColumn(i - 1).setMaxWidth(150); } else { table.getColumnModel().getColumn(i - 1).setMaxWidth(90); } } else { // table.getColumnModel().getColumn(i).setMinWidth(120); // table.getColumnModel().getColumn(i).setMaxWidth(250); } } table.getColumnModel().getColumn(table.getColumnCount() - 1).setMaxWidth(60); table.getColumnModel().getColumn(table.getColumnCount() - 1).setResizable(false); table.setRowSelectionAllowed(true); table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); table.getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { if (!dataHandler.getDeleting() && (table.getSelectedRow() != -1) && e.getColumn() != table.getColumnCount() - 1 && e.getColumn() != 1) { int row = table.getSelectedRow(); int col = e.getColumn(); if (col == 0 && (boolean) table.getValueAt(row, col) == true) { if (!selectedRows.contains((Integer) row)) selectedRows.add(row); } else if (col == 0 && (boolean) table.getValueAt(row, col) == false) { selectedRows.remove((Object) row); } else if (col != 0 && (boolean) table.getValueAt(row, table.getColumnCount() - 1)) { dataHandler.dataEdited(); } } } }); table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { private int count = 0; @Override public void valueChanged(ListSelectionEvent arg0) { if (count > 1 && !arg0.getValueIsAdjusting()) { int[] draggedRows = table.getSelectedRows(); for (int i = 0; i < draggedRows.length; i++) if (selectedRows.contains((Integer) draggedRows[i])) { selectedRows.remove((Integer) draggedRows[i]); table.setValueAt(false, draggedRows[i], 0); } else { selectedRows.add((Integer) draggedRows[i]); table.setValueAt(true, draggedRows[i], 0); } // Finalize count = 0; } else if (arg0.getValueIsAdjusting()) count++; else count = 0; } }); // { // // @Override // public Component prepareRenderer(TableCellRenderer renderer, // int row, int column) { // JLabel label = (JLabel) super.prepareRenderer(renderer, row, column); // if ((boolean) table.getValueAt(row, table.getColumnCount() - 1) == // false) { // if ((int) row % 2 == 0) { // label.setBackground(new Color(244, 226,215)); // } else { // label.setBackground(new Color(241, 220,205)); // } // } else { // if ((int) row% 2 == 0) { // label.setBackground(new Color(255, 255, 255)); // } else { // label.setBackground(new Color(252, 252, 252)); // } // // } // if(table.getSelectedRow()==row) // label.setBackground(Color.LIGHT_GRAY); // return label; // } // }; // table.prepareRenderer(null, WIDTH, WIDTH); // table.setRowSelectionAllowed(true); // table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); table.setDefaultRenderer(Object.class, new MyTableCellRenderer()); // { // // @Override // public Component getTableCellRendererComponent(JTable table, Object // value, boolean isSelected, boolean hasFocus, int row, int column) { // JLabel label = (JLabel) table.prepareRenderer(null, row, column); // if ((boolean) table.getValueAt(row, table.getColumnCount() - 1) == // false) { // if ((int) row % 2 == 0) { // label.setBackground(new Color(244, 226,215)); // } else { // label.setBackground(new Color(241, 220,205)); // } // } else { // if ((int) row% 2 == 0) { // label.setBackground(new Color(255, 255, 255)); // } else { // label.setBackground(new Color(252, 252, 252)); // } // // } // if(table.getSelectedRow()==row) // label.setBackground(Color.LIGHT_GRAY); // return label; // } // }); // { // // @Override // public Component getTableCellRendererComponent(JTable table, Object // value, boolean isSelected, boolean hasFocus, int row, int column) { // Component cell= table.getCellRenderer(row, // column).getTableCellRendererComponent(table, value, isSelected, // hasFocus, row, column); // // // for(int i=1;i<table.getRowCount();i++) { // if((boolean)table.getValueAt(i, table.getColumnCount()-1) ==false) // { // setForeground(Color.black); // setBackground(Color.red); // } // else // { // setBackground(Color.white); // setForeground(Color.black); // } // } // return cell; // } // }); // DefaultTableCellRenderer rightRenderer = new // DefaultTableCellRenderer(); // rightRenderer.setHorizontalAlignment(DefaultTableCellRenderer.RIGHT); for (int i = 0; i < tableModel.getColumnCount(); i++) { table.getTableHeader().getColumnModel().getColumn(i) .setHeaderRenderer(new HeaderRenderer(table, alignments[1])); // table.getColumnModel().getColumn(i).setCellRenderer(new // MyTableCellRenderer()); } table.getTableHeader().setReorderingAllowed(false); table.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); table.setRowHeight(25); // table.setPreferredScrollableViewportSize(new Dimension(10000, 200)); // Create the scroll pane and add the table to it. JScrollPane scrollPane = new JScrollPane(table); // JViewport tableView = new JViewport(); // tableView.add(table); // scrollPane.setViewport(tableView); parent.setSize(table.getWidth(), table.getHeight()); // parent.setPreferredSize(new Dimension(70000,10000)); // scrollPane.setVerticalScrollBar(new JScrollBar(JScrollBar.VERTICAL)); // scrollPane.setHorizontalScrollBar(new JScrollBar(JScrollBar.HORIZONTAL)); // Add the scroll pane to this panel. // parent.add(table.getTableHeader()); // parent.add(table, c); // Add header in NORTH slot parent.add(table.getTableHeader(), BorderLayout.NORTH); // Add table itself to CENTER slot parent.add(table, BorderLayout.CENTER); }
From source file:openlr.mapviewer.gui.MapViewerGui.java
/** * Creates a new map viewer gui and initializes all components. * * @param mapHolder/*from w w w. j a v a 2 s . c o m*/ * the map holder * @throws MapViewerException * If an error occurs when setting up the parameters for the UI * elements */ public MapViewerGui(final MapsHolder mapHolder) throws MapViewerException { // 1. add Menubar FileChooserFactory fcf = new DirectoryRememberingFileChooserFactory(); CodingPropertiesHolder codingPropertiesHolder = createCodingPropertiesHolder(); setJMenuBar(new MapViewerMenuBar(this, codingPropertiesHolder, fcf)); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setTitle("OpenLR - Map Viewer"); setSize(WIDTH, HEIGHT); StatusBar statusBar = new StatusBar(); LocationPanel locPanel = new LocationPanel(mapHolder, codingPropertiesHolder); locPanel.setFileChooserFactory(fcf); // trigger the shutdown manager when the application window is closed addWindowListener(new WindowAdapter() { @Override public void windowClosing(final WindowEvent e) { ShutDownManager.getInstance().statShutDown(); } }); // 2. add Toolbar ToolBar toolBar = new ToolBar(mapHolder, locPanel, fcf, statusBar); prepareMouseListener(mapHolder, statusBar); JPanel panel = new JPanel(new MigLayout("insets 0", "[][grow]", "[][grow][grow][]")); panel.add(toolBar, "north, span"); // +++++ 1. ADD locationPanel TO PANEL ++++++ panel.add(locPanel, "grow"); // add map panels JPanel mapsPanel = new MapPanelsHolder(mapHolder); mapsPanel.setSize(WIDTH, HEIGHT); panel.add(mapsPanel, "grow, wrap, span 1 3"); LocationReferencePanel esp = new LocationReferencePanel(mapHolder, statusBar, codingPropertiesHolder); esp.setFileChooserFactory(fcf); // +++++ 3. ADD LocationReferencePanel TO PANEL ++++++ panel.add(esp, "growx"); panel.add(statusBar, "south, span"); getContentPane().add(panel); if (ICON_URL != null) { ImageIcon im = new ImageIcon(ICON_URL); setIconImage(im.getImage()); } setLocationRelativeTo(null); }
From source file:org.openstatic.irc.client.O5Client.java
public O5Client() { super("O5 IRC"); this.chat_panels = new Hashtable<String, O5ChatPanel>(); this.server_panels = new Hashtable<String, O5ServerPanel>(); this.token_id = null; this.addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(WindowEvent winEvt) { System.exit(0);//from w w w. ja v a 2 s. com } }); this.tabbed = new JTabbedPane(); JPanel main_pane = new JPanel(); main_pane.setLayout(new BorderLayout()); // Setup tab JPanel pane = new JPanel(new GridLayout(0, 2, 6, 6)); pane.setSize(50, 100); JLabel server_label = new JLabel("Server:", JLabel.TRAILING); server_field = new JTextField(15); server_field.setText("127.0.0.1:4050"); JLabel username_label = new JLabel("Username:", JLabel.TRAILING); username_field = new JTextField(15); JLabel password_label = new JLabel("Password:", JLabel.TRAILING); password_field = new JTextField(15); login_btn = new JButton("Connect"); login_btn.setActionCommand("login"); login_btn.addActionListener(this); pane.add(server_label); pane.add(server_field); pane.add(username_label); pane.add(username_field); pane.add(password_label); pane.add(password_field); pane.add(new JLabel("")); pane.add(login_btn); JPanel page_start = new JPanel(new BorderLayout()); JLabel page_header = new JLabel("O5 Client"); page_header.setFont(new Font("Monospaced", Font.BOLD, 36)); page_start.add(page_header, BorderLayout.PAGE_START); page_start.add(pane, BorderLayout.PAGE_END); main_pane.add(page_start, BorderLayout.PAGE_START); tabbed.addTab("Connect", null, main_pane, ""); // finish window this.add(tabbed); centerWindow(); this.setVisible(true); }
From source file:shuffle.fwk.service.roster.EditRosterService.java
private Component makeUpperPanel() { JPanel ret = new JPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0;//from w w w.j a va 2s . c o m c.weighty = 0.0; c.gridx = 1; c.gridy = 1; c.gridwidth = 1; c.gridheight = 1; c.gridx += 1; c.weightx = 0.0; JPanel typePanel = new JPanel(); typePanel.add(new JLabel(getString(KEY_TYPE))); typeChooser = new TypeChooser(true); typePanel.add(typeChooser); typePanel.setToolTipText(getString(KEY_TYPE_TOOLTIP)); typeChooser.setToolTipText(getString(KEY_TYPE_TOOLTIP)); ret.add(typePanel, c); c.gridx += 1; c.weightx = 0.0; JPanel levelPanel = new JPanel(); levelPanel.add(new JLabel(getString(KEY_LEVEL))); SpinnerNumberModel snm = new SpinnerNumberModel(0, 0, Species.MAX_LEVEL, 1); levelSpinner = new JSpinner(snm); levelPanel.add(levelSpinner); levelPanel.setToolTipText(getString(KEY_LEVEL_TOOLTIP)); levelSpinner.setToolTipText(getString(KEY_LEVEL_TOOLTIP)); JButton applyAllButton = new JButton(getString(KEY_SET_FOR_ALL)); applyAllButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { applyLevelToAll(); } }); applyAllButton.setToolTipText(getString(KEY_SET_FOR_ALL_TOOLTIP)); levelPanel.add(applyAllButton); ret.add(levelPanel, c); c.gridx += 1; c.weightx = 1.0; JPanel stringPanel = new JPanel(new GridBagLayout()); GridBagConstraints sc = new GridBagConstraints(); sc.fill = GridBagConstraints.HORIZONTAL; sc.gridx = 1; stringPanel.add(new JLabel(getString(KEY_NAME)), sc); textField = new JTextField(); sc.gridx += 1; sc.weightx = 1.0; sc.insets = new Insets(0, 5, 0, 5); stringPanel.add(textField, sc); stringPanel.setToolTipText(getString(KEY_NAME_TOOLTIP)); textField.setToolTipText(getString(KEY_NAME_TOOLTIP)); ret.add(stringPanel, c); c.gridx += 1; c.weightx = 0.0; megaFilter = new JCheckBox(getString(KEY_MEGA_FILTER)); megaFilter.setToolTipText(getString(KEY_MEGA_FILTER_TOOLTIP)); ret.add(megaFilter, c); c.gridx += 1; c.weightx = 0.0; effectFilter = new EffectChooser(false, EffectChooser.DefaultEntry.NO_FILTER); effectFilter.setToolTipText(getString(KEY_EFFECT_FILTER_TOOLTIP)); ret.add(effectFilter, c); getMinUpperPanel = new Supplier<Dimension>() { @Override public Dimension get() { Dimension ret = new Dimension(10 + 50, 0); for (Component c : new Component[] { typePanel, levelPanel, stringPanel, megaFilter, effectFilter }) { Dimension temp = c.getPreferredSize(); int width = temp.width + ret.width; int height = Math.max(temp.height, ret.height); ret.setSize(width, height); } return ret; } }; return ret; }
From source file:shuffle.fwk.service.teams.EditTeamService.java
private Component makeUpperPanel() { JPanel ret = new JPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0;/* w w w . j a va2 s . co m*/ c.weighty = 0.0; c.gridx = 1; c.gridy = 1; c.gridwidth = 1; c.gridheight = 1; c.gridx += 1; c.weightx = 0.0; JPanel typePanel = new JPanel(); typePanel.add(new JLabel(getString(KEY_TYPE))); typeChooser = new TypeChooser(true); typePanel.add(typeChooser); typePanel.setToolTipText(getString(KEY_TYPE_TOOLTIP)); typeChooser.setToolTipText(getString(KEY_TYPE_TOOLTIP)); ret.add(typePanel, c); c.gridx += 1; c.weightx = 0.0; JPanel levelPanel = new JPanel(); levelPanel.add(new JLabel(getString(KEY_LEVEL))); SpinnerNumberModel snm = new SpinnerNumberModel(0, 0, Species.MAX_LEVEL, 1); levelSpinner = new JSpinner(snm); levelPanel.add(levelSpinner); levelPanel.setToolTipText(getString(KEY_LEVEL_TOOLTIP)); levelSpinner.setToolTipText(getString(KEY_LEVEL_TOOLTIP)); ret.add(levelPanel, c); c.gridx += 1; c.weightx = 1.0; JPanel stringPanel = new JPanel(new GridBagLayout()); GridBagConstraints sc = new GridBagConstraints(); sc.fill = GridBagConstraints.HORIZONTAL; sc.gridx = 1; stringPanel.add(new JLabel(getString(KEY_NAME)), sc); textField = new JTextField(); sc.gridx += 1; sc.weightx = 1.0; sc.insets = new Insets(0, 5, 0, 5); stringPanel.add(textField, sc); stringPanel.setToolTipText(getString(KEY_NAME_TOOLTIP)); textField.setToolTipText(getString(KEY_NAME_TOOLTIP)); ret.add(stringPanel, c); c.gridx += 1; c.weightx = 0.0; megaFilter = new JCheckBox(getString(KEY_MEGA_FILTER)); megaFilter.setToolTipText(getString(KEY_MEGA_FILTER_TOOLTIP)); ; ret.add(megaFilter, c); c.gridx += 1; c.weightx = 0.0; effectFilter = new EffectChooser(false, EffectChooser.DefaultEntry.NO_FILTER); effectFilter.setToolTipText(getString(KEY_EFFECT_FILTER_TOOLTIP)); ret.add(effectFilter, c); c.gridx += 1; c.weightx = 0.0; @SuppressWarnings("serial") JButton copyToLauncher = new JButton(new AbstractAction(getString(KEY_MAKE_DEFAULT)) { @Override public void actionPerformed(ActionEvent e) { makeTeamDefault(); } }); copyToLauncher.setToolTipText(getString(KEY_MAKE_DEFAULT_TOOLTIP)); ret.add(copyToLauncher, c); getMinUpperPanel = new Supplier<Dimension>() { @Override public Dimension get() { Dimension ret = new Dimension(10 + 50, 0); for (Component c : new Component[] { typePanel, levelPanel, stringPanel, megaFilter, effectFilter, copyToLauncher }) { Dimension temp = c.getPreferredSize(); int width = temp.width + ret.width; int height = Math.max(temp.height, ret.height); ret.setSize(width, height); } return ret; } }; return ret; }
From source file:view.ImagePanel.java
public void refreshSignatureValidationListPanels() { for (JPanel jp : panelList) { remove(jp);/*ww w .j av a2s . c om*/ } if (buf == null) { return; } if (pdfDocument != null) { if (svList != null) { Point p = getImageLocation(); for (final SignatureValidation sv : svList) { try { int pgNumber = sv.getPosList().get(0).page - 1; if (this.pageNumber == pgNumber) { for (AcroFields.FieldPosition pos : sv.getPosList()) { int p1 = (int) (p.x + (pos.position.getLeft() * scale)); int p2 = (int) (p.y + Math.floor((pdfDocument.getPage(pageNumber).getCropBox().getHeight() - pos.position.getTop()) * scale)); int p3 = (int) (pos.position.getWidth() * scale); int p4 = (int) (pos.position.getHeight() * scale); final JPanel jp1 = sv.getPanel(); jp1.setLocation(p1, p2); jp1.setSize(p3, p4); if (sv.equals(selectedSignature)) { jp1.setBackground(new Color(0, 0, 0, 45)); jp1.setBorder(new LineBorder(Color.BLACK, 1)); } else { jp1.setBackground(new Color(0, 0, 0, 0)); jp1.setBorder(null); } jp1.setVisible(true); jp1.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(java.awt.event.MouseEvent evt) { if (mainWindow.getWorkspacePanel() .getStatus() != WorkspacePanel.Status.SIGNING) { jp1.setCursor(new Cursor(Cursor.HAND_CURSOR)); jp1.setBackground(new Color(0, 0, 0, 45)); jp1.setBorder(new LineBorder(Color.BLACK, 1)); repaint(); } else { jp1.setCursor(null); } } @Override public void mouseExited(java.awt.event.MouseEvent evt) { if (mainWindow.getWorkspacePanel() .getStatus() != WorkspacePanel.Status.SIGNING) { if (selectedSignature == null) { jp1.setBackground(new Color(0, 0, 0, 0)); jp1.setBorder(null); repaint(); } else if (!selectedSignature.equals(sv)) { jp1.setBackground(new Color(0, 0, 0, 0)); jp1.setBorder(null); repaint(); } } } }); panelList.add(jp1); add(jp1); repaint(); } } } catch (Exception e) { } } } } }