2

表示されていない唯一の Gateway のラベルを修正する方法。残りはすべて表示されます。

  public TextLabelMirror() {

    // DHCP
    String[] petStrings = { "Static", "Auto" };
    JPanel namePanel = new JPanel(new BorderLayout());
    JLabel nameLabel = new JLabel("DHCP Mode: ");
    nameLabel.setDisplayedMnemonic(KeyEvent.VK_N);
    final JComboBox nameTextField = new JComboBox(petStrings);    
    nameLabel.setLabelFor(nameTextField);
    namePanel.add(nameLabel, BorderLayout.WEST);
    namePanel.add(nameTextField, BorderLayout.CENTER);

    // IP - Address 
    JPanel namePanel0 = new JPanel(new BorderLayout());
    JLabel nameLabel0 = new JLabel("IP: ");
    nameLabel0.setDisplayedMnemonic(KeyEvent.VK_N);
    final JTextField nameTextField0 = new JTextField(20);           
    nameLabel0.setLabelFor(nameTextField0);
    namePanel0.add(nameLabel0, BorderLayout.WEST);
    namePanel0.add(nameTextField0, BorderLayout.CENTER);


    // NetMask
    JPanel namePanel1 = new JPanel(new BorderLayout());
    JLabel nameLabel1 = new JLabel("Netmask: ");
    nameLabel1.setDisplayedMnemonic(KeyEvent.VK_N);
    final JTextField nameTextField1 = new JTextField(20);       
    nameLabel1.setLabelFor(nameTextField1);
    namePanel1.add(nameLabel1, BorderLayout.WEST);
    namePanel1.add(nameTextField1, BorderLayout.CENTER);

    // Gateway
    JPanel namePanel2 = new JPanel(new BorderLayout());
    JLabel nameLabel2 = new JLabel("Gateway: ");
    nameLabel2.setDisplayedMnemonic(KeyEvent.VK_N);
    final JTextField nameTextField2 = new JTextField(20);       
    nameLabel2.setLabelFor(nameTextField2);
    namePanel2.add(nameLabel2, BorderLayout.WEST);
    namePanel2.add(nameTextField2, BorderLayout.WEST);

    // Save now
    JPanel namePanel3 = new JPanel(new BorderLayout());
    final JButton nameTextField3 = new JButton("Save");       
    namePanel3.add(nameTextField3, BorderLayout.CENTER); 
    ....

  }
4

1 に答える 1

5

どちらも WEST に追加されたようですね。nameTextField2 を CENTER などに追加するつもりだったと思います。

namePanel2.add(nameLabel2, BorderLayout.WEST);
namePanel2.add(nameTextField2, BorderLayout.WEST);

そのようです:

namePanel2.add(nameLabel2, BorderLayout.WEST);
namePanel2.add(nameTextField2, BorderLayout.CENTER);
于 2012-04-09T07:34:09.377 に答える