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



Home Answers Viewqa Java-Beginners call frame again
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


hendra
call frame again
1 Answer(s)      5 years and 8 months ago
Posted in : Java Beginners



Advertisement
View Answers

January 27, 2009 at 5:06 AM


Hi friend,



I am sending you a running code please implement following code according to requirement.

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

public class TextDemo extends JPanel implements ActionListener {
protected JTextField textField;
protected JTextArea textArea;
private final static String newline = "\n";

public TextDemo(){
super(new GridBagLayout());

textField = new JTextField(20);
textField.addActionListener(this);

textArea = new JTextArea(5, 20);
textArea.setEditable(false);
JScrollPane scrollPane = new JScrollPane(textArea);

//Add Components to this panel.
GridBagConstraints c = new GridBagConstraints();
c.gridwidth = GridBagConstraints.REMAINDER;

c.fill = GridBagConstraints.HORIZONTAL;
add(textField, c);

c.fill = GridBagConstraints.BOTH;
c.weightx = 1.0;
c.weighty = 1.0;
add(scrollPane, c);
}

public void actionPerformed(ActionEvent evt) {
String text = textField.getText();
textArea.append(text + newline);
textField.selectAll();
textArea.setCaretPosition(textArea.getDocument().getLength());
}

private static void createAndShowGUI() {
JFrame frame = new JFrame("TextDemo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Add contents to the window.
frame.add(new TextDemo());
frame.setSize(300,150);
frame.setVisible(true);
}

public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}


---------------------------------------

Thanks.


Related Tutorials/Questions & Answers:
call frame again - Java Beginners
call frame again  d, thank's for your answer, but i can't combine... can run ,first i have one frameA in this frame have one jTextfield1,one jbutton1,second i have FrameB in this frame have one Jtextfield1 and jbutton1. I can
call frame - Java Beginners
call frame   dear java, I want to ask something about call frame to another frame and back to first frame. I have FrameA and FrameB. In frameA... String PAINT_ICON = "paint_icon"; //true if the next frame created should
Advertisements
how to call a frame having threading concept
how to call a frame having threading concept   i hav a frame having buttton on it .on click event of the button ,i want to call another frame which... of that frame ,frame is displaying but no other content. that frame contains
how to call a frame having threading concept
how to call a frame having threading concept   i hav a frame having buttton on it .on click event of the button ,i want to call another frame which... of that frame ,frame is displaying but no other content. that frame contains
Struts Login Validation. In This code setter of login page is called only one time again it doesnt call it. Why..?
Struts Login Validation. In This code setter of login page is called only one time again it doesnt call it. Why..?  **struts.xml** <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software
FRAME
FRAME  WHILE I'M RUNNINGFILE OF A GUI PROGRAMME(JDBC CONNECTION) INSTEAD OF OUTPUT FRAME ONLY TWO BLANK FRAMES ARE GETTING DISPLAYD... CAN ANYONE HELP ME TO SOLVE DS PROBLEM
FRAME
FRAME  WHILE I'M RUNNINGFILE OF A GUI PROGRAMME(JDBC CONNECTION) INSTEAD OF OUTPUT FRAME ONLY TWO BLANK FRAMES ARE GETTING DISPLAYD... CAN ANYONE HELP ME TO SOLVE DS PROBLEM
frame
frame  how to creat a frame in java   Hi Friend, Try the following code: import java.awt.*; import javax.swing.*; import java.awt.event.*; class RetrieveDataFromTextFields{ public static void main(String[] args
There and Back Again
There and Back Again       The weblog of Joshua Eichorn, AJAX, PHP and Open Source Read full Description
frame update another frame.
frame update another frame.   How do I make a link or form in one frame update another frame
Frame query
Frame query  Hi, I am working on Images in java. I have two JFrame displaying same image. We shall call it outerFrame and innerFrame.In innerFrame i am rotating the image.After all the rotations i need to display this image
Hi..Again Doubt .. - Java Beginners
Hi..Again Doubt ..  Thank u for ur Very Good Response...Really great... call. It should add to the MS Acess table..Plz check this out.... hope u ill... bg; MainMenu menu; Vote(Frame frame,String str) { setLayout(null); con
again with xml - XML
again with xml  hi all i am a beginner in xml so pls give me the details regarding the methods used in it. wat will return the methods getElementsByTagName(), getChildNodes(), getParentNode(), nextSibling(),etc and when
again java - Java Beginners
again java  i will ask iam using servlets ,in one program my requirement is if there is a image(if u like) in anywhere and we browse that image and it is store in u r account like orkut. my doubt is if the image is stored
again java - Java Beginners
again java  Hi, i will ask iam using servlets ,in one program my requirement is if there is a image(if u like) in anywhere and we browse that image and it is store in u r account like orkut. my doubt is if the image
java again - Date Calendar
java again  I can't combine your source code yesterday, can you help me again. My problem is how we get result jtextfield2 from if jtexfield1 we enter(jTextfield keypressed) then the result out to jTextfield2, This my jFrame
one frame update another frame
one frame update another frame  How do I make a link or form in one frame update another frame
Java Frame
Java Frame  What is the difference between a Window and a Frame
panel and frame
panel and frame  What is the difference between panel and frame
billing frame
billing frame  how to generate billing frame using swing which contain sr. no, name of product, quantity, price & total
call a constructor
call a constructor  How do you call a constructor for a parent class
Read data again - Java Beginners
Read data again  Hey, i want to ask again about how to read data from txt, My DB: kd_div varchar(15), nm_div varchar(30), dep varchar(25... data from txt file and send to DB.i'm using one button to call.  Hi
Image on frame
Image on frame   Hi, This is my code. In this I am unable to load... java.awt.event.*; public class AwtImg extends Frame { Image img; public...(); } AwtImg() { super("Image Frame"); MediaTracker mt=new
Hi .Again me.. - Java Beginners
Hi .Again me..  Hi Friend...... can u pls send me some code... args[]){ JFrame frame = new JFrame("Button Group... the window. JFrame frame = new JFrame("RadioButtonDemo
frame generation
frame generation  Hi I wnat to genarate one frame with two tabs working ,production..and I want two radiobuttons sector ,others in the frames..based on the tab selection I want to clikc the radio button..when i ckick the radio
call ireports
call ireports  how to call jrxml file in jsp or servlets pls give one example any one? please send one example any one
Iphone call
Iphone call  Do you have other method to make a call on Iphone,without openUrl
matching database again - Java Beginners
matching database again  Dear experts, So happy I get through this ask a question page again. Thank God. I want to say "A BIG THANK YOU" for helping me about the matching codes. It is working now after fine tuning
Read data again - Java Beginners
Read data again  sir, i still hav a problem,first your code will be change like this : in netbeans out message error 5. Can you help me again. My database like my question before.Can you fix and find the problem in my code
conference call
conference call  hi am a java beginner I want to develop a simple conference call system over a LAN can u please enlighten me on the basics that I have to do and kno first
Advertisements
 

 

 

DMCA.com