Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8378427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:55:35+00:00 2026-06-09T15:55:35+00:00

Please have a look at the following code. package normal; import java.awt.*; import java.awt.event.*;

  • 0

Please have a look at the following code.

package normal;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

public class MainForm extends JFrame implements ComponentListener
{
    private JTabbedPane tab;

    private InsertForm insertForm;
    private UpdateDeleteForm updateDelete;
    private SearchForm searchForm;

    public MainForm()
    {
        tab = new JTabbedPane();
        insertForm = new InsertForm();
        updateDelete = new UpdateDeleteForm();
        searchForm = new SearchForm();

        //Creating the main window
        tab.add(insertForm,"Insert");
        tab.add(updateDelete,"Update/Delete");
        tab.add(searchForm,"Search");
        tab.addChangeListener(new TabChangeWork());

        getContentPane().add(tab);




       // this.setSize(500,500);
        this.setTitle("My Phone Book App");
        this.setResizable(false);
        this.pack();
        this.validate();
        this.setLocationRelativeTo(null);
        this.setVisible(true);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    }

    @Override
    public void componentResized(ComponentEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void componentMoved(ComponentEvent e)
    {
        System.out.println("X Location: "+this.getX());
    }

    @Override
    public void componentShown(ComponentEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void componentHidden(ComponentEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    private class TabChangeWork implements ChangeListener
    {

        @Override
        public void stateChanged(ChangeEvent e) 
        {
            JTabbedPane tabSource = (JTabbedPane)e.getSource();

            int index = tabSource.getSelectedIndex();
            System.out.println("Tab Changed to: "+tabSource.getTitleAt(index));


            if(tabSource.getTitleAt(index).equals("Update/Delete"))
            {
                updateDelete.addNames();
            }
        }

    }
}

In here, the ComponentListener is not working properly because the action inside the method “ComponentMoved” is not happening. I am trying to the get the new coordinates of the JFrame if this is moved. Why it is not working? Please help!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T15:55:37+00:00Added an answer on June 9, 2026 at 3:55 pm

    You have not registered with the ComponentListener anywhere in the code…

    Do it like this….

    component_to_monitor.addComponentListener(this);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please have a look at the following code import java.awt.event.*; import javax.swing.*; import java.awt.*;
Please have a look at the following code import java.awt.*; import java.awt.event.*; import javax.swing.*;
Please have a look the following code import javax.swing.*; import java.awt.event.*; import java.awt.*; public
Please have a look at the following code. import java.awt.FlowLayout; import java.awt.GridLayout; import javax.swing.*;
Please have a look at the following code import java.awt.*; import javax.swing.JTable; import javax.swing.*;
Please have a look at the following code package normal; import java.io.*; import java.util.*;
Please have a look at the following code Main.Java import java.awt.event.*; import java.awt.*; import
Please have a look at the following code package Euler; import java.util.ArrayList; import java.util.List;
Please have a look at the following code import java.awt.Color; import java.awt.Dimension; import java.awt.FlowLayout;
Please have a look at the following code import java.awt.Color; import java.awt.Dimension; import java.awt.EventQueue;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.