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



Home Answers Viewqa Java-Beginners Dynamically update the Label & set Bounds constant between 2 Label(Thread)
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Sintoo
Dynamically update the Label & set Bounds constant between 2 Label(Thread)
0 Answer(s)      2 years and a month ago
Posted in : Java Beginners


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


Advertisement
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
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
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
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
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 make a label left alignment?
how to make a label left alignment?  how to make a label left alignment
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
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
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
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
how to set the value of textfield constant
how to set the value of textfield constant  how to set the value of textfield constant
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
NetBeans change the picture on one single label
NetBeans change the picture on one single label  I wantted to insert Images using if condition on a button that is performed to change the picture on one single label. how shuold i do this ? and also give me an example
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> <
how to display the value of termcell name in label
how to display the value of termcell name in label  want to display the tercell name in label report of pending apllication of termcellname code of the jsp page is as: <%@ taglib uri="http://displaytag.sf.net" prefix
creating columns and adding label and textfield in the columns in a jsp page
creating columns and adding label and textfield in the columns in a jsp page  I have create a jsp page with 3 columns.....each column has a title,3 label and corresponding 3 text fields....can u send me the code
Display Label and radio buttons runtime with respect to DB values
Display Label and radio buttons runtime with respect to DB values  Requirement: I am getting alertCondition,Y,W values from DB the the cooresponding fields like the following: JLbel- alertCondition-"alert1","Alert2" JradioButton
How to resolve this error The filename, directory name, or volume label syntax is incorrect
How to resolve this error The filename, directory name, or volume label syntax is incorrect  Image is stored in physical directory like this String... label syntax is incorrect) at java.io.RandomAccessFile.open(Native Method
Dynamically Update textbox from database
Dynamically Update textbox from database  I have a database as shown below.(database created using SQL Server 2005) name : george,simon address : bangalore,hyderabad now I want the following thing to be done. I have a form
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
difference between main thread and child thread?
difference between main thread and child thread?  any one give correct exact difference.   in jsp 7 implicit objects are available those are 1:response->This denotes the data included with the HTTP Response. 2
Setting Bounds for a maximized frame
Setting Bounds for a maximized frame       In this section, you will learn how to set the bounds for a maximized frame. This means to fix the size for the frame after
Request[/searchMenu] does not contain handler parameter named 'function'. This may be caused by whitespace in the label text. - Subversion
Request[/searchMenu] does not contain handler parameter named 'function'. This may be caused by whitespace in the label text.  Hi, i am using... in the label text. jsp file = Search for - Shipping Category struts-config.xml
Switching dynamically between database schemas - JDBC
Switching dynamically between database schemas   I am working on a project which requires to switch between database schemas dynamically. Am using MySql as my database and am coding using core and advanced java. I have been
 

 

 

DMCA.com