Create a panel that will contain the panel that has the multiple fields.
//Create setup panel.
JPanel settingUITopPanel = new JPanel(new BorderLayout());
senderPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("JMS SENDER"));
settingUITopPanel.add(senderPanel, BorderLayout.NORTH);
listenerPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("JMS LISTENER"));
settingUITopPanel.add(listenerPanel, BorderLayout.SOUTH);
senderPanel.setLayout(senderSetup(layout));
listenerPanel.setLayout(listenerSetup(layout1));
//Displa dialog box with multiple fields.
int result = JOptionPane.showConfirmDialog(null,settingUITopPanel,"Setting",JOptionPane.OK_CANCEL_OPTION);
if(result == JOptionPane.OK_OPTION){
//Get fields value here...
}
Method that will return sender setup layout.
private GroupLayout senderSetup(GroupLayout layout){
JLabel l2 = new JLabel("MQ Port Number");
JLabel l3 = new JLabel("MQ Manager");
JLabel l4 = new JLabel("MQ Queue");
JLabel l5 = new JLabel("MQ Channel");
JLabel l6 = new JLabel("MQ Username");
JLabel l7 = new JLabel("MQ Password");
layout.setAutoCreateContainerGaps(true);
GroupLayout.SequentialGroup hGroup =
layout.createSequentialGroup();
hGroup.addGroup(layout.createParallelGroup().
addComponent(l1).
addComponent(l2).
addComponent(l3).
addComponent(l4).
addComponent(l5).
addComponent(l6).
addComponent(l7));
hGroup.addGroup(layout.createParallelGroup().
addComponent(mqSenderHost).
addComponent(mqSenderManager).
addComponent(mqSenderQueue).
addComponent(mqSenderChannel).
addComponent(mqSenderUser).
addComponent(mqSenderPassword)
);
layout.setHorizontalGroup(hGroup);
layout.createSequentialGroup();
vGroup.addGroup(layout.createParallelGroup(Alignment.BASELINE).
addComponent(l1).addComponent(mqSenderHost));
vGroup.addGroup(layout.createParallelGroup(Alignment.BASELINE).
addComponent(l2).addComponent(mqSenderPort));
vGroup.addGroup(layout.createParallelGroup(Alignment.BASELINE).
addComponent(l3).addComponent(mqSenderManager));
vGroup.addGroup(layout.createParallelGroup(Alignment.BASELINE).
addComponent(l4).addComponent(mqSenderQueue));
vGroup.addGroup(layout.createParallelGroup(Alignment.BASELINE).
addComponent(l5).addComponent(mqSenderChannel));
vGroup.addGroup(layout.createParallelGroup(Alignment.BASELINE).
addComponent(l6).addComponent(mqSenderUser));
vGroup.addGroup(layout.createParallelGroup(Alignment.BASELINE).
addComponent(l7).addComponent(mqSenderPassword));
}//End method
Method that will return listener setup layout.
private GroupLayout listenerSetup(GroupLayout layout){
JLabel l2 = new JLabel("MQ Host Name");
JLabel l3 = new JLabel("MQ Port Number");
JLabel l4 = new JLabel("MQ Manager");
JLabel l5 = new JLabel("MQ Queue");
JLabel l6 = new JLabel("MQ Channel");
JLabel l7 = new JLabel("MQ Username");
JLabel l8 = new JLabel("MQ Password");
listenerEnabledCheckbox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
if (!((JCheckBox) event.getSource()).isSelected()) {
contentPane.remove(mainPanel);
senderTa.setSize(40, 100);
mainPanel = JPanelUtil.getJMSSenderOnlyPanel(senderTa);
mainPanel.setBorder(BorderFactory.createMatteBorder(5, 5, 5, 5, Color.white));
contentPane.add(mainPanel, BorderLayout.CENTER);
frame.setSize(1000, 800);
frame.setBounds(50, 50, 800, 600);
frame.pack();
suspendBtn.setEnabled(false);
false,
mqListenerHost,
mqListenerPort,
mqListenerManager,
mqListenerQueue,
mqListenerChannel,
mqListenerUser,
mqListenerPassword);
jmsThread.suspend();
}
contentPane.remove(mainPanel);
senderTa.setSize(20, 100);
receiverTa.setSize(20, 100);
mainPanel = JPanelUtil.getJMSSenderAndListenerPanel(senderTa, receiverTa);
mainPanel.setBorder(BorderFactory.createMatteBorder(5, 5, 5, 5, Color.white));
contentPane.add(mainPanel, BorderLayout.CENTER);
frame.setSize(1000, 800);
frame.setBounds(50, 50, 800, 600);
frame.pack();
suspendBtn.setEnabled(false);
true,
mqListenerHost,
mqListenerPort,
mqListenerManager,
mqListenerQueue,
mqListenerChannel,
mqListenerUser,
mqListenerPassword);
}
}
});
layout.setAutoCreateContainerGaps(true);
GroupLayout.SequentialGroup hGroup = layout.createSequentialGroup();
addComponent(l1).
addComponent(l2).
addComponent(l3).
addComponent(l4).
addComponent(l5).
addComponent(l6).
addComponent(l7).
addComponent(l8));
hGroup.addGroup(layout.createParallelGroup().
addComponent(listenerEnabledCheckbox).
addComponent(mqListenerHost).
addComponent(mqListenerPort).
addComponent(mqListenerManager).
addComponent(mqListenerQueue).
addComponent(mqListenerChannel).
addComponent(mqListenerUser).
addComponent(mqListenerPassword));
layout.setHorizontalGroup(hGroup);
addComponent(l1).addComponent(listenerEnabledCheckbox));
vGroup.addGroup(layout.createParallelGroup(Alignment.BASELINE).
addComponent(l2).addComponent(mqListenerHost));
vGroup.addGroup(layout.createParallelGroup(Alignment.BASELINE).
addComponent(l3).addComponent(mqListenerPort));
vGroup.addGroup(layout.createParallelGroup(Alignment.BASELINE).
addComponent(l4).addComponent(mqListenerManager));
vGroup.addGroup(layout.createParallelGroup(Alignment.BASELINE).
addComponent(l5).addComponent(mqListenerQueue));
vGroup.addGroup(layout.createParallelGroup(Alignment.BASELINE).
addComponent(l6).addComponent(mqListenerChannel));
vGroup.addGroup(layout.createParallelGroup(Alignment.BASELINE).
addComponent(l7).addComponent(mqListenerUser));
vGroup.addGroup(layout.createParallelGroup(Alignment.BASELINE).
addComponent(l8).addComponent(mqListenerPassword));
}//End method
No comments:
Post a Comment