•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 422,379 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,725 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
A simple GUI that tests the GridLayout function, multiple panels, and different coloured panels.
Last edited : Jun 13th, 2007.
// Arman Majumder // Induced Contrast GUI import java.awt.*; import java.awt.event.*; import java.util.*; import java.io.*; import javax.swing.*; class Illusion extends JPanel { public Illusion(Color backColor) { setBackground(backColor); } public void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(Color.gray); g.fillRect(50, 50, 100, 100); } } public class InducedContrast { public static void main(String [] args) { JFrame theGUI = new JFrame(); theGUI.setTitle("Induced Contrast"); theGUI.setSize(400, 250); theGUI.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Illusion panel = new Illusion(Color.black); JPanel panel1 = new Illusion(Color.black); panel1.setPreferredSize(new Dimension(200, 200)); JPanel panel2 = new Illusion(Color.white); Container pane = theGUI.getContentPane(); pane.setLayout(new GridLayout(1, 2)); pane.add(panel1); pane.add(panel2); theGUI.setVisible(true); } }
Post Comment
•
•
•
•
DaniWeb Marketplace (Sponsored Links)