diff --git a/SDPPython/GUIexample.java b/SDPPython/GUIexample.java new file mode 100644 index 0000000..853c4b5 --- /dev/null +++ b/SDPPython/GUIexample.java @@ -0,0 +1,65 @@ +import javax.swing.*; +import java.awt.*; + +public class GUIexample { + public static void main(String[] args) { + // Create the main frame with a title + JFrame frame = new JFrame("Integrated Circuit Test System"); + frame.setSize(250, 250); // Set the size 250 pixels wide and 250 pixels tall + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + // Set background color + frame.getContentPane().setBackground(new Color(166, 184, 150)); + + // Use GridBagLayout for responsive/resizable components + frame.setLayout(new GridBagLayout()); + GridBagConstraints gbc = new GridBagConstraints(); + gbc.fill = GridBagConstraints.HORIZONTAL; + gbc.insets = new Insets(10, 10, 10, 10); // Padding + + // Create a label + JLabel instructionsLabel = new JLabel(""); + gbc.gridx = 0; // Column 0 + gbc.gridy = 0; // Row 0 + gbc.gridwidth = 2; // Span 2 columns + frame.add(instructionsLabel, gbc);// Add the label to the window + + // rounded corners/color for button + class RoundedButton extends JButton { + public RoundedButton(String label) { + super(label); + setBackground(new Color(125, 154, 104));//green + } + + @Override + protected void paintComponent(Graphics g) { + Graphics2D g2 = (Graphics2D) g.create(); + g2.setColor(getBackground()); + g2.fillRoundRect(0, 0, getWidth(), getHeight(), 20, 20); // Rounded corners + super.paintComponent(g); + } + + @Override + public void setContentAreaFilled(boolean b) { + super.setContentAreaFilled(b); + } + } + + // Create the Identify Chip button with rounded corners + RoundedButton identifyButton = new RoundedButton("Identify Chip"); + gbc.gridx = 0; + gbc.gridy = 2; + gbc.gridwidth = 1; + gbc.fill = GridBagConstraints.NONE; // Keep button size fixed + gbc.weightx = 0; + gbc.weighty = 0; + frame.add(identifyButton, gbc);// Add the button + + // Make the frame visible + frame.setVisible(true); + } +} + + + +