0
내가 최근에 초점을 JtabbedPane의 탭을 열었습니다. 내 응용 프로그램에서, 나는 모든 탭을 만듭니다 그것은 첫 번째 탭에만 초점을 맞 춥니 다. 최근에는 포커스를 자동으로 만들지 않습니다. 예 : 처음 만들 때 탭 첫 번째 탭에 초점을 누른 다음 다른 탭을 만듭니다. 다음 탭으로 포커스를 이동합니다. 첫 번째 탭에만 자동으로 표시되지 않습니다. 한번 확인하십시오. 감사합니다.어떻게 초점 JtabbedPane 탭을 만들
내 코드 :
이public class TabbedPaneFocus extends javax.swing.JFrame {
JTextArea tx;
int i=0;
JTabbedPane tabbedPane;
public TabbedPaneFocus() {
initComponents();
tabbedPane=new CloseButtonTabbedPane();
add(tabbedPane);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(tabbedPane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 512, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(tabbedPane, javax.swing.GroupLayout.DEFAULT_SIZE, 366, Short.MAX_VALUE)
);
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
create = new javax.swing.JMenuItem();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jMenu1.setText("File");
create.setText("Create");
create.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
createActionPerformed(evt);
}
});
jMenu1.add(create);
jMenuBar1.add(jMenu1);
setJMenuBar(jMenuBar1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 512, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 366, Short.MAX_VALUE)
);
pack();
}// </editor-fold>
private void createActionPerformed(java.awt.event.ActionEvent evt) {
try{
i++;
tx = new JTextArea();
tx.setFont(new java.awt.Font("Miriam Fixed", 0, 13));
JScrollPane scrollpane=new JScrollPane(tx);
tabbedPane.add(scrollpane);
tabbedPane.addTab("Doc"+i, scrollpane);
tabbedPane.setFocusable(true);
}
catch(ArrayIndexOutOfBoundsException aio){
}
}
public static void main(String args[]) {
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(TabbedPaneFocus.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(TabbedPaneFocus.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(TabbedPaneFocus.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(TabbedPaneFocus.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
new TabbedPaneFocus().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JMenuItem create;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenuBar jMenuBar1;
// End of variables declaration
}