Dynamically update the Label & set Bounds constant between 2 Label(Thread)

Dynamically update the Label & set Bounds constant between 2 Label(Thread)

strong textpackage xcada; import com.mysql.jdbc.Connection; import com.mysql.jdbc.PreparedStatement; import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.sql.ResultSet; import javax.swing.JButton; import javax.swing.JLabel;

public class MyNew3 extends javax.swing.JFrame { private int q; private String r; private String data[ ]={ }; private String tagNo; private String findTagNo[ ]={ }; private JButton button1[]; private int m=0; private String t3=""; private String str5=""; private String t2="";

    public  MyNew3( String t2,String t3,int q)
    {
    initComponents();
    this.q=q;
    this.t2=t2;
    this.t3=t3;
     StringThread th = new StringThread ();
      th.start();





}
MyNew3() {

}

private JLabel createlabel(int i,String tagNo) { final String tagNo1=tagNo; System.out.println(""+i); JLabel label1= new JLabel();

   this.button1[i]=new JButton();

    this.jPanel1.add(label1);//***Here is error coming..***
  // System.out.println("I m not here");
     System.out.println("I m here");
   jPanel1.add(button1[i]);
   label1.setText(data[i]);
   button1[i].setText("Update");
   label1.setBounds(110,100+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i, 375, 20);
   button1[i].setBounds(110,120+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i, 75, 15);
   label1.setFont(new Font("Tahoma", Font.BOLD, 14));


   button1[i].addActionListener(new ActionListener(){


        @Override
        public void actionPerformed(ActionEvent e) {



            MyNew4 form4=new MyNew4(tagNo1);

                                                   }




});
   return label1;
  //return button1;

}

public void display() {

       try
    {   
           Connection con=(Connection) ConnectionFactory.getConnection();
           String sql1="SELECT * FROM people";
           PreparedStatement ps2=(PreparedStatement) con.prepareStatement(sql1);
           ResultSet rs2=ps2.executeQuery();
           System.out.println(rs2);
           while(rs2.next())
           {



         this.str5+=rs2.getString("Type")+":"+rs2.getString("Temp")+"Tag Number :"+rs2.getString("Tag")+"Unit :"+rs2.getString("Unit")+"\n#";
                          data=str5.split("#");
                            m++;


    }
    }

      catch(Exception e)
    {

    }
    JLabel label[]=new JLabel[m];
    this.button1=new JButton[m];
    System.out.println(""+m);
     for(int i=0;i<m;i++)
     {
        this.findTagNo=data[i].split("Tag Number :");
        this.findTagNo=findTagNo[1].split("Unit :");
       label[i]=createlabel(i,findTagNo[0]);

     }     

}

} class StringThread extends Thread {

StringThread()

{ super();

}

@Override public void run ( )

{

   while(true)  

 {


    try
    {
    new MyNew3().display();
   // System.out.println("hi11");
    this.sleep(1000);


 }

catch(Exception e)

{

 System.out.println("Hi");      
 System.out.println(e.toString());

}

}

}

} sir, i m facing problem in Dynamically update the label. when i m changing the the value in database , its dynamically not updated prblem is jPanel.add(label11); and also not setting the bounds properly... plz resolve it

View Answers









