Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

While loop with enums

807588Jun 17 2009 — edited Jun 28 2009
I'm familiar how to use for loops,
for(HomeButtons BtnInfo : HomeButtons.values())
    {
      if(BtnInfo.getEnum().equalsIgnoreCase("NOVALUE")==false)
      {
        System.out.println("Name:" + BtnInfo.getName() + "  Test:" + BtnInfo.getText());
        JButton tmpBtn = new JButton();
        tmpBtn.setName(BtnInfo.getName());
        tmpBtn.setText((BtnInfo.getText()));
        tmpBtn.setHorizontalTextPosition(SwingConstants.CENTER);
        tmpBtn.setVerticalTextPosition(SwingConstants.CENTER);
        tmpBtn.setIcon(BtnInfo.getIcon());
        tmpBtn.setForeground(TEXT_COLOR);
        tmpBtn.setOpaque(false);
        tmpBtn.addMouseListener(this);
        tmpBtn.setActionCommand(BtnInfo.getEnum());
        this.add(tmpBtn);
      }
    }
The question is, can you do the same thing with a while loop? I'm trying to get that "if" out of this loop.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 26 2009
Added on Jun 17 2009
14 comments
290 views