-1

I am trying to create a contact list where once you press a button named (contact add) it will go to a new page where you can add the name, address, and number. But I am having trouble going to a new page after pressing my button.

button.addActionListener( new ActionListener());
{
    public static void actionPerformed(ActionEvent e)
    {
    
        AFrame frame = new AFrame();    
        frame.setSize(500,500);    
        frame.setTitle("add list");
       new NewPFrame().setVisible(true);   
    }
});
camickr
  • 316,400
  • 19
  • 155
  • 279
  • Welcome. You should take a look at [ask] and take the [tour], if you have not done so already. Also take a look at [example]. This is general information that you should keep in mind, when asking questions. – cliff2310 May 31 '22 at 16:13
  • Does this answer your question? [How to open a new window by clicking a button](https://stackoverflow.com/questions/15513380/how-to-open-a-new-window-by-clicking-a-button) – Alias Cartellano May 31 '22 at 17:32
  • 1
    Looks to me like you are trying to create 2 frames. If you are trying to show the "add list" frame, then you need to make it visible. I see no need for creating a NewPFrame. Also, you should NOT be creating a second frame. Instead create you can create a `JDialog`. – camickr May 31 '22 at 20:10
  • I'm not familiar with the `AFrame` or `NewPFrame` classes. Can you tell us which graphics library you are using? Are you trying to use Swing, or JavaFX, or some other third-party library for creating a GUI? – Bobulous May 31 '22 at 21:10
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Swayangjit Jun 01 '22 at 08:15

0 Answers0