Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Pokus extends javax.swing.JFrame {
- /**
- * Creates new form Pokus
- */
- public Pokus() {
- initComponents();
- }
- /**
- * 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.
- */
- @SuppressWarnings("unchecked")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">
- private void initComponents() {
- jScrollPane1 = new javax.swing.JScrollPane();
- jTable1 = new javax.swing.JTable();
- jButton1 = new javax.swing.JButton();
- jButton2 = new javax.swing.JButton();
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- jTable1.setModel(new javax.swing.table.DefaultTableModel(
- new Object [][] {
- {null, null, null, null},
- {null, null, null, null},
- {null, null, null, null},
- {null, null, null, null}
- },
- new String [] {
- "Title 1", "Title 2", "Title 3", "Title 4"
- }
- ));
- jTable1.setFillsViewportHeight(true);
- jScrollPane1.setViewportView(jTable1);
- jButton1.setText("AUTO_RESIZE_LAST_COLUMN");
- jButton1.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton1ActionPerformed(evt);
- }
- });
- jButton2.setText("AUTO_RESIZE_NEXT_COLUMN");
- jButton2.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton2ActionPerformed(evt);
- }
- });
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 667, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(0, 0, Short.MAX_VALUE))
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addGap(103, 103, 103)
- .addComponent(jButton1)
- .addGap(82, 82, 82)
- .addComponent(jButton2)
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(18, 18, 18)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jButton2)
- .addComponent(jButton1))
- .addGap(0, 17, Short.MAX_VALUE))
- );
- pack();
- }// </editor-fold>
- private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
- jTable1.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
- jTable1.getColumnModel().getColumn(1).setWidth(200);
- jTable1.repaint();
- jTable1.revalidate();
- }
- private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
- jTable1.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN);
- jTable1.getColumnModel().getColumn(1).setWidth(200);
- jTable1.repaint();
- jTable1.revalidate();
- }
- /**
- * @param args the command line arguments
- */
- public static void main(String args[]) {
- /* Set the Nimbus look and feel */
- //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
- /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
- * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
- */
- try {
- for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
- if ("Nimbus".equals(info.getName())) {
- javax.swing.UIManager.setLookAndFeel(info.getClassName());
- break;
- }
- }
- } catch (ClassNotFoundException ex) {
- java.util.logging.Logger.getLogger(Pokus.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (InstantiationException ex) {
- java.util.logging.Logger.getLogger(Pokus.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (IllegalAccessException ex) {
- java.util.logging.Logger.getLogger(Pokus.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (javax.swing.UnsupportedLookAndFeelException ex) {
- java.util.logging.Logger.getLogger(Pokus.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- }
- //</editor-fold>
- /* Create and display the form */
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- new Pokus().setVisible(true);
- }
- });
- }
- // Variables declaration - do not modify
- private javax.swing.JButton jButton1;
- private javax.swing.JButton jButton2;
- private javax.swing.JScrollPane jScrollPane1;
- private javax.swing.JTable jTable1;
- // End of variables declaration
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement