import javax.swing.JFrame; import javax.swing.Action; import javax.swing.AbstractAction; import javax.swing.ImageIcon; import java.awt.event.ActionEvent; import javax.swing.JButton; class Program01 extends JFrame { Action leftAction = new LeftAction("Felirat"); JButton btnTest = new JButton(leftAction); Program01() { add(btnTest); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(400, 300); centerWindow(this); setVisible(true); } public static void centerWindow(java.awt.Window frame) { java.awt.Dimension dimension = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); int x = (int)((dimension.getWidth() - frame.getWidth()) / 2); int y = (int)((dimension.getHeight() - frame.getHeight()) / 2); frame.setLocation(x, y); } public static void main(String[]args) { new Program01(); } class LeftAction extends AbstractAction { public LeftAction(String text) { super(text); } public void actionPerformed(ActionEvent e) { setTitle("vmi"); } } }