Latest Tutorials| Questions and Answers|Ask Questions?|Site Map




Have Programming Question? Ask it here!
 
 
 


Shadab Ahmad Khan
ABC
0 Answer(s)      a year and 11 months ago
Posted in : HTML


package threeDAssignment;

import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.ActionListener;

import javax.swing.Box; import javax.swing.DefaultComboBoxModel; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JLabel;

@SuppressWarnings("serial") public class LayerOptionDialog extends JDialog implements ActionListener {

public LayerOptionDialog(JFrame owner, String title) {
    super(owner,title);

    setSize(350, 150);

    setLocation(new Point(0, owner.getHeight()-155));

    setResizable(false);

    grid=((DisplayUI)owner).getGrid();

    canvas=((DisplayUI)owner).getCanvas();

    createDialog();

    addListeners();
}

private void addListeners() {
    cmbDirection.addActionListener(this);
    cmbLayer.addActionListener(this);

    btnBack.addActionListener(this);
    btnForward.addActionListener(this);
    btnFastBack.addActionListener(this);
    btnFastForward.addActionListener(this);
    btnStop.addActionListener(this);

    btnReset.addActionListener(this);
    btnClose.addActionListener(this);
}

@Override
public void actionPerformed(ActionEvent e) {
    Object source=e.getSource();

    if(source.equals(cmbDirection))
    {
        if(cmbDirection.getSelectedIndex()>0){
            DefaultComboBoxModel cmbLayerModel=(DefaultComboBoxModel)cmbLayer.getModel();
            cmbLayerModel.removeAllElements();

            if(cmbDirection.getSelectedIndex()==1){
                int NX=grid.getNX();
                for(int i=1; i<=NX; i++){
                    cmbLayerModel.addElement(i);
                }
            }else if(cmbDirection.getSelectedIndex()==2){
                int NY=grid.getNY();
                for(int i=1; i<=NY; i++){
                    cmbLayerModel.addElement(i);
                }
            }
            else if(cmbDirection.getSelectedIndex()==3){
                int NZ=grid.getNZ();
                for(int i=1; i<=NZ; i++){
                    cmbLayerModel.addElement(i);
                }
            }

            cmbLayer.repaint();
        }else{
            DefaultComboBoxModel cmbLayerModel=(DefaultComboBoxModel)cmbLayer.getModel();
            cmbLayerModel.removeAllElements();
            cmbLayer.repaint();
        }
    }
    else if(source.equals(cmbLayer)){
        showGridLayer(0);

    }

    else if(source.equals(btnForward)){
        showGridLayer(1);
    }
    else if(source.equals(btnBack)){
        showGridLayer(-1);
    }
    else if (source.equals(btnFastForward)) {
        isStop=false;
        if (cmbDirection.getSelectedIndex() > 0) {
                Thread t = new Thread(new Runnable() {

                    @Override
                    public void run() {
                        while (Integer.parseInt(cmbLayer.getSelectedItem().toString()) < ((cmbDirection.getSelectedIndex()==1)?grid.getNX():((cmbDirection.getSelectedIndex()==2)?grid.getNY():grid.getNZ()))) {
                            if(isStop)
                                return;
                            showGridLayer(1);
                            if(Integer.parseInt(cmbLayer.getSelectedItem().toString()) == ((cmbDirection.getSelectedIndex()==1)?grid.getNX():((cmbDirection.getSelectedIndex()==2)?grid.getNY():grid.getNZ()))){
                                return;
                            }
                            try {
                                Thread.sleep(300);
                            } catch (InterruptedException e1) {
                                e1.printStackTrace();
                            }
                        }
                    }
                });
                t.start();
        }
    }
    else if (source.equals(btnFastBack)) {
        isStop=false;
        if (cmbDirection.getSelectedIndex() > 0) {
            Thread t = new Thread(new Runnable() {

                    @Override
                    public void run() {
                        while (Integer.parseInt(cmbLayer.getSelectedItem().toString()) > 0) {
                            if(isStop)
                                return;
                            showGridLayer(-1);
                            if(Integer.parseInt(cmbLayer.getSelectedItem().toString())==1)
                                return;
                            try {
                                Thread.sleep(300);
                            } catch (InterruptedException e1) {
                                e1.printStackTrace();
                            }
                        }
                    }
                });
                t.start();
        }
    }
    else if(source.equals(btnReset)){
        cmbDirection.setSelectedIndex(0);
        DefaultComboBoxModel cmbLayerModel=(DefaultComboBoxModel)cmbLayer.getModel();
        cmbLayerModel.removeAllElements();
        cmbLayer.repaint();
        canvas.showLayer(0);
    }
    else if(source.equals(btnClose)){
        this.dispose();
    }
    else if(source.equals(btnStop)){

// t.interrupt(); isStop=true; } }

private void showGridLayer(int i) {
    if(cmbDirection.getSelectedIndex()>0){
        DefaultComboBoxModel cmbLayerModel=(DefaultComboBoxModel)cmbLayer.getModel();
        if(cmbLayerModel.getSize()>0){
            int layer=Integer.parseInt(cmbLayer.getSelectedItem().toString());
            if(cmbDirection.getSelectedIndex()==1){

                if((layer+i)<=grid.getNX() && (layer+i)>0){
                    canvas.showLayer(layer+i);
                    cmbLayer.setSelectedItem(layer+i);
                }

            }else if(cmbDirection.getSelectedIndex()==2){

                if((layer+i)<=grid.getNY() && (layer+i)>0){
                    canvas.showLayer(grid.getNX()+layer+i);
                    cmbLayer.setSelectedItem(layer+i);
                }
            }else if(cmbDirection.getSelectedIndex()==3){

                if((layer+i)<=grid.getNZ() && (layer+i)>0){
                    canvas.showLayer(grid.getNX()+grid.getNY()+layer+i);
                    cmbLayer.setSelectedItem(layer+i);
                }
            }
        }
    }else{
        canvas.showLayer(0);
    }
}

private void createDialog() {
    setLayout(new GridBagLayout());
    GridBagConstraints gbc=new GridBagConstraints();

    Insets ins=new Insets(10, 2, 10, 2);

    gbc.anchor=GridBagConstraints.FIRST_LINE_START;
    gbc.fill=GridBagConstraints.BOTH;
    gbc.insets=ins;

    gbc.gridx=0;
    gbc.gridy=0;
    add(new JLabel("Direction :"),gbc);

    cmbDirection=new JComboBox(new Object[]{"Select","X-Direction","Y-Directiion","Z-Direction"});
    gbc.gridx=1;
    gbc.gridwidth=2;
    add(cmbDirection,gbc);

    gbc.gridx=2;
    gbc.gridwidth=1;
    add(Box.createHorizontalStrut(10),gbc);

    gbc.gridx=3;
    add(new JLabel("   Layer :"),gbc);

    cmbLayer=new JComboBox();
    gbc.gridx=4;
    add(cmbLayer,gbc);

    btnFastBack=new JButton("<<<");
    gbc.gridx=0;
    gbc.gridy=1;
    add(btnFastBack,gbc);

    btnBack=new JButton("<<");
    gbc.gridx=1;
    add(btnBack,gbc);

    btnStop=new JButton("...");
    gbc.gridx=2;
    add(btnStop,gbc);

    btnForward=new JButton(">>");
    gbc.gridx=3;
    add(btnForward,gbc);

    btnFastForward=new JButton(">>>");
    gbc.gridx=4;
    add(btnFastForward,gbc);

    gbc.gridx=0;
    gbc.gridy=2;
    gbc.gridwidth=2;
    add(Box.createHorizontalStrut(50),gbc);

    btnReset=new JButton("Reset");
    gbc.gridx=1;
    gbc.gridwidth=1;
    add(btnReset,gbc);

    gbc.gridx=2;
    add(Box.createHorizontalStrut(50),gbc);

    btnClose=new JButton("Close");
    gbc.gridx=3;
    add(btnClose,gbc);
}

private Grid grid;
private ThreeDCanvas canvas;

private JComboBox cmbLayer;
private JComboBox cmbDirection;

private JButton btnBack;
private JButton btnForward;
private JButton btnFastBack;
private JButton btnFastForward;
private JButton btnStop;
private JButton btnReset;
private JButton btnClose;

private boolean isStop=false;

}


Advertisement
View Answers

Related Tutorials/Questions & Answers:
ABC
ABC
Advertisements
Access denied for user 'abc'@'xxxx' (using password: YES)
Access denied for user 'abc'@'xxxx' (using password: YES)  I have tested my code on local machine DB, its working correctly.. But when i shifted it to server DB using URL, Username and password.. i got this error .. How can i
String st="abc bca cab acb bac cba acb " ; But out put as ab ab ab ab ab ab how to get it?
String st="abc bca cab acb bac cba acb " ; But out put as ab ab ab ab ab ab how to get it?  String st="abc bca cab acb bac cba acb " ; I want print as ab ab ab ab ab ab ab How to do
Use DEFAULT Statement in Procedure
a procedure 'abc'. The BEGIN statement  indicate the beginning of an SQL declare...;   delimiter $$ create procedure abc() BEGIN DECLARE x... a procedure 'abc', we use call abc ( ) given below: call abc
Login.mxml
that the userid should be roseindia and password is abc, if someone enter wrong...=pass.text.toLowerCase();   if((u==''||u!='roseindia')||(p==''||p!='abc'))  
format
format  Abcdcba Abc cba Ab ba A a Ab ba Abc cba Abcdcba
JAVA - Java Beginners
JAVA  I want to read the content of file "a.cfg" such that If a.cfg contains abc = xyz then value of xyz should be stored in abc variable
pointer to a reference
[]) { int abc = 0; foo1(abc); cout << abc << "\n"; abc = 0; foo2(&abc); cout << abc << "\n"; return 0
pointer to a reference
[]) { int abc = 0; foo1(abc); cout << abc << "\n"; abc = 0; foo2(&abc); cout << abc << "\n"; return 0
String Ques
String Ques  what is difference between String str="abc"; and String str=new String("abc");   Hello Friend, Differences: 1)String str=new string("abc") creates two objects, one in heap memory and one in string
Simple Procedure to display Hello World
'abc' using  create procedure statement. The select statement return you the 'Hello,World' ,whenever a procedure 'abc' is invoked. Create a Procedure delimiter $$ create procedure abc() BEGIN SELECT
pattern program
pattern program  can some one plz help me to wright the logic for the following pattern abcdcba abc cba ab ba a a ab ba abc cba abcdcba
I have need to help
I have need to help  Write a program that, for four points A, B, C and P, draws a triangle formed by ABC and a small cross showing the position of P... applies: a) P lies inside ABC b) P lies outside ABC Or c) P lies on an edge of ABC
String - Java Interview Questions
String  i have a String s1="abc"; String s2="123"; then how to get a String s3="a1b2c3
strrrrr - Java Beginners
for passing value one page to another page but this is return null string abc=request.getParameter("TOT"); out.println("=abc" + abc); print the value abc=null; when TOT=20 i want to abc=20 in another jsp page please
Simple Procedure to display Hello World
'abc' using  create procedure statement. The select statement return you the 'Hello,World' ,whenever a procedure 'abc' is invoked. Create... procedure abc() BEGIN SELECT 'Hello,World' world'; END$$ delimiter
array to string
array to string  hello how to assign value from array to string. nsstring *abc = [array objectAtindex:1];   you can use this code NSString *abc = [NSString stringWithString:[array objectAtIndex:i]]; where i
servlet and xml - XML
://localhost:8080/webapp/form.html. in web.xml: abc myservlet abc /url
how to call the array variable in scriptlet from javascript function
how to call the array variable in scriptlet from javascript function  This is the scriptlet code:- <% String[] abc={"saab","volvo","bmw","Benz...() { alert("hi"); var x='<%= abc[0]%>'; alert(abc[0]); for (i=0;i
pattern program
before.anyways the pattern goes like this abcdcba abc cba ab ba a a ab ba abc abc
hi - Java Beginners
Friend, Try the following code: class ABC { public int i=10; } public class TestABC { public static void main (String [] arg) { ABC test=new ABC
java - JDBC
character strings. All string literals in Java programs, such as "abc", are implemented... = "abc"; is equivalent to: char data[] = {'a', 'b', 'c... of how strings can be used: System.out.println("abc
SQL Out Parameter
from SQL Out Parameter .In this Example we create a procedure 'abc... $$ create procedure abc(OUT x int) BEGIN SET x = 10; END$$ delimiter ; Call Procedure call abc(@y); Fetch Value
SQL Out Parameter
from SQL Out Parameter .In this Example we create a procedure 'abc... Procedure delimiter $$ create procedure abc(OUT x int... abc(@y); Fetch Value Select @y; Result
SQL IN Parameters
an example, which create a procedure 'abc' and accept input parameter...; Create Procedure delimiter $$ create procedure abc... Procedure name is used to execute the procedure. call abc(123
Java Program
Java Program  i have a String like ABCD, my output should be as below a,bcd ab,cd abc,d a,b,cd a,bc,d ab,c,d a,b,c,d
CORE JAVA
CORE JAVA  Iā??ve a string like below String xyz =ā??nullā??; I want to compare xyz with space which is in other String ABC. What will be the output
Why we are writting public static void main(String args[])?
Why we are writting public static void main(String args[])?  Why we are writting public static void main(String args[])? please elaborate it... and also explain the statement System.out.println("abc
problem on strings
problem on strings  in string1 "123456 ABC DEF...",IN string2 "raveen". iwant to add string2 after 123456 in the first string based on index number.i need logic for this with out using StringBuffer concept. Thanks in advanace
strings concatnation
strings concatnation  in string1 "123456 ABC DEF...",IN string2 "raveen". iwant to add string2 after 123456 in the first string based on index number.i need logic
expression language array
expression language array  var test='${abc.myarray}'; //myarray is string array in bean //abc How to get the length of myarray? I tried test.length which does not work
how to find the sum of integers in a string of sentence in java
how to find the sum of integers in a string of sentence in java  how to find the sum of integers in a string of sentence in java for e.g:--> abc d 2 3 21 the output should be 2+3+21=26
package
package  by what name we can save a java file that contain a package {i.e package p;} and several public classes {i.e public class abc} but not a main method
SimpleQuestionR
SimpleQuestionR  //why is the output of the program exp1 and 3?whts this concept about ?? class Exp { public int x=3; public void abc...; } public void abc() { x+=5; System.out.println("the method of exp1
Replace
Replace   Hi, I have two text files in two diff locatons.The text file like below using java program 1)a.txt 1 abc bangalore 2 def... format a.txt A abc bangalore B def adfsdf C ghij asdfdsad
Replace TEXT
Replace TEXT   I have two text files in two diff locatons.The text file like below using java program 1)a.txt 1 abc bangalore 2 def... format a.txt A abc bangalore B def adfsdf C ghij asdfdsad
Conversion from string data type into different data types.
Conversion from string data type into different data types.  string str="World id Beutifull"; char chr[20]; char* chrctr ; Qustion is -How to store the 'str' value in 'chr' and 'chrctr'? int abc; sprintf(abc ,"%s",str
Exercise - Delete Blanks
Java: Exercise - Delete Blanks Write a method to delete all blanks from its parameter. The method signature is public static String deblank(String s); Sample output deblank("abc") returns "abc" (ie, no changes
Use DEFAULT Statement in Procedure
a procedure 'abc'. The BEGIN statement  indicate the beginning of an SQL declare...;       delimiter $$ create procedure abc... Procedure To invoke a procedure 'abc', we use call abc ( ) given below
SQL IN Parameters
an example, which create a procedure 'abc' and accept input parameter... $$ create procedure abc(IN a int) BEGIN SET @x = a; END$$ delimiter.... call abc(123); Fetch variable value Fetch
String Expressions
: String a = "abc"; String h = "Hello"; String name = "Michael Maus"; Show what...") ); __________ System.out.println( a.equals("ABC") ); __________ System.out.println( a.equalsIgnoreCase("ABC") ); __________ System.out.println( a.substring(1,3
PLZ HELP ME. i need php code.
PLZ HELP ME. i need php code.   I want php code for bellow OUTPUT. output is just example but it must be letters only. abc bcd efg jku rgt azs hje qqc wws adt
How many objects are created in the code below? Explain.
How many objects are created in the code below? Explain.  Hi, Here is my code public static void main(String[] args) {String s1 = "abc"; StringBuffer s2 = new StringBuffer(s1); StringBuffer s3= s2; StringBuffer s4 = new
Java code
Java code  hi, please suggest me how to extract table name and find the no of select statement and insert statement from a file and dispaly the result of SELECT and INSERT tablewise i.e. abc_table SELECT 4 pgm_table
how to use StringTokenizer to retrieve the class name, attributes name and methods name from the Java Source Code
of codes. Thx! import java.util.*; import java.io.*; public class Abc { private String filename; private int count; Abc( String name ) { filename...{ Abc x; x = new Abc ( "Abc.java" ); x.readFile
Java Interface
Java Interface  Can an Interface have an inner class?  Yes, interface can have inner class. for example- public interface gyan { static int i = 0; void abc(); class test { test() { System.out.println
decryption and encryption - Java Beginners
decryption and encryption  hi everyone. my question is that i have one problem which i have to solve and the issue is that i have to do the encryption and decryption thing there in my code, e.g if the user enters the abc the code
object creation - MobileApplications
object creation  hi m creating a mobile appliction J2me in which i wud like to call another class wen user clicks on login ..but wen tried to put this code : if(username == abc && password==123) { classname obj = new
hi - Java Beginners
" It means the object created is of the class type. class Abc { int a=0; // instance variable } Abc abc = new Abc(); abc.a // object variable
 

 

 

DMCA.com