The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
ColorChange
Posted by: ColorChange | March 9, 2010 @ 7:02am
Java Code
[
Download
]
package szut.org.ColorChange; import java.awt.BorderLayout; import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JSeparator; import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.WindowConstants; import javax.swing.border.LineBorder; import javax.swing.SwingUtilities; /** * This code was edited or generated using CloudGarden's Jigloo * SWT/Swing GUI Builder, which is free for non-commercial * use. If Jigloo is being used commercially (ie, by a corporation, * company or business for any purpose whatever) then you * should purchase a license for each developer using Jigloo. * Please visit www.cloudgarden.com for details. * Use of Jigloo implies acceptance of these licensing terms. * A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR * THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED * LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE. */ public class ColorChange extends javax.swing.JFrame { private JTextField txtFieldColor; private JSeparator jSeparator1; private JTextArea colorTxtArea; private JButton colorButton; /** * Auto-generated main method to display this JFrame */ public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { ColorChange inst = new ColorChange(); inst.setLocationRelativeTo(null); inst.setVisible(true); } }); } public ColorChange() { super(); initGUI(); } private void initGUI() { try { setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); getContentPane().setLayout(null); this.setTitle("COLOOORS!"); { txtFieldColor = new JTextField(); getContentPane().add(txtFieldColor); txtFieldColor.setBounds(17, 227, 91, 25); } { colorButton = new JButton(); getContentPane().add(colorButton); colorButton.setText("Color me!"); colorButton.setBounds(279, 228, 91, 23); colorButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { colorButtonActionPerformed(evt); } }); } { colorTxtArea = new JTextArea(); getContentPane().add(colorTxtArea); colorTxtArea.setBounds(17, 12, 353, 210); colorTxtArea.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false)); } { jSeparator1 = new JSeparator(); getContentPane().add(jSeparator1); jSeparator1.setBounds(0, 260, 392, 10); } pack(); setSize(400, 300); } catch (Exception e) { e.printStackTrace(); } } private void colorButtonActionPerformed(ActionEvent evt) { System.out.println("colorButton.actionPerformed, event="+evt); String s = txtFieldColor.getText(); if(s.equals("Blau")){ colorTxtArea.setBackground(new Color (0, 128, 255)); }else if(s.equals("Rot")){ colorTxtArea.setBackground(new Color (255, 0, 0)); }else if(s.equals("Gr�n")){ colorTxtArea.setBackground(new Color (0, 255, 0)); }else{ s.equals("Rot");colorTxtArea.setBackground(new Color (0, 128, 255)); } } }
Syntax Highlighting
[
Open in new window
]
Author Comments
none
Rating
4.58 / 8
43 Votes