i have my little program here and it all works and everything but i would like the GUI to stay this size i have it set. Right now when you run it and you drag a corner it changes the whole look of the GUI and moves everything around. I was wondering if there is a way to keep it the size i have it now without it being able to change?
package wlodmgcalc; import javax.swing.*; import java.awt.*; import java.awt.event.*; public class wlocalc extends JFrame implements ActionListener { static final long serialVersionUID = 0L; JTextField atk; JComboBox elementBox; JButton calculate; JLabel damageTotal; JLabel warning; String[] elements; int cbox; String atkNum; public wlocalc() { super("WLO Damage Calculator"); setSize(180, 230); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); FlowLayout flow = new FlowLayout(FlowLayout.LEFT); setLayout(flow); JPanel row1 = new JPanel(); JLabel atkLabel = new JLabel("Atk/Matk:"); row1.add(atkLabel); atk = new JTextField(7); row1.add(atk); add(row1); JPanel row2 = new JPanel(); JLabel elementLabel = new JLabel("Element:"); row2.add(elementLabel); String[] elements = { "Wind", "Fire", "Water", "Earth" }; elementBox = new JComboBox(elements); elementBox.addActionListener(this); row2.add(elementBox); add(row2); JPanel row3 = new JPanel(); FlowLayout flowbutton = new FlowLayout(FlowLayout.CENTER, 50, 10); row3.setLayout(flowbutton); calculate = new JButton("Calculate"); calculate.addActionListener(this); row3.add(calculate); add(row3); JPanel row4 = new JPanel(); JLabel totalLabel = new JLabel("Damage: "); row4.add(totalLabel); add(row4); JPanel row5 = new JPanel(); damageTotal = new JLabel(atkNum); row5.add(damageTotal); add(row5); JPanel row6 = new JPanel(); warning = new JLabel("Damage is to weak element"); row6.add(warning); add(row6); setVisible(true); } public void actionPerformed(ActionEvent event) { String atknum = atk.getText(); int atkNumber = Integer.parseInt(atknum); String element = (String)elementBox.getSelectedItem(); if (atkNumber == 0) { damageTotal.setText("0"); } else if (element == "Wind") { cbox = (int) ((atkNumber * 1.4 + 0 - 2 * 0.98) * 1.3); } else if (element == "Fire") { cbox = (int) ((atkNumber * 1.4 + 0 - 2 * 0.98) * 1.6); } else if (element == "Water") { cbox = (int) ((atkNumber * 1.4 + 0 - 2 * 0.98) * 1.4); } else if (element == "Earth") { cbox = (int) ((atkNumber * 1.4 + 0 - 2 * 0.98) * 1.3); } String pressed = event.getActionCommand(); if (pressed.equals("Calculate")) { damageTotal.setText("" + cbox); } } public static void main(String[] args) { wlocalc dmg = new wlocalc(); } }
Any and help is appreciated if you want to see how i mean just run that and maximize the window