This has nothing to do with efficiency. Use the first one, it's simpler and probably already contains the visibility check inside the setVisible() method.
When you write code, don't try to think about efficiency, especially in ridiculously trivial cases like this. You're running on a multi GHz computer, so you're only wasting your time on micro-optimization like this.