Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 8th, 2012  |  syntax: None  |  size: 4.29 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Adding title bar to JFrame (Linux)
  2. /*
  3.  * To change this template, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package javaapplication14;
  7.  
  8. import framez.NewJFrame;
  9.  
  10. /**
  11.  *
  12.  * @author uluroki
  13.  */
  14. public class JavaApplication14 {
  15.  
  16. /**
  17.  * @param args the command line arguments
  18.  */
  19. public static void main(String args[]) {
  20.     /* Set the Nimbus look and feel */
  21.     //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  22.     /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  23.      * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  24.      */
  25.     try {
  26.         for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  27.             if ("Nimbus".equals(info.getName())) {
  28.                 javax.swing.UIManager.setLookAndFeel(info.getClassName());
  29.                 break;
  30.             }
  31.         }
  32.     } catch (ClassNotFoundException ex) {
  33.         java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  34.     } catch (InstantiationException ex) {
  35.         java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  36.     } catch (IllegalAccessException ex) {
  37.         java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  38.     } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  39.         java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  40.     }
  41.     //</editor-fold>
  42.  
  43.     /* Create and display the form */
  44.     java.awt.EventQueue.invokeLater(new Runnable() {
  45.  
  46.         @Override
  47.         public void run() {
  48.             NewJFrame myframe = new NewJFrame();                
  49.             myframe.setVisible(true);
  50.         }
  51.     });
  52.   }
  53. }
  54.  
  55.  
  56. /*
  57.  * To change this template, choose Tools | Templates
  58.  * and open the template in the editor.
  59.  */
  60.  
  61. /*
  62.  * NewJFrame.java
  63.  *
  64.  * Created on 2012-01-11, 21:13:30
  65.  */
  66. package framez;
  67.  
  68. /**
  69.  *
  70.  * @author uluroki
  71.  */
  72. public class NewJFrame extends javax.swing.JFrame {
  73.  
  74. /** Creates new form NewJFrame */
  75. public NewJFrame() {
  76.     initComponents();
  77. }
  78.  
  79. /** This method is called from within the constructor to
  80.  * initialize the form.
  81.  * WARNING: Do NOT modify this code. The content of this method is
  82.  * always regenerated by the Form Editor.
  83.  */
  84. @SuppressWarnings("unchecked")
  85. // <editor-fold defaultstate="collapsed" desc="Generated Code">
  86. private void initComponents() {
  87.  
  88.     jScrollPane1 = new javax.swing.JScrollPane();
  89.     jTable1 = new javax.swing.JTable();
  90.  
  91.     setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  92.  
  93.     jTable1.setModel(new javax.swing.table.DefaultTableModel(
  94.         new Object [][] {
  95.             {null, null, null, null},
  96.             {null, null, null, null},
  97.             {null, null, null, null},
  98.             {null, null, null, null}
  99.         },
  100.         new String [] {
  101.             "Title 1", "Title 2", "Title 3", "Title 4"
  102.         }
  103.     ));
  104.     jScrollPane1.setViewportView(jTable1);
  105.  
  106.     javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  107.     getContentPane().setLayout(layout);
  108.     layout.setHorizontalGroup(
  109.         layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  110.         .addGroup(layout.createSequentialGroup()
  111.             .addContainerGap()
  112.             .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 375, javax.swing.GroupLayout.PREFERRED_SIZE)
  113.             .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  114.     );
  115.     layout.setVerticalGroup(
  116.         layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  117.         .addGroup(layout.createSequentialGroup()
  118.             .addContainerGap()
  119.             .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 275, javax.swing.GroupLayout.PREFERRED_SIZE)
  120.             .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  121.     );
  122.  
  123.     pack();
  124. }// </editor-fold>
  125.  
  126. // Variables declaration - do not modify
  127. private javax.swing.JScrollPane jScrollPane1;
  128. private javax.swing.JTable jTable1;
  129. // End of variables declaration
  130. }
  131.        
  132. I just created a Desktop Application, added a JFrame Form,
  133. and dragged'n'dropped some buttons - no logic yet