Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
SAM21004 authored Oct 22, 2024
1 parent 1bfc243 commit 88910a0
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions SDPPython/GUIexample.java
Original file line number Diff line number Diff line change
@@ -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);
}
}




0 comments on commit 88910a0

Please sign in to comment.