how to center JLabel in Jframe Swing?
问题 I have this working code for a stop watch in Swing. I want to have the label Time Remaining 300 seconds centered on the second line`. here is my code. import java.awt.BorderLayout; import java.awt.GridLayout; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.Timer; public class TimerGUI extends JPanel { JLabel