posted 15 years ago
Hi Michael,
I am putting the complete program, and this program is called by another program(say B.java). This program is a Tab of a window(this window is belongs to B.java, I am not able to post that B.java because it is related to so many other java files in my project).
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
/*
* Created by JFormDesigner on Mon Mar 31 15:10:48 IST 2008
*/
/**
* @author User #1
*/
public class MyProgram extends JPanel{
public MyProgram() {
initComponents();
}
private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
tabbedPane1 = new JTabbedPane();
panel2 = new JPanel();
label4 = new JLabel();
label6 = new JLabel();
scrollPane3 = new JScrollPane();
list3 = new JList();
panel9 = new JPanel();
button6 = new JButton();
button7 = new JButton();
scrollPane4 = new JScrollPane();
list4 = new JList();
label5 = new JLabel();
comboBox2 = new JComboBox();
panel10 = new JPanel();
button8 = new JButton();
button5 = new JButton();
//======== tabbedPane1 ========
{
//======== panel2 ========
{
panel2.setBorder(new TitledBorder("Announcements"));
panel2.setLayout(new GridBagLayout());
((GridBagLayout)panel2.getLayout()).columnWidths = new int[] {0, 0, 0, 0};
((GridBagLayout)panel2.getLayout()).rowHeights = new int[] {0, 0, 0, 0, 0, 0};
((GridBagLayout)panel2.getLayout()).columnWeights = new double[] {0.0, 0.0, 0.0, 1.0E-4};
((GridBagLayout)panel2.getLayout()).rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4};
//---- label4 ----
label4.setText("User groups selected");
panel2.add(label4, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 5, 5), 0, 0));
//---- label6 ----
label6.setText("User Groups in the system");
panel2.add(label6, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 5, 0), 0, 0));
//======== scrollPane3 ========
{
scrollPane3.setViewportView(list3);
}
panel2.add(scrollPane3, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 5, 5), 0, 0));
//======== panel9 ========
{
panel9.setMinimumSize(new Dimension(200, 0));
panel9.setLayout(null);
//---- button6 ----
button6.setText("<<Add");
button6.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
button6ActionPerformed(e);
}
});
panel9.add(button6);
button6.setBounds(0, 0, 100, button6.getPreferredSize().height);
//---- button7 ----
button7.setText("Remove>>");
button7.setMinimumSize(new Dimension(200, 23));
button7.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
button7ActionPerformed(e);
}
});
panel9.add(button7);
button7.setBounds(0, 25, 100, button7.getPreferredSize().height);
{ // compute preferred size
Dimension preferredSize = new Dimension();
for(int i = 0; i < panel9.getComponentCount(); i++) {
Rectangle bounds = panel9.getComponent(i).getBounds();
preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
}
Insets insets = panel9.getInsets();
preferredSize.width += insets.right;
preferredSize.height += insets.bottom;
panel9.setPreferredSize( preferredSize );
}
}
panel2.add(panel9, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 5, 5), 0, 0));
//======== scrollPane4 ========
{
scrollPane4.setViewportView(list4);
}
panel2.add(scrollPane4, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 5, 0), 0, 0));
//---- label5 ----
label5.setText("Announcement");
panel2.add(label5, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 5, 5), 0, 0));
//---- comboBox2 ----
comboBox2.setEditable(true);
comboBox2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
comboBox1ActionPerformed(e);
}
});
panel2.add(comboBox2, new GridBagConstraints(0, 3, 3, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 5, 0), 0, 0));
//======== panel10 ========
{
panel10.setLayout(new GridLayout());
//---- button8 ----
button8.setText("Send");
button8.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
button8ActionPerformed(e);
}
});
panel10.add(button8);
//---- button5 ----
button5.setText("Clear");
button5.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
button5ActionPerformed(e);
}
});
panel10.add(button5);
}
panel2.add(panel10, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 0, 5), 0, 0));
}
tabbedPane1.addTab("Announcement", panel2);
}
// JFormDesigner - End of component initialization //GEN-END:initComponents
}
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
private JTabbedPane tabbedPane1;
private JPanel panel2;
private JLabel label4;
private JLabel label6;
private JScrollPane scrollPane3;
private JList list3;
private JPanel panel9;
private JButton button6;
private JButton button7;
private JScrollPane scrollPane4;
private JList list4;
private JLabel label5;
private JComboBox comboBox2;
private JPanel panel10;
private JButton button8;
private JButton button5;
// JFormDesigner - End of variables declaration //GEN-END:variables
private void button6ActionPerformed(ActionEvent e) {
// TODO add your code here
}
private void button7ActionPerformed(ActionEvent e) {
// TODO add your code here
}
private void comboBox1ActionPerformed(ActionEvent e) {
// TODO add your code here
}
private void button8ActionPerformed(ActionEvent e) {
// TODO add your code here
}
private void button5ActionPerformed(ActionEvent e) {
// TODO add your code here
}
}
If you need more information I can give you. So, can you please help me to solve this issue.
[ March 31, 2008: Message edited by: Debendra Blr ]