-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
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); | ||
} | ||
} | ||
|
||
|
||
|
||
|