• Post Reply Bookmark Topic Watch Topic
  • New Topic

Is this design smart?

 
Qunfeng Wang
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is my old login dialog
-----------------------------------

logo

------------------------------------
--log info-----------------------
| host________
| port________
| user________
| pwd__________
----------------------------------
OK Cancel
------------------------------------
Now I want to switch between english and chinese.So I redisign my dialog like this:
-----------------------------------

logo

------------------------------------
--log info-----------------------
| host________
| port________
| user________
| pwd__________
----------------------------------
OK Cancel Option>>
------------------------------------
When I pressed Option,the dialog strectch like this:
-----------------------------------

logo

------------------------------------
--log info-----------------------
| host________
| port________
| user________
| pwd__________
----------------------------------
language[ ]
----------------------------------

OK Cancel Option>>
------------------------------------

When I pressed Option agin ,it will shrink.
Is this a good design?If so,how can I manage the language panel?I mean how to make it stretch or shrink.
Thank you in advance.
 
Qunfeng Wang
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah,I get it!I redesign my login dialog just like the Web Anvenet's client login dialog.Below is how I make my dialog stretch and shrink.
advanceBtn.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent evt) {
if(show == false) {
hostTextField.setMaximumSize(userTextField.getPreferredSize());
p = new JPanel(new SpringLayout());
p.setBorder(BorderFactory.createLoweredBevelBorder());

p.add(hostLabel);
hostLabel.setLabelFor(hostTextField);
p.add(hostTextField);

p.add(portLabel);
portLabel.setLabelFor(portTextField);
p.add(portTextField);

p.add(languageLabel);
languageLabel.setLabelFor(comboBox);
p.add(comboBox);

p.add(showConsoleLabel);
showConsoleLabel.setLabelFor(checkBox);
p.add(checkBox);

//Lay out the panel.
SpringUtilities.makeCompactGrid(p,
4, 2, //rows, cols
6, 6, //initX, initY
6, 5); //xPad, yPad

setBounds(wx, wy, 400, 400);
setResizable(false);
setVisible(true);

mainPane.add(p, BorderLayout.CENTER);
pack();

if(comboBox.getSelectedIndex() == 0)
advanceBtn.setText("<<高级");
else
advanceBtn.setText("<<Advance");
show = false;


show = true;
}
else {
mainPane.remove(p);
pack();
if(comboBox.getSelectedIndex() == 0)
advanceBtn.setText("高级>>");
else
advanceBtn.setText("Advance>>");
show = false;
}



}
});

When the button pressed,the mainPane adds or removes panel p according to the value of show.I use SpringLayout,it's a good choice to do login dialog.
Now another problem,the texfields in the panel p are longer than the textfields in another panel(the panel above p),even when I setPreferredSize.Is this because they are in different panels?Or I use a non-proper layout?
Thanks.
 
Qunfeng Wang
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use GridBagLayout to solve this problem.
Next, I'll try to set a backgroud image for the dialog.
 
Filip Pas
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After the user pressed the options button invoke the pack method of you're jframe and it will readjust.
 
Filip Pas
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After the user pressed the options button invoke the pack method of you're jframe and it will readjust.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!