I have created a JTextField and I have used the setBounds() method which is not working. There are no bugs in my code so Im not sure whats wrong. I will include pictures and image of output below.
import java.awt.*;
import javax.swing.*;
public class A1 extends JFrame {
public A1(String title) {
super(title);
this.setSize(500, 500);
this.setLocation(100, 100);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JTextField text1 = new JTextField();
text1.setBounds(50, 100, 200, 30);
Container mainContainer = this.getContentPane();
JTabbedPane tabbedPane = new JTabbedPane();
tabbedPane.setBackground(Color.GRAY);
tabbedPane.setForeground(Color.BLACK);
tabbedPane.setFont(new Font("Century Gothic", Font.BOLD, 14));
//tab1
JPanel panel1 = new JPanel();
panel1.setBackground(Color.CYAN);
panel1.add(text1);
//tab2
JPanel panel2 = new JPanel();
tabbedPane.addTab("Future/Present Value", panel1);
tabbedPane.addTab("Financial Ratios", panel2);
mainContainer.add(tabbedPane);
}
public static void main(String[] args) {
A1 launch = new A1("Financial Calculator");
launch.setVisible(true);
}
}
Im honestly baffled why it doesnt change size. Any help would be much appreciated.