Android Open Source - MobileDev_beginner Check Box Test






From Project

Back to project page MobileDev_beginner.

License

The source code is released under:

This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a co...

If you think the Android project MobileDev_beginner listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/**
 * @(#)CheckBoxTest.java//from www  . j  ava 2 s .c o m
 *
 *
 * @author
 * @version 1.00 2014/7/14
 */
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class CheckBoxTest extends JFrame {
  private JTextField field1;
  private JCheckBox bold, italic;

  //set GUI
    public CheckBoxTest() {
      super ("JCheckBox Test");

      //get content pane
      Container container = getContentPane();
      container.setLayout( new FlowLayout() );

      //set up JTextField
      field1 = new JTextField("Hohohoho", 20);
      field1.setFont( new Font("Serif", Font.PLAIN, 14));
      container.add(field1);

      //create checkbox objects
      bold = new JCheckBox ("Bold");
      container.add( bold);

      italic = new JCheckBox ("Italic");
      container.add( italic);

      //register listenenr
      CheckBoxHandler handler = new CheckBoxHandler();
      bold.addItemListener( handler);
      italic.addItemListener( handler);

      setSize( 275, 100);
      setVisible (true);
    }

    public static void main (String[] args) {
      CheckBoxTest app = new CheckBoxTest();
      app.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE);
    }

    //private inner class
    private class CheckBoxHandler implements ItemListener {
      private int valBold = Font.PLAIN;
      private int valItalic = Font.PLAIN;

      public void itemStateChanged( ItemEvent event) {

        if ( event.getSource() == bold )
          valBold = bold.isSelected() ? Font.BOLD : Font.PLAIN;

        if ( event.getSource() == bold )
          valItalic = italic.isSelected() ? Font.ITALIC : Font.PLAIN;

        //set text field
        field1.setFont( new Font( "Serif", valBold + valItalic, 14) );
      }
    }


}




Java Source Code List

.CheckBoxTest.java
.Demo.java
.ListTest.java
.OurServlet.java
.TextFieldTest.java
com.corruptor.smssender.smsMenu.java
com.example.login.insidemenu.java
com.example.login.loginact.java
org.corruptor.Booking.java
org.corruptor.Car.java
org.corruptor.Customer.java
org.corruptor.Login.java
org.corruptor.Menu.java
org.corruptor.MyConnection.java
org.corruptor.MyMain.java
org.corruptor.MyScanner.java
org.corruptor.Reports.java