2015-08-04 18 views
7

Tôi đã kết nối với Solaris 11 từ máy tính của mình. Tôi đã đặt DISPLAY cho máy của mình. Và tôi đang sử dụng Java 8.Swing JButton không hiển thị đúng trên Solaris với Java 8

Lưu ý: Điều này làm việc tốt khi sử dụng Java 6.

Khi tôi tung ra hộp thoại sau đó nút của nó và các thành phần xoay khác không nhận được trả lại.

quan sát thấy rằng nó hoạt động trên o Windows 7 Enterprise o Windows Server 2012 Enterprise

tôi đã cố gắng thay đổi L & F nhưng điều đó không làm việc. Khi tôi sử dụng "GTKLookAndFeel" thì các nút xuất hiện nhưng không có văn bản/nhãn.

Bất kỳ trợ giúp nào được đánh giá cao. Vui lòng cho tôi biết nếu có cần thiết. Cảm ơn.

Mã cho thoại của tôi là như sau

package com.ui; 


import javax.swing.SwingUtilities; 


public class SimpleDialog extends java.awt.Dialog { 
    private static final long serialVersionUID = -8298472889742780386L; 
    public SimpleDialog(java.awt.Frame parent, boolean modal) { 
     super(parent, modal); 
     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. 
    */ 
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents 
    private void initComponents() { 

     btnSkip = new javax.swing.JButton(); 
     btnRetry = new javax.swing.JButton(); 
     btnAbort = new javax.swing.JButton(); 
     jScrollPane1 = new javax.swing.JScrollPane(); 
     lblMessage = new javax.swing.JTextArea(); 
     btnViewLog = new javax.swing.JButton(); 

     setLocationRelativeTo(null); 
     setMinimumSize(new java.awt.Dimension(600, 200)); 
     setModalityType(java.awt.Dialog.ModalityType.APPLICATION_MODAL); 
     setName("Form"); // NOI18N 
     setResizable(false); 
     setTitle("Simple Dialog"); 
     addWindowListener(new java.awt.event.WindowAdapter() { 
      public void windowClosing(java.awt.event.WindowEvent evt) { 
       closeDialog(evt); 
      } 
     }); 

     btnSkip.setText("Skip this Step"); // NOI18N 
     btnSkip.setName("btnSkip"); // NOI18N 
     btnSkip.addActionListener(new java.awt.event.ActionListener() { 
      public void actionPerformed(java.awt.event.ActionEvent evt) { 
       btnSkip_Click(evt); 
      } 
     }); 

     btnRetry.setText("Retry"); // NOI18N 
     btnRetry.setName("btnRetry"); // NOI18N 
     btnRetry.addActionListener(new java.awt.event.ActionListener() { 
      public void actionPerformed(java.awt.event.ActionEvent evt) { 
       btnRetry_Click(evt); 
      } 
     }); 

     btnAbort.setText("Abort"); // NOI18N 
     btnAbort.setName("btnAbort"); // NOI18N 
     btnAbort.addActionListener(new java.awt.event.ActionListener() { 
      public void actionPerformed(java.awt.event.ActionEvent evt) { 
       btnAbort_Click(evt); 
      } 
     }); 

     jScrollPane1.setName("jScrollPane1"); // NOI18N 

     lblMessage.setColumns(20); 
     lblMessage.setEditable(false); // NOI18N 
     lblMessage.setLineWrap(true); 
     lblMessage.setRows(5); 
     lblMessage.setName("lblMessage"); // NOI18N 
     jScrollPane1.setViewportView(lblMessage); 

     btnViewLog.setText("View log"); // NOI18N 
     btnViewLog.setName("btnViewLog"); // NOI18N 
     btnViewLog.addActionListener(new java.awt.event.ActionListener() { 
      public void actionPerformed(java.awt.event.ActionEvent evt) { 
       // open some log file 
      } 
     }); 

     javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); 
     this.setLayout(layout); 
     layout.setHorizontalGroup(
       layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 
       .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() 
         .addContainerGap() 
         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) 
           .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 580, Short.MAX_VALUE) 
           .addGroup(layout.createSequentialGroup() 
             .addComponent(btnSkip) 
             .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) 
             .addComponent(btnRetry) 
             .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 87, Short.MAX_VALUE) 
             .addComponent(btnViewLog) 
             .addGap(79, 79, 79) 
             .addComponent(btnAbort))) 
             .addContainerGap()) 
       ); 
     layout.setVerticalGroup(
       layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 
       .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() 
         .addContainerGap() 
         .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 149, Short.MAX_VALUE) 
         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 
         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 
           .addComponent(btnSkip) 
           .addComponent(btnAbort) 
           .addComponent(btnRetry) 
           .addComponent(btnViewLog)) 
           .addContainerGap()) 
       ); 

     pack(); 
    }// </editor-fold>//GEN-END:initComponents 

    /** Closes the dialog */ 
    private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog 
     setVisible(false); 
     dispose(); 
    }//GEN-LAST:event_closeDialog 

    private void btnAbort_Click(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAbort_Click 
     this.setVisible(false); 
    }//GEN-LAST:event_btnAbort_Click 

    private void btnRetry_Click(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRetry_Click 
     this.setVisible(false); 
    }//GEN-LAST:event_btnRetry_Click 

    private void btnSkip_Click(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSkip_Click 
     this.setVisible(false); 
    }//GEN-LAST:event_btnSkip_Click 

    public static void main(String args[]) { 
     SwingUtilities.invokeLater(new Runnable() { 
      public void run() { 

       SimpleDialog dialog = new SimpleDialog(new java.awt.Frame(), true); 
       dialog.addWindowListener(new java.awt.event.WindowAdapter() { 
        public void windowClosing(java.awt.event.WindowEvent e) { 
         System.exit(0); 
        } 
       }); 
       dialog.setVisible(true); 
      } 
     }); 
    } 


    // Variables declaration - do not modify//GEN-BEGIN:variables 
    private javax.swing.JButton btnAbort; 
    private javax.swing.JButton btnRetry; 
    private javax.swing.JButton btnSkip; 
    private javax.swing.JButton btnViewLog; 
    private javax.swing.JScrollPane jScrollPane1; 
    private javax.swing.JTextArea lblMessage; 
    // End of variables declaration//GEN-END:variables 

} 
+0

Trường hợp Solaris [không đầu] (http://stackoverflow.com/a/7401312/230513)? – trashgod

+0

cảm ơn @trashgod cho câu trả lời của bạn. Tôi không chắc liệu Solaris có vô đầu hay không. Tuy nhiên, xin lưu ý rằng nó hoạt động tốt khi tôi kết nối thông qua Windows Server 2012 và Windows 7 máy. –

+0

Không rõ máy bạn đang nói đến khi bạn nói "Tôi đã đặt DISPLAY thành máy của tôi". Với thực tế bạn đã viết bạn không có ý tưởng nếu máy Solaris là không đầu hay không, tôi giả sử bạn không phải là rendering nút swing trên Solaris nhưng (gián tiếp) để cái gì khác. Bạn đang chạy một máy chủ X11 trên máy tính Windows của bạn? – jlliagre

Trả lời

0

Hãy thử UIManager.setLookAndFeel này (UIManager.getSystemLookAndFeelClassName());

Hãy cho tôi biết nếu nó hoạt động hay không. :)

+0

Nó không hoạt động. Tôi đã đề cập đến trong câu hỏi của tôi rằng việc thay đổi L & F không giúp được gì. Nhân tiện, vấn đề ở đâu đó trong việc sử dụng các điều khiển Swing bên trong hộp thoại AWT. Tôi đã đổi sang hộp thoại Swing và nó hoạt động. Cảm ơn. –

Các vấn đề liên quan