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)

Have Programming Question? Ask it here!
 
 
 


Sintoo
Dynamically update the Label & set Bounds constant between 2 Label(Thread)
0 Answer(s)      a year and 8 months 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
java break to label tatement
Java Break to Label Statement In this article author discusses about Java Break to label Statement. 2005-06-30 The Java Specialists' Newsletter [Issue 110..., then I kept one burning for 5 days, even getting up at 2:00am to make sure
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
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
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
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
Difference between and merge and update in hibernate
Difference between and merge and update in hibernate  What is difference between and merge and update in hibernate?   Use update() if you are sure that the session does not contain an already persistent instance
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
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
How can i Change Button Label Value Randomly in VIRTUAL KEYBOARD using JAVA or Net Beans ???
How can i Change Button Label Value Randomly in VIRTUAL KEYBOARD using JAVA or Net Beans ???  How can change Button Label value Every Time when i start Virtual Keyboard, Means ,if 1st time Button1=''a'' then next login time
How can i Change Button Label Value Randomly in VIRTUAL KEYBOARD using JAVA or Net Beans ???
How can i Change Button Label Value Randomly in VIRTUAL KEYBOARD using JAVA or Net Beans ???  How can change Button Label value Every Time when i start Virtual Keyboard, Means ,if 1st time Button1=''a'' then next login time
Request[/DispatchAction] does not contain handler parameter named 'parameter'. This may be caused by whitespace in the label text. - Struts
Request[/DispatchAction] does not contain handler parameter named 'parameter'. This may be caused by whitespace in the label text.  I am trying... be caused by whitespace in the label text. struts-config.xml
Struts 2 imagae set to frame.
Struts 2 imagae set to frame.  I could not set image to frame in stuts 2. Here is the code : 1)index.jsp <%@ taglib uri="/struts-tags... could understand the reason . I want to set the image after uploading it please
HOW TO DISPLAY 2 SET OF CONTROLS
HOW TO DISPLAY 2 SET OF CONTROLS  i can be display one row by selecting value from drop down box BUT ALSO i need to display 2 rows by selecting value...').getElementsByTagName('tbody')[2]; tbody.appendChild(tr); } else if(b==2) { tr.innerHTML = '<
Diff between Struts1 and struts 2? - Struts
Diff between Struts1 and struts 2?  What are the difference in between Struts 1 and Struts 2?  Hi Gaurav There is a big difference... describes some differences between struts1 and struts2 Feature Struts 1 Struts 2
Diff between Runnable Interface and Thread class while using threads
Diff between Runnable Interface and Thread class while using threads  Diff between Runnable Interface and Thread class while using threads  ... problems. 2)Extending the thread will give you simple code structure in comparison
Diff between Runnable Interface and Thread class while using threads
Diff between Runnable Interface and Thread class while using threads  Diff between Runnable Interface and Thread class while using threads  ... problems. 2)Extending the thread will give you simple code structure in comparison
Difference between EJB 2 and EJB 3 - EJB
Difference between EJB 2 and EJB 3  I know we dont implement home...? If it is not there, do we have anuthing else? 2) What is the flow in EJB3.0.... it differs in EJB 2? please explain me like this for the 4th Question, In EJB
Set Date limit for dojo date picker dynamically - Date Calendar
Set Date limit for dojo date picker dynamically  Hi all, I am using Dojo's date picker in my project. I am trying to set min & max value... picker. I had set min & max date for first field. Now whatever date select in first
Nb hours between 2 time stamps meets specific criteria
Nb hours between 2 time stamps meets specific criteria  sql - I have 2 columns with time stamps and 2 empty columns, named DAYHOURS AND NIGHTHOURS. I want to update DAYHOURS and NIGHTHOURS with Number of hours fall under - 06:00
define a constant.
define a constant.  How do you define a constant?   Hi, With the help of define() directive, you can create constant in php. And here is how: <?php define('NAME', 'Bharat'); ?> Thanks
Universal Label Decorations
Universal Label Decorations Eclipse plugin containing a configurable decorator for icons and labels. Can be adjusted to decorate labels...;test" in their name as JUnit-Packages. Universal label decorations can
Dynamically adding textbox and labels
Dynamically adding textbox and labels  Sir, In my application I want to insert texbox and labels dynamically and want to insert database field value in that generated label. Plz help me, Thanks in advance
Java Thread Priorities
In this section, we will discuss how to set thread priorities with example. Thread Priorities: Thread priority is set in form of integer, which is handled... that a thread hold. Its constant value is 10. MIN_PRIORITY : It is minimum
Tomahawk outputLabel tag
to set the label for any component in the page. Its for attribute is used to decide the component for which it is label. In the for attribute the id for that component is set. This is same as html label tag
mapping between java class and more than 2 tables
mapping between java class and more than 2 tables  Association mapping of table in hibernate   Hi Friend, Please visit the following link: Hibernate Tutorial Thanks
 

 

 

DMCA.com