Reputation: 13
So I have this code in my contructor, my class extends JFrame:
super("myBucketList");
i = new Item();
//controls panel
controls = new JPanel();
itemField = new JTextField();
itemField.addActionListener(new ListenAction());
delField = new JTextField();
delField.addActionListener(new ListenAction());
listArea = new JTextArea();
listArea.setEditable(false);
controls.add(delField);
controls.add(itemField);
//txtareaPanel
textareaPanel = new JPanel();
listScroll = new JScrollPane();
listScroll.setViewportView(listArea);
textareaPanel.add(listScroll);
//tab1 panel
tab1 = new JPanel();
tab1.setLayout(new BorderLayout());
tab1.add(controls, BorderLayout.NORTH);
tab1.add(textareaPanel, BorderLayout.CENTER);
add(tab1);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(500,200);
setVisible(true);
Now if I run my application the components are really small, how to fix it?
Here is a screenshot of the situation/problem: http://snag.gy/yjbUl.jpg
Thanks
Upvotes: 0
Views: 480
Reputation: 1
If you are using jdk 8 then keep it but download the jre 9 and your widgets etc will be of normal size. This solves the problem!
Upvotes: 0
Reputation: 11143
Just call the constructor with columns, see here
For example:
itemField = new JTextField(10); //Or the number of cols you want
Or call JTextField#setColumns()
itemField.setColumns(10); //Or the number of columns you want
For the JTextArea
call this constructor as follows:
listArea = new JTextArea("", 10, 10); //Text, rows, cols.
Or again use JTextArea#setRows()
and JTextArea#setColumns()
as follows:
listArea.setColumns(10);
listArea.setRows(10);
That should fix your problem.
Upvotes: 2