Advertisement
Guest User

Untitled

a guest
Apr 20th, 2014
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.36 KB | None | 0 0
  1. public class Pokus extends javax.swing.JFrame {
  2. /**
  3. * Creates new form Pokus
  4. */
  5. public Pokus() {
  6. initComponents();
  7. }
  8.  
  9. /**
  10. * This method is called from within the constructor to initialize the form.
  11. * WARNING: Do NOT modify this code. The content of this method is always
  12. * regenerated by the Form Editor.
  13. */
  14. @SuppressWarnings("unchecked")
  15. // <editor-fold defaultstate="collapsed" desc="Generated Code">
  16. private void initComponents() {
  17.  
  18. jScrollPane1 = new javax.swing.JScrollPane();
  19. jTable1 = new javax.swing.JTable();
  20. jButton1 = new javax.swing.JButton();
  21. jButton2 = new javax.swing.JButton();
  22.  
  23. setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  24.  
  25. jTable1.setModel(new javax.swing.table.DefaultTableModel(
  26. new Object [][] {
  27. {null, null, null, null},
  28. {null, null, null, null},
  29. {null, null, null, null},
  30. {null, null, null, null}
  31. },
  32. new String [] {
  33. "Title 1", "Title 2", "Title 3", "Title 4"
  34. }
  35. ));
  36. jTable1.setFillsViewportHeight(true);
  37. jScrollPane1.setViewportView(jTable1);
  38.  
  39. jButton1.setText("AUTO_RESIZE_LAST_COLUMN");
  40. jButton1.addActionListener(new java.awt.event.ActionListener() {
  41. public void actionPerformed(java.awt.event.ActionEvent evt) {
  42. jButton1ActionPerformed(evt);
  43. }
  44. });
  45.  
  46. jButton2.setText("AUTO_RESIZE_NEXT_COLUMN");
  47. jButton2.addActionListener(new java.awt.event.ActionListener() {
  48. public void actionPerformed(java.awt.event.ActionEvent evt) {
  49. jButton2ActionPerformed(evt);
  50. }
  51. });
  52.  
  53. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  54. getContentPane().setLayout(layout);
  55. layout.setHorizontalGroup(
  56. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  57. .addGroup(layout.createSequentialGroup()
  58. .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 667, javax.swing.GroupLayout.PREFERRED_SIZE)
  59. .addGap(0, 0, Short.MAX_VALUE))
  60. .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  61. .addGap(103, 103, 103)
  62. .addComponent(jButton1)
  63. .addGap(82, 82, 82)
  64. .addComponent(jButton2)
  65. .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  66. );
  67. layout.setVerticalGroup(
  68. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  69. .addGroup(layout.createSequentialGroup()
  70. .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)
  71. .addGap(18, 18, 18)
  72. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  73. .addComponent(jButton2)
  74. .addComponent(jButton1))
  75. .addGap(0, 17, Short.MAX_VALUE))
  76. );
  77.  
  78. pack();
  79. }// </editor-fold>
  80.  
  81. private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
  82. jTable1.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
  83. jTable1.getColumnModel().getColumn(1).setWidth(200);
  84. jTable1.repaint();
  85. jTable1.revalidate();
  86. }
  87.  
  88. private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
  89. jTable1.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN);
  90. jTable1.getColumnModel().getColumn(1).setWidth(200);
  91. jTable1.repaint();
  92. jTable1.revalidate();
  93. }
  94.  
  95. /**
  96. * @param args the command line arguments
  97. */
  98. public static void main(String args[]) {
  99. /* Set the Nimbus look and feel */
  100. //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  101. /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  102. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  103. */
  104. try {
  105. for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  106. if ("Nimbus".equals(info.getName())) {
  107. javax.swing.UIManager.setLookAndFeel(info.getClassName());
  108. break;
  109. }
  110. }
  111. } catch (ClassNotFoundException ex) {
  112. java.util.logging.Logger.getLogger(Pokus.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  113. } catch (InstantiationException ex) {
  114. java.util.logging.Logger.getLogger(Pokus.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  115. } catch (IllegalAccessException ex) {
  116. java.util.logging.Logger.getLogger(Pokus.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  117. } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  118. java.util.logging.Logger.getLogger(Pokus.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  119. }
  120. //</editor-fold>
  121.  
  122. /* Create and display the form */
  123. java.awt.EventQueue.invokeLater(new Runnable() {
  124. public void run() {
  125. new Pokus().setVisible(true);
  126. }
  127. });
  128. }
  129. // Variables declaration - do not modify
  130. private javax.swing.JButton jButton1;
  131. private javax.swing.JButton jButton2;
  132. private javax.swing.JScrollPane jScrollPane1;
  133. private javax.swing.JTable jTable1;
  134. // End of variables declaration
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement