Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.16 KB | None | 0 0
  1.  
  2. public class DedisWindow {
  3.     private static JFrame frame;
  4.    
  5.     private static DefaultTableModel tableModel;
  6.    
  7.     static {
  8.         initialize();
  9.     }
  10.    
  11.     private static void initialize() {
  12.         frame = new JFrame("Control de servidores dedicados");
  13.        
  14.         frame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
  15.         frame.setVisible(false);
  16.        
  17.         JTable table = new JTable();
  18.        
  19.         table.getTableHeader().setReorderingAllowed(false);
  20.         table.setFillsViewportHeight(true);
  21.         table.setRowSelectionAllowed(false);
  22.         table.setBackground(new Color(204, 204, 153));
  23.  
  24.         tableModel = new DefaultTableModel() {
  25.             private static final long serialVersionUID = -5177074969522608672L;
  26.  
  27.             @Override
  28.             public boolean isCellEditable(int row, int column) {
  29.                 return false;
  30.             }
  31.         };
  32.        
  33.         tableModel.addColumn("Servidor");
  34.         tableModel.addColumn("Carga CPU (%)");
  35.         tableModel.addColumn("Memoria usada");
  36.         tableModel.addColumn("Memoria máxima");
  37.         tableModel.addColumn("Espacio libre");
  38.            
  39.         table.setModel(tableModel);
  40.         table.getColumnModel().getColumn(1).setCellRenderer(new DedisCellRenderer());
  41.        
  42.         JScrollPane scrollPane = new JScrollPane();
  43.        
  44.         scrollPane.setViewportView(table);
  45.        
  46.         GroupLayout groupLayout = new GroupLayout(frame.getContentPane());
  47.        
  48.         groupLayout.setHorizontalGroup(
  49.             groupLayout.createParallelGroup(Alignment.LEADING)
  50.                 .addGroup(groupLayout.createSequentialGroup()
  51.                     .addContainerGap()
  52.                     .addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
  53.                         .addComponent(scrollPane, GroupLayout.DEFAULT_SIZE, 550, Short.MAX_VALUE))
  54.                     .addContainerGap())
  55.         );
  56.        
  57.         groupLayout.setVerticalGroup(
  58.             groupLayout.createParallelGroup(Alignment.LEADING)
  59.                 .addGroup(groupLayout.createSequentialGroup()
  60.                     .addContainerGap()
  61.                     .addComponent(scrollPane, GroupLayout.DEFAULT_SIZE, 311, Short.MAX_VALUE)
  62.                     .addContainerGap())
  63.         );
  64.        
  65.         frame.getContentPane().setLayout(groupLayout);
  66.         frame.pack();
  67.     }
  68.    
  69.     public static void update() {
  70.         // TODO Actualizar
  71.     }
  72.    
  73.     public static void show() {
  74.         if (frame.isVisible()) {
  75.             return;
  76.         }
  77.        
  78.         frame.setLocationRelativeTo(null);
  79.         frame.setVisible(!frame.isVisible());
  80.     }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement