Skip to content

Commit

Permalink
Added Panels
Browse files Browse the repository at this point in the history
  • Loading branch information
NMKrastev committed Jul 5, 2022
1 parent b5534b1 commit 73a6873
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 1 deletion.
1 change: 1 addition & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion 27-Labels/27-Labels.iml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager">
<output url="file://$MODULE_DIR$/out/production/" />
<output url="file://$MODULE_DIR$/out/production" />
<output-test url="file://$MODULE_DIR$/../out/test/27-Labels" />
<exclude-output />
<content url="file://$MODULE_DIR$">
Expand Down
13 changes: 13 additions & 0 deletions 28-Panels/28-Panels.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager">
<output url="file://$MODULE_DIR$/out/production/" />
<output-test url="file://$MODULE_DIR$/../out/test/28-Panels" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
Binary file added 28-Panels/out/production/Main.class
Binary file not shown.
41 changes: 41 additions & 0 deletions 28-Panels/src/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import javax.swing.*;
import java.awt.*;

public class Main {
public static void main(String[] args) {

//JPanel - a GUI component that functions as a container to hold other components

ImageIcon icon = new ImageIcon("ThumbsUp.png");

JLabel label = new JLabel();
label.setText("Hello");
label.setIcon(icon);
label.setVerticalAlignment(JLabel.BOTTOM);
label.setHorizontalAlignment(JLabel.RIGHT);

JPanel redPanel = new JPanel();
redPanel.setBackground(Color.red);
redPanel.setBounds(0, 0, 250, 250);

JPanel bluePanel = new JPanel();
bluePanel.setBackground(Color.blue);
bluePanel.setBounds(250, 0, 250, 250);

JPanel greenPanel = new JPanel();
greenPanel.setBackground(Color.green);
greenPanel.setBounds(0, 250, 500, 250);
greenPanel.setLayout(new BorderLayout());

JFrame frame = new JFrame();
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setLayout(null);
frame.setSize(750, 750);
frame.setVisible(true);
greenPanel.add(label);
frame.add(redPanel);
frame.add(bluePanel);
frame.add(greenPanel);

}
}
Binary file added ThumbsUp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 73a6873

Please sign in to comment.