Note that there are some explanatory texts on larger screens.

plurals
  1. POJPanel won't show on JFrame
    text
    copied!<p>Here is the code</p> <pre><code>import Sprites.*; import javax.swing.*; import java.awt.*; public class Main { public int Health = 100; public int ArmourPt = 0; public int Gold = 250; public static JLabel Goldlbl = new JLabel("Gold:"); public static JLabel Healthlbl = new JLabel("Health:"); public static JLabel ArmourPtLbl = new JLabel("Armour Points"); public static JFrame MainWindow = new JFrame(); public static int CalcDamage(int Damage, int Armour){ int ReturnDamage = Damage - Armour + Damage / Damage + Armour / Damage * Damage - Armour + Damage + 25 ; if(ReturnDamage &lt; 0){ ReturnDamage = 0; } return ReturnDamage; } public static void main(String[] args) { // TODO Auto-generated method stub MainWindow.setSize(1500, 700); MainWindow.setTitle("Ampventure");; JPanel MPanel = (JPanel)MainWindow.getContentPane(); MPanel.setLayout(null); JPanel StatsPanel = new JPanel(); StatsPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK, 4)); StatsPanel.setSize(350, 450); StatsPanel.setLocation(0, 0); StatsPanel.setMaximumSize(new Dimension (350, 450)); MPanel.add(StatsPanel); JPanel InvPanel = new JPanel(); InvPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK, 4)); InvPanel.setSize(350, 212); InvPanel.setLocation(0, 450); StatsPanel.setMaximumSize(new Dimension (350, 250)); MPanel.add(InvPanel); JPanel DisplayPanel = new JPanel(); DisplayPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK, 4)); DisplayPanel.setSize(1135, 450); DisplayPanel.setLocation(350, 0); MPanel.add(DisplayPanel); JPanel ControlPanel = new JPanel(); ControlPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK, 4)); ControlPanel.setSize(1135, 212); ControlPanel.setLocation(350, 1135); MPanel.add(ControlPanel); MainWindow.setVisible(true); } } </code></pre> <p>What is is supposed to do: Split up the screen into four parts using JPanels</p> <p>What it does: Shows three of the panels, Stats, Inv, and Display, but not Control. </p> <p>NOTE! I have had this said to me before, so let me state this now. I have NO plans and DO NOT WANT to use a layout manager. The dimensions of this have to be very specific and I don't want to use tricks to just use a layout manager. Please keep this in mind when answering. It's okay if you mention it, but please don't outright say 'Use a layout manager' Thank you.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload