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



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Shadab Ahmad Khan
ABC
0 Answer(s)      2 years and 4 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... procedure abc() BEGIN DECLARE x int DEFAULT 15; DECLARE y int DEFAULT 15... ;   Call Procedure To invoke a procedure 'abc', we use call
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
a procedure 'abc' using  create procedure statement. The select statement return you the 'Hello,World' ,whenever a procedure 'abc' is invoked... abc() BEGIN SELECT 'Hello,World' world'; END$$ delimiter
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 IN Parameters
illustrates an example, which create a procedure 'abc' and accept input... procedure abc(IN a int) BEGIN SET @x = a; END$$ delimiter.... call abc(123); Fetch variable value
SQL Out Parameter
an example from SQL Out Parameter .In this Example we create a procedure 'abc... procedure abc(OUT x int) BEGIN SET x = 10; END$$ delimiter ; Call Procedure call abc(@y); Fetch Value
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
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
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
 

 

 

DMCA.com