Created
March 1, 2023 19:01
-
-
Save dahool/d07d8b637ac8c1cfead1e301a0d2a5e9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyPanel extends JPanel { | |
private JLabel jcomp1; | |
private JLabel jcomp2; | |
private JLabel statusPrinter; | |
private JLabel statusPinpad; | |
public MyPanel() { | |
//construct components | |
jcomp1 = new JLabel ("Impresora"); | |
jcomp2 = new JLabel ("PinPad"); | |
statusPrinter = new JLabel ("-"); | |
statusPinpad = new JLabel ("-"); | |
//adjust size and set layout | |
setPreferredSize (new Dimension (262, 94)); | |
setLayout (null); | |
//add components | |
add (jcomp1); | |
add (jcomp2); | |
add (statusPrinter); | |
add (statusPinpad); | |
//set component bounds (only needed by Absolute Positioning) | |
jcomp1.setBounds (10, 20, 70, 25); | |
jcomp2.setBounds (10, 55, 75, 25); | |
statusPrinter.setBounds (85, 20, 165, 25); | |
statusPinpad.setBounds (85, 50, 170, 25); | |
} | |
public static void main (String[] args) { | |
JFrame frame = new JFrame ("MyPanel"); | |
frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); | |
frame.getContentPane().add (new MyPanel()); | |
frame.pack(); | |
frame.setVisible (true); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment