View RSS Feed

All Blog Entries

  1. Look of a Calculator

    by , 12-30-2011 at 06:37 PM
    Java Code:
    package myPackage;
    
    import java.awt.BorderLayout;
    import java.awt.FlowLayout;
    import java.awt.GridLayout;
    
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    
    public class SimpleCalculator {
    
    	public static void main(String[] args) 
    	{
    		JFrame myFrame = new JFrame( "Testing" );
    ...
    Categories
    Uncategorized
  2. A Simple GridLayout Example

    by , 12-29-2011 at 01:12 AM
    Java Code:
    package myPackage;
    
    import java.awt.Container;
    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    
    import javax.swing.JButton;
    import javax.swing.JFrame;
    
    public class GridLayoutFrame extends JFrame implements ActionListener
    {
    	
    	private JButton[] buttons; // array of buttons
    	private static final String[] names = {"one", "two", "three"
    ...
    Categories
    Uncategorized
  3. JList Multiple Selection and Copying with a Button to Another JList Example

    by , 12-28-2011 at 11:33 PM
    Java Code:
    package myPackage;
    
    import java.awt.FlowLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JList;
    import javax.swing.JScrollPane;
    import javax.swing.ListSelectionModel;
    
    public class MultipleSelectionFrame extends JFrame 
    {
    	private static final long	serialVersionUID	= 1L;
    	private JList colorJList;
    ...
    Categories
    Uncategorized
  4. JList Example

    by , 12-28-2011 at 12:17 AM
    Java Code:
    package myPackage;
    
    import java.awt.FlowLayout;
    import java.awt.GridLayout;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JList;
    import javax.swing.JScrollPane;
    import javax.swing.ListSelectionModel;
    import javax.swing.event.ListSelectionEvent;
    import javax.swing.event.ListSelectionListener;
    
    public class ListFrame extends JFrame
    {
    	JList myJList;
    	String[] colorrs;
    ...
    Categories
    Uncategorized
  5. Compilation of better code advice

    by , 12-27-2011 at 11:14 PM
    Writing Better Java Code
    This is a compilation of advice on writing more efficient Java code. Whenever I find more I'll add them to the list. If you spot something fishy do say so, so that I will correct it.

    Faster code:
    1. Use integer instead of long (long is a 64bit integer, most processors are 32bit so operations can run 2-4 times faster with an int)
    2. Use local variables instead of class members
    3. Use shorthand when evaluation booleans
    Java Code:
    return
    ...

    Updated 12-27-2011 at 11:26 PM by ozzyman

    Categories
    Uncategorized
  6. [SOLVED] optionwindow

    by , 12-26-2011 at 08:20 PM
    Quote Originally Posted by keffie91 View Post
    Hello I have created an optionwindow for my chat program, but if i open the option window and click the cross in the right corner, not only the optionwindow terminates but also the chatprogram. Can someone tell what i can do about it, and are there other ways to make a kind of optionwindow?

    thanks keffie91

    this is the source:

    ChatProgram.java
    Java Code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    ...
    Categories
    Uncategorized
  7. A simple GUI code

    by , 12-18-2011 at 02:25 PM
    Java Code:
    package myPackage;
    import java.awt.Color;
    import java.awt.FlowLayout;
    import javax.swing.*;
    @SuppressWarnings("serial")
    public class SamsLearning extends JFrame {
    	public SamsLearning() {
    		super();
    		this.setTitle("My Title");
    		this.setLookAndFeel();
    		this.setSize(500,500);
    		MyButtonClass myButton = new MyButtonClass("Play");
    		MyButtonClass myButton2 = new MyButtonClass("Stop");
    ...
    Categories
    Uncategorized
Page 29 of 48 FirstFirst ... 19272829303139 ... LastLast