Wednesday, August 11, 2004

 

MikoBoyzzz Java Sched for August 14 2004

Hi peeps, I will be at these locations over the weekend..


8:00 am - 12:00 pm (University of the East Java Tutorial Track 2).

6:00 pm - 10:00 pm (STI Java / J2ME related discussions ) .

Tuesday, August 10, 2004

 

Review this for the Week...

Hello Class,


I want you to review Part2 to Part 4 of the Java tutorial Site that I gave... We will be doing the Sample programming this coming saturday..Considering that the schedule for the 21st was moved to September....

Also be familiar with Jcreator because that will be our default IDE at this moment...

And tell ur friends and schoolmates about how wonderful the world is gonna be with JAVA.. :D







Sunday, August 08, 2004

 

Swing Samples

------------------------------------
JRadioButtonTableExample.java
------------------------------------
import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.table.*;import javax.swing.event.*;
class RadioButtonRenderer implements TableCellRenderer { public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { if (value==null) return null; return (Component)value; }}
class RadioButtonEditor extends DefaultCellEditor implements ItemListener { private JRadioButton button;
public RadioButtonEditor(JCheckBox checkBox) { super(checkBox); }
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { if (value==null) return null; button = (JRadioButton)value; button.addItemListener(this); return (Component)value; }
public Object getCellEditorValue() { button.removeItemListener(this); return button; }
public void itemStateChanged(ItemEvent e) { super.fireEditingStopped(); }}
public class JRadioButtonTableExample extends JFrame {
public JRadioButtonTableExample(){ super( "JRadioButtonTable Example" ); UIDefaults ui = UIManager.getLookAndFeel().getDefaults(); UIManager.put("RadioButton.focus", ui.getColor("control"));
DefaultTableModel dm = new DefaultTableModel(); dm.setDataVector( new Object[][]{ {"Group 1",new JRadioButton("A")}, {"Group 1",new JRadioButton("B")}, {"Group 1",new JRadioButton("C")}, {"Group 2",new JRadioButton("a")}, {"Group 2",new JRadioButton("b")}}, new Object[]{"String","JRadioButton"}); JTable table = new JTable(dm) { public void tableChanged(TableModelEvent e) { super.tableChanged(e); repaint(); } }; ButtonGroup group1 = new ButtonGroup(); group1.add((JRadioButton)dm.getValueAt(0,1)); group1.add((JRadioButton)dm.getValueAt(1,1)); group1.add((JRadioButton)dm.getValueAt(2,1)); ButtonGroup group2 = new ButtonGroup(); group2.add((JRadioButton)dm.getValueAt(3,1)); group2.add((JRadioButton)dm.getValueAt(4,1)); table.getColumn("JRadioButton").setCellRenderer(new RadioButtonRenderer()); table.getColumn("JRadioButton").setCellEditor(new RadioButtonEditor(new JCheckBox())); JScrollPane scroll = new JScrollPane(table); getContentPane().add( scroll ); setSize( 200, 140 ); setVisible(true); }
public static void main(String[] args) { JRadioButtonTableExample frame = new JRadioButtonTableExample(); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); }}

Saturday, August 07, 2004

 

Swing Samples

----------------
InvisibleNodeTreeExample.java
-------------------

/* (swing1.1) */
import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.tree.*;import javax.swing.border.*;
/** * @version 1.0 01/12/99 */public class InvisibleNodeTreeExample extends JFrame { public InvisibleNodeTreeExample() { super("InvisibleNode TreeExample"); String[] strs = {"swing", // 0 "platf", // 1 "basic", // 2 "metal", // 3 "JTree"}; // 4 InvisibleNode[] nodes = new InvisibleNode[strs.length]; for (int i=0;i public static void main(String args[]) { InvisibleNodeTreeExample frame = new InvisibleNodeTreeExample(); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) {System.exit(0);} }); frame.setSize(300, 180); frame.setVisible(true); }}

 

Java Swing Codes....

Try These Swing Examples..

-------------------------
InvisibleTreeModel.java

-------------------------

/* (swing1.1) */
import javax.swing.tree.*;
/** * @version 1.0 01/12/99 */public class InvisibleTreeModel extends DefaultTreeModel {
protected boolean filterIsActive;
public InvisibleTreeModel(TreeNode root) { this(root, false); }
public InvisibleTreeModel(TreeNode root, boolean asksAllowsChildren) { this(root, false, false); }
public InvisibleTreeModel(TreeNode root, boolean asksAllowsChildren ,boolean filterIsActive) { super(root, asksAllowsChildren); this.filterIsActive = filterIsActive; }
public void activateFilter(boolean newValue) { filterIsActive = newValue; }
public boolean isActivatedFilter() { return filterIsActive; }
public Object getChild(Object parent, int index) { if (filterIsActive) { if (parent instanceof InvisibleNode) { return ((InvisibleNode)parent).getChildAt(index,filterIsActive); } } return ((TreeNode)parent).getChildAt(index); }
public int getChildCount(Object parent) { if (filterIsActive) { if (parent instanceof InvisibleNode) { return ((InvisibleNode)parent).getChildCount(filterIsActive); } } return ((TreeNode)parent).getChildCount(); }
}

----------------------
InvisibleNode.java
----------------------

/* (swing1.1) */
import java.util.*;import javax.swing.tree.*;
/** * @version 1.0 01/12/99 */public class InvisibleNode extends DefaultMutableTreeNode {
protected boolean isVisible;
public InvisibleNode() { this(null); }
public InvisibleNode(Object userObject) { this(userObject, true, true); }
public InvisibleNode(Object userObject, boolean allowsChildren , boolean isVisible) { super(userObject, allowsChildren); this.isVisible = isVisible; }
public TreeNode getChildAt(int index,boolean filterIsActive) { if (! filterIsActive) { return super.getChildAt(index); } if (children == null) { throw new ArrayIndexOutOfBoundsException("node has no children"); } int realIndex = -1; int visibleIndex = -1; Enumeration enum = children.elements(); while (enum.hasMoreElements()) { InvisibleNode node = (InvisibleNode)enum.nextElement(); if (node.isVisible()) { visibleIndex++; } realIndex++; if (visibleIndex == index) { return (TreeNode)children.elementAt(realIndex); } } throw new ArrayIndexOutOfBoundsException("index unmatched"); //return (TreeNode)children.elementAt(index); }
public int getChildCount(boolean filterIsActive) { if (! filterIsActive) { return super.getChildCount(); } if (children == null) { return 0; } int count = 0; Enumeration enum = children.elements(); while (enum.hasMoreElements()) { InvisibleNode node = (InvisibleNode)enum.nextElement(); if (node.isVisible()) { count++; } } return count; }
public void setVisible(boolean visible) { this.isVisible = visible; } public boolean isVisible() { return isVisible; }
}

----------------------------------
InvisibleNodeTreeExample.java
----------------------------------


/* (swing1.1) */
import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.tree.*;import javax.swing.border.*;
/** * @version 1.0 01/12/99 */public class InvisibleNodeTreeExample extends JFrame { public InvisibleNodeTreeExample() { super("InvisibleNode TreeExample"); String[] strs = {"swing", // 0 "platf", // 1 "basic", // 2 "metal", // 3 "JTree"}; // 4 InvisibleNode[] nodes = new InvisibleNode[strs.length]; for (int i=0;i public static void main(String args[]) { InvisibleNodeTreeExample frame = new InvisibleNodeTreeExample(); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) {System.exit(0);} }); frame.setSize(300, 180); frame.setVisible(true); }}





 

Java Talk on UE 08/07/2004..

I will be together with my colleague for an Intro discussion to java tomorrow.... Well, I have news that all slots are taken.... Like the beatles huh ! :D hehehe

This page is powered by Blogger. Isn't yours?