Я проектирую JDialog в NetBeans и хочу повторно использовать код.В основном у меня есть JTabbedPane с 3 вкладками.Все 3 вкладки имеют JTable, и все 3 JTable имеют одинаковую структуру.NetBeans генерирует новый код для каждого JTable, есть ли способ повторно использовать тот же код в NetBeans?
Это код GUI, который у меня есть:
private void initComponents() {
jlPacket = new javax.swing.JLabel();
jtpPacket = new javax.swing.JTabbedPane();
jpInputs = new javax.swing.JPanel();
jScrollPane1 = new javax.swing.JScrollPane();
jtblInputs = new javax.swing.JTable();
jpOutputs = new javax.swing.JPanel();
jScrollPane2 = new javax.swing.JScrollPane();
jtblOutputs = new javax.swing.JTable();
jPanel3 = new javax.swing.JPanel();
jbSavePacketConfiguration = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setResizable(false);
jlPacket.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
jlPacket.setText("Packet Configuration");
jtpPacket.setBackground(new java.awt.Color(255, 255, 255));
jtpPacket.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
jpInputs.setBackground(new java.awt.Color(255, 255, 255));
jtblInputs.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
jtblInputs.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
"Group", "Start Address", "End Address"
}
) {
boolean[] canEdit = new boolean [] {
false, true, true
};
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];
}
});
jtblInputs.setSelectionBackground(new java.awt.Color(204, 255, 204));
jtblInputs.setSelectionForeground(new java.awt.Color(0, 0, 0));
jtblInputs.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);
jtblInputs.getTableHeader().setReorderingAllowed(false);
jScrollPane1.setViewportView(jtblInputs);
jtblInputs.getColumnModel().getColumn(0).setResizable(false);
jtblInputs.getColumnModel().getColumn(1).setResizable(false);
jtblInputs.getColumnModel().getColumn(2).setResizable(false);
javax.swing.GroupLayout jpInputsLayout = new javax.swing.GroupLayout(jpInputs);
jpInputs.setLayout(jpInputsLayout);
jpInputsLayout.setHorizontalGroup(
jpInputsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jpInputsLayout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 275, Short.MAX_VALUE)
.addContainerGap())
);
jpInputsLayout.setVerticalGroup(
jpInputsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jpInputsLayout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 283, Short.MAX_VALUE)
.addContainerGap())
);
jtpPacket.addTab("Inputs", jpInputs);
jpOutputs.setBackground(new java.awt.Color(255, 255, 255));
jpOutputs.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
jtblOutputs.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
jtblOutputs.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
"Group", "Start Address", "End Address"
}
) {
boolean[] canEdit = new boolean [] {
false, true, true
};
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];
}
});
jtblOutputs.setSelectionBackground(new java.awt.Color(204, 255, 204));
jtblOutputs.setSelectionForeground(new java.awt.Color(0, 0, 0));
jtblOutputs.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);
jtblOutputs.getTableHeader().setReorderingAllowed(false);
jScrollPane2.setViewportView(jtblOutputs);
jtblOutputs.getColumnModel().getColumn(0).setResizable(false);
jtblOutputs.getColumnModel().getColumn(1).setResizable(false);
jtblOutputs.getColumnModel().getColumn(2).setResizable(false);
javax.swing.GroupLayout jpOutputsLayout = new javax.swing.GroupLayout(jpOutputs);
jpOutputs.setLayout(jpOutputsLayout);
jpOutputsLayout.setHorizontalGroup(
jpOutputsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 295, Short.MAX_VALUE)
.addGroup(jpOutputsLayout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 275, Short.MAX_VALUE)
.addContainerGap())
);
jpOutputsLayout.setVerticalGroup(
jpOutputsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 305, Short.MAX_VALUE)
.addGroup(jpOutputsLayout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 283, Short.MAX_VALUE)
.addContainerGap())
);
jtpPacket.addTab("Outputs", jpOutputs);
jPanel3.setBackground(new java.awt.Color(255, 255, 255));
jPanel3.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 295, Short.MAX_VALUE)
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 305, Short.MAX_VALUE)
);
jtpPacket.addTab("Outputs", jPanel3);
jbSavePacketConfiguration.setBackground(new java.awt.Color(255, 255, 255));
jbSavePacketConfiguration.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
jbSavePacketConfiguration.setText("Save Packet Configuration");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jtpPacket, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
.addComponent(jlPacket)
.addComponent(jbSavePacketConfiguration))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jlPacket)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jtpPacket, javax.swing.GroupLayout.PREFERRED_SIZE, 334, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jbSavePacketConfiguration)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>