There are a lot of specifications missing for the question, but the basic concept might be the following:
- Listen the events for the container resizing with a ComponentListener
- In the Event listener make the resize logic, for example by increasing the font size until the text does not fit in the container.
See this example.
solved Responsive Font Size Java [closed]