How can i reach frame title inside Handler
<p>I can't reach my title inside Handler.</p>

<p>Example of my code:</p>

<pre><code>public Frame extends JFrame {

public Frame() {
    super("Frame 1");
        .
        .
        .
</code></pre>

<p>There needs to be a button in my GUI and whenever you click it, it needs to change the title from Frame 1 to Frame 2, and vice versa.</p>

<pre><code>ButtonHandler handler = new ButtonHandler();
        .
        .
        .
}
 class ButtonHandler implements ActionListener {
    public void actionPerformed(ActionEvent event) {
            JButton but = (JButton) event.getSource();
            if (??.getTitle(equals("Frame 1"))) {
                setTitle("Frame 2");
            } else {
                setTitle("Frame 1");
            }
</code></pre>

<p>So everytime I click the button all it does is the else part. I can't use the getTitle inside my if :/</p>
