Having some problems with drawing my panels
Hi, I'm new to all this gui stuff. I'm trying to make my panels from objects in my frame, but I get an empty window.. I'll post my classes, hopefully they're pretty self explanatory (and it's simple stuff too). I'm calling the method launchGui from another class somewhere else in the system. No exceptions or anything, just an empty gui. Thanks in advance.
Gui.java
package gui;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
publicclass Guiextends JPanel{
publicstaticvoid launchGui(){
JFrame frame =new JFrame("ID7 Simulator");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JComponent gui =new Gui();
gui.setVisible(true);
gui.setSize(350,100);
frame.setContentPane(gui);
frame.pack();
frame.setVisible(true);
}
publicvoid Gui(){
setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
TerminalPanel terminalPanel =new TerminalPanel();
WeightPanel weightPanel =new WeightPanel();
add(terminalPanel);
add(weightPanel);
}
publicvoid actionPerformed(ActionEvent e){
System.exit(0);
}
}
DisplayPanel.java
package gui;
import java.awt.*;
import javax.swing.*;
publicclass DisplayPanelextends JPanel{
publicvoid DisplayPanel(){
setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
JTextField nettoWeight =new JTextField(25);
JTextField inputField =new JTextField(25);
JButton bTara =new JButton("(T)");
add(inputField);
add(nettoWeight);
add(bTara);
}
}
NumericPanel.java
package gui;
import java.awt.*;
import javax.swing.*;
publicclass NumericPanelextends JPanel{
publicvoid NumericPanel(){
setLayout(new GridLayout(4,3));
//Generating Buttons
JButton b1 =new JButton("1");
JButton b2 =new JButton("2");
JButton b3 =new JButton("3");
JButton b4 =new JButton("4");
JButton b5 =new JButton("5");
JButton b6 =new JButton("6");
JButton b7 =new JButton("7");
JButton b8 =new JButton("8");
JButton b9 =new JButton("9");
JButton bClear =new JButton("Clear");
JButton b0 =new JButton("0");
JButton bEnter =new JButton("Enter");
setLayout(new GridLayout(4,3));
add(b1);
add(b2);
add(b3);
add(b4);
add(b5);
add(b6);
add(b7);
add(b8);
add(b9);
add(bClear);
add(b0);
add(bEnter);
}
}
TerminalPanel.java
package gui;
import java.awt.*;
import javax.swing.*;
publicclass TerminalPanelextends JPanel{
publicvoid TerminalPanel(){
DisplayPanel displayPanel =new DisplayPanel();
NumericPanel numericPanel =new NumericPanel();
add(numericPanel);
add(displayPanel);
}
}
WeightPanel.java
package gui;
import javax.swing.*;
import java.awt.*;
publicclass WeightPanelextends JPanel{
publicvoid WeightPanel(){
SpinnerModel nettoWeightModel =new SpinnerNumberModel(
main.Main.nettoWeight,//initial value
-50,// Lower Boundary
50,// Upper boundary
0.5);//step size
JSpinner weight =new JSpinner(nettoWeightModel);
add(weight);
}
}
Message was edited by:
hogl
Message was edited by:
hogl

