Nangamso Zamxaka
Refresh JFrame
2 Answer(s)      4 years and a month ago
Posted in : Java Beginners

How to refersh a JFrame and its componets

Advertisement
View Answers

March 29, 2011 at 4:40 PM


import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

 class Show extends JFrame {
    JPanel points;
    JTextField text;
    int maxPoints;

    public Show() {
        setBackground(Color.WHITE);
        setSize(400, 300);
        getContentPane().setLayout(null);
        setDefaultLookAndFeelDecorated(true);

        JLabel lab=new JLabel("Enter number of points: ");
        lab.setBounds(10,10,150,20);

        text = new JTextField();
        text.setBounds(150,10,100,20);

        this.add(lab);
        this.add(text);

        JButton submit = new JButton("Submit");
        submit.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e) {
            maxPoints = Integer.parseInt(text.getText()) * 2;
            points.removeAll();

            for (int i=0; i<maxPoints; i++) {
                JTextField textField = new JTextField();
                points.add(textField);
            }
            points.validate();
            points.repaint();
        }
        });
        submit.setBounds(10, 40, 100, 20);
        this.add(submit);

        points = new JPanel(new GridLayout(2,2));
        points.setBounds(10,70,265,60);
        this.add(points);
        Component[] a = points.getComponents();
        System.out.println(a.length);
        repaint();
    }
   }
public class RefreshJFrame {
        public static void main(String[] args) {
        Show show = new Show();
        show.setVisible(true);
        }
}


November 10, 2012 at 10:23 AM


its not working










Related Tutorials/Questions & Answers:
Refresh JFrame
Refresh JFrame  How to refersh a JFrame and its componets
refresh checkbox jframe
refresh checkbox jframe  How to refresh checkbox button in JFrame
Advertisements
JFrame
JFrame  write an application with a JFrame that five labels describing reasons that a customer might not buy your product(for example "Too expensive") every time the user clicks a Jbutton, remove one of the negative reasons
jframe
jframe  Create a JFrame for the Summervale Resort. Allow the user to view the information about different rooms available, dining options and activities offered. Include at least two options in each menu and display appropriate
JFrame
Jframe. How can i do it. Please help me to do it. Or what else can i have
UIBarButtonItem Refresh
, refresh button using code in iPhone application?? If yes then how?   ... the refresh button... i'm providing you the example of Navigation Refresh UIBarbuttonItem...] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(refresh
Part refresh without a page refresh
Part refresh without a page refresh  hello, How do I submit a form or a part of a form without a page refresh?   hii, Ajax can do this. You can do partial update and upon a successful AJAX interaction over the whole
prevent browser refresh
prevent browser refresh   prevent browser from refresh in Javascript
Captcha Refresh - Jquery
Captcha Refresh - Jquery  I'm looking for an example to refresh the Captcha image in Jquery ..every time the page get refresh. Thanks.   $("#refresh").click(function() { $("#captcha").attr("src","captcha.php?r
Hiding a JFrame
javax.swing.*; import java.awt.event.*; class PassData extends JFrame { JTextField... java.awt.*; import java.awt.event.*; class NextPage extends JFrame { NextPage
Hiding a JFrame
javax.swing.*; import java.awt.event.*; class PassData extends JFrame { JTextField... java.awt.*; import java.awt.event.*; class NextPage extends JFrame { NextPage
refresh jsp page - Ajax
refresh jsp page  Code for refresh a web page in jsp.  Hi friend, function refreshpage() { window.location.reload
servelt refresh page
servelt refresh page   write a program in servlet that display the cricket score.the page should automatically refresh on every 5 seconds.the score... should fall down.the page should not refresh after 5 overs is completed
Refresh the form - Struts
Refresh the form  Hi How Can i control the page that doesn't go to refresh when i am doing 1 or more action from same page and forward those action again to same page. how can i control the doesn't go to refresh in that page
refresh rate in ajax
refresh rate in ajax  my data is in table which is generated dynamically. i want to refresh that perticular table after some time using ajax and with jsp
Table refresh with ajax - Ajax
Table refresh with ajax  I am using jsp/html in my code. Is it compulsory that i have to use a servlet to implement table refresh using ajax? Or jsp also would work? Rajatha
how to refresh my GUI page
how to refresh my GUI page  how to refresh a GUI in java
Client side refresh
Client side refresh  What is client side refresh?   ... by all browsers. <META HTTP-EQUIV="Refresh" CONTENT="5; URL=/servlet/MyServlet/"> This will refresh the page in the browser automatically and loads
Windows 7 refresh DNS
Windows 7 refresh DNS  Windows 7 refresh DNS How to refresh DNS... to refresh the DNS. go to the command prompt (dos prompt) and then issue the following command: ipconfig /flushdns Above command will refresh the DNS data
Frame refresh problem - Swing AWT
Frame refresh problem  Whenever I close a child frame and reload...[] args){ JFrame frame=new JFrame(); JButton b=new JButton("Submit"); frame.add(b...(){ public void actionPerformed(ActionEvent ae){ JFrame f=new JFrame
Table refresh with ajax - Ajax
Table refresh with ajax  Hi, I want to update my table which has... or if the database is updated, i want my table to be updated automatically. For this i think i need to use ajax where a particular area in the page can
refresh - JSP-Servlet
. Is there any other way to refresh that particular place instead of refreshing whole page
Servlet refresh page
Servlet refresh page In this example we will show you how you can refresh your page from setting the refresh attribute from a servlet. response.setHeader("Refresh", "10"); The refresh attribute will direct
page refresh - JSP-Servlet
up window has to close and jsp page has to refresh. how can i solve
how to reset JFrame
how to reset JFrame  how to reset JFrame
Hoe to refresh a table row dynamically
Hoe to refresh a table row dynamically  Want to refresh a table data when a particular link is clicked. How can i do using ajax ?   Hello... will able to refresh a particular table row? Please clarify this. Thanks
jframe background color not showing
jframe background color not showing  jframe background color is not showing. please suggest.   Just add the background color to JPanel and then add it to JFrame. For example .. JFrame myFrame = new JFrame(); JPanel
How to refresh Client only once by sending setHeader ("refresh" ,??? )
How to refresh Client only once by sending setHeader ("refresh" ,??? ) ... to be refreshed ?? I just want to refresh my client page only once....! Not periodically... / REFRESH ....! I want to reload Client side only once when some event occur and flag
jumping frame jFrame to jInternalframe
jumping frame jFrame to jInternalframe  Afternoon sir, I want to ask... and sub menu(employee). in Form Login(jFrame) have username(textfield1) and password(passwordfield1), in Menu(jframe) have Menu employee(jMenu),creaby(jlabel1
Removing the Title Bar of a JFrame
Removing the Title Bar of a JFrame  How to remove the Title Bar of a JFrame in Swing Application?   Please check the tutorial Removing the Title Bar of a Frame for the source code and example description. Thanks