Related Tutorials/Questions & Answers:
Dynamically update the Label & set Bounds constant between 2 Label(Thread)
Dynamically update the Label & set Bounds constant between 2 Label(Thread... in Dynamically update the label. when i m changing the the value in database , its... extends javax.swing.JFrame { private int q; private String r
Dynamically update the Label & set Bounds constant between 2 Label(Thread)
Dynamically update the Label & set Bounds constant between 2 Label(Thread... in Dynamically update the label. when i m changing the the value in database , its... extends javax.swing.JFrame { private int q; private String r
Advertisements
Dynamically update the Label & set Bounds constant between 2 Label(Thread)
Dynamically update the Label & set Bounds constant between 2 Label(Thread... in Dynamically update the label. when i m changing the the value in database , its... extends javax.swing.JFrame { private int q; private String r
How to set Marathi font to Label??
How to set Marathi font to Label??  Hello, I am doing one project in java-Swing Farm Management i want to set Marathi label in that so how i can? plzzzz help me its urgent
Struts 2 Radio without Label
Struts 2 Radio without Label  I Use a s:radio tag to create a grid to choice one option, but when i render my jsp the value of the radio is showed like a label, I donĂ?´t want the label. What can i do to solve this?   
Label
Label       A displayed label object is known as the Label. Most of the times label is used... the functioning of the next text field. A label is also restricted to a single line
ModuleNotFoundError: No module named 'label'
ModuleNotFoundError: No module named 'label'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'label' How to remove the ModuleNotFoundError: No module named 'label'
ModuleNotFoundError: No module named 'label'
ModuleNotFoundError: No module named 'label'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'label' How to remove the ModuleNotFoundError: No module named 'label'
janusgraph find edge with label
graph server. I want to find all the edges with a particular label. How to find edge with label in janusgraph? Thanks   Hi, You can use following query for find edge with label: g.V().hasLabel('MyLevel') Thanks
Struts2.2.1 label Tag Example
Struts2.2.1 label Tag Example The label tag is used to renders an HTML LABEL that allow to output <s: label name=? ? value=? ? /> combination that has... will shows how to implement the label tag in the Struts2.2.1 -- First we create
select the foreground color for a label
select the foreground color for a label  (Using JScrollBar) Write a program that uses scroll bars to select the foreground color for a label, Three horizontal scroll bars are used for selecting the red, green, and blue components
Label n Dropdown Issue
Label n Dropdown Issue  Hi guys, Some how Iam able to receive the data for labels, dropdowns. I created one array with the size of label, and statred for loop, inside this I created one more array of type above created
Dropdown and label issue
Dropdown and label issue  This is Venkat from Hyderabad,India.Working as a JavaDeveloper herein. Could you please read the code n give your valuable... array with the size of label, and statred for loop, inside this I created one
how to make a label left alignment?
how to make a label left alignment?  how to make a label left alignment
Setting Multi-Line label on the Button
Setting Multi-Line label on the Button       This section shows you how to set the multi line label on the button in Java Swing Applications. This program uses html class
Label in Flex4
Label in Flex4: In Flex4 Label is a lightweight and low level UI-component that is known as Spark Component in FLex4. Spark Label is used for rendering one or more lines of uniformly-formatted text. Label in Flex4 utilize the new
how to move label in jframe in java?
how to move label in jframe in java?  please any one can give me code for moving a java label in Jframe
ModuleNotFoundError: No module named 'label-maker'
ModuleNotFoundError: No module named 'label-maker'  Hi, My Python... 'label-maker' How to remove the ModuleNotFoundError: No module named 'label-maker' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'label-converter'
ModuleNotFoundError: No module named 'label-converter'  Hi, My... named 'label-converter' How to remove the ModuleNotFoundError: No module named 'label-converter' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'label-maker'
ModuleNotFoundError: No module named 'label-maker'  Hi, My Python... 'label-maker' How to remove the ModuleNotFoundError: No module named 'label-maker' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'label-studio'
ModuleNotFoundError: No module named 'label-studio'  Hi, My Python... 'label-studio' How to remove the ModuleNotFoundError: No module named 'label-studio' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'label-wrapper'
ModuleNotFoundError: No module named 'label-wrapper'  Hi, My... 'label-wrapper' How to remove the ModuleNotFoundError: No module named 'label-wrapper' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'edc-label'
ModuleNotFoundError: No module named 'edc-label'  Hi, My Python... 'edc-label' How to remove the ModuleNotFoundError: No module named 'edc-label' error? Thanks   Hi, In your python environment you
Version of com.ribell>launcher-label dependency
List of Version of com.ribell>launcher-label dependency
enable text box and label on selection
enable text box and label on selection  hello, Please tell me how to enable label and text box on selection of drop down list box. in drop down list box all values come from database. please reply
J2ME Label Example
are using setLabel to set the new label to the ItemString. We are replacing the new... J2ME Label Example       This is the simple create label example in which we create an StringItem
how to set the value of textfield constant
how to set the value of textfield constant  how to set the value of textfield constant
ModuleNotFoundError: No module named 'django-label-tag-attr'
ModuleNotFoundError: No module named 'django-label-tag-attr'  Hi...: No module named 'django-label-tag-attr' How to remove the ModuleNotFoundError: No module named 'django-label-tag-attr' error? Thanks   Hi
ModuleNotFoundError: No module named 'multi-label-pigeon'
ModuleNotFoundError: No module named 'multi-label-pigeon'  Hi, My... named 'multi-label-pigeon' How to remove the ModuleNotFoundError: No module named 'multi-label-pigeon' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'odoo10-addon-partner-label'
ModuleNotFoundError: No module named 'odoo10-addon-partner-label'  Hi...: No module named 'odoo10-addon-partner-label' How to remove the ModuleNotFoundError: No module named 'odoo10-addon-partner-label' error? Thanks
ModuleNotFoundError: No module named 'similarity-index-of-label-graph'
ModuleNotFoundError: No module named 'similarity-index-of-label-graph' ...: ModuleNotFoundError: No module named 'similarity-index-of-label-graph' How to remove the ModuleNotFoundError: No module named 'similarity-index-of-label-graph' error
ModuleNotFoundError: No module named 'label-studio-converter'
ModuleNotFoundError: No module named 'label-studio-converter'  Hi...: No module named 'label-studio-converter' How to remove the ModuleNotFoundError: No module named 'label-studio-converter' error? Thanks   Hi
ModuleNotFoundError: No module named 'label-studio-evalme'
ModuleNotFoundError: No module named 'label-studio-evalme'  Hi, My... named 'label-studio-evalme' How to remove the ModuleNotFoundError: No module named 'label-studio-evalme' error? Thanks   Hi
ModuleNotFoundError: No module named 'matplotlib-label-lines'
ModuleNotFoundError: No module named 'matplotlib-label-lines'  Hi...: No module named 'matplotlib-label-lines' How to remove the ModuleNotFoundError: No module named 'matplotlib-label-lines' error? Thanks   Hi
ModuleNotFoundError: No module named 'multi-label-pigeon'
ModuleNotFoundError: No module named 'multi-label-pigeon'  Hi, My... named 'multi-label-pigeon' How to remove the ModuleNotFoundError: No module named 'multi-label-pigeon' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'multi-label-pigeon-jupyter'
ModuleNotFoundError: No module named 'multi-label-pigeon-jupyter'  Hi...: No module named 'multi-label-pigeon-jupyter' How to remove the ModuleNotFoundError: No module named 'multi-label-pigeon-jupyter' error? Thanks
ModuleNotFoundError: No module named 'multi-label-pigeon-jupyter'
ModuleNotFoundError: No module named 'multi-label-pigeon-jupyter'  Hi...: No module named 'multi-label-pigeon-jupyter' How to remove the ModuleNotFoundError: No module named 'multi-label-pigeon-jupyter' error? Thanks
ModuleNotFoundError: No module named 'odoo10-addon-partner-label'
ModuleNotFoundError: No module named 'odoo10-addon-partner-label'  Hi...: No module named 'odoo10-addon-partner-label' How to remove the ModuleNotFoundError: No module named 'odoo10-addon-partner-label' error? Thanks
ModuleNotFoundError: No module named 'odoo10-addon-partner-label'
ModuleNotFoundError: No module named 'odoo10-addon-partner-label'  Hi...: No module named 'odoo10-addon-partner-label' How to remove the ModuleNotFoundError: No module named 'odoo10-addon-partner-label' error? Thanks
ModuleNotFoundError: No module named 'pybtex-author-year-label'
ModuleNotFoundError: No module named 'pybtex-author-year-label'  Hi...: No module named 'pybtex-author-year-label' How to remove the ModuleNotFoundError: No module named 'pybtex-author-year-label' error? Thanks  
ModuleNotFoundError: No module named 'svm-label-ranking'
ModuleNotFoundError: No module named 'svm-label-ranking'  Hi, My... named 'svm-label-ranking' How to remove the ModuleNotFoundError: No module named 'svm-label-ranking' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'django-label-tag-attr'
ModuleNotFoundError: No module named 'django-label-tag-attr'  Hi...: No module named 'django-label-tag-attr' How to remove the ModuleNotFoundError: No module named 'django-label-tag-attr' error? Thanks   Hi
ModuleNotFoundError: No module named 'django-label-templates'
ModuleNotFoundError: No module named 'django-label-templates'  Hi...: No module named 'django-label-templates' How to remove the ModuleNotFoundError: No module named 'django-label-templates' error? Thanks   Hi
ModuleNotFoundError: No module named 'edc-form-label'
ModuleNotFoundError: No module named 'edc-form-label'  Hi, My... named 'edc-form-label' How to remove the ModuleNotFoundError: No module named 'edc-form-label' error? Thanks   Hi, In your python
Label Tag (Form Tag) Example
Label Tag (Form Tag) Example       In this section, we are going to describe the label tag. The label tag is a UI tag that is used to render an HTML LABEL that allows us to output label:name
Maven Dependency launcher-label >> 1.0.0
You should include the dependency code given in this page to add Maven Dependency of com.ribell >> launcher-label version1.0.0 in your project
Maven Dependency launcher-label >> 1.0.1
You should include the dependency code given in this page to add Maven Dependency of com.ribell >> launcher-label version1.0.1 in your project
how to get the value of a label field of option tag in javascript?
how to get the value of a label field of option tag in javascript?  example <select> <option label="2" value="A">A</option> <option label="5" value="B">B</option> <
Difference between Timer and Thread?
Difference between Timer and Thread?  Can anyone tell me about the difference between Timer and Thread, Why we need to have Timer in case we have Thread implimentation startegy in Java
Changing the Label of a JButton Component in Java
Changing the Label of a JButton Component in Java... to change the label of a button in java swing. JButton is the component of javax.swing.*; package. The following program helps you to change the label of the button

Ads