TextField on an applet

hey all and thank u for ur time,

i ve created an applet where i initiated some jtextfields:

JTextField valEp = new JTextField ("valeur Ep");

the problem is that they can be seen only if i click on them.

is there a trick?

and does anyone know a simple tutorial for managing the positions of buttons, text and all on an applet?

[363 byte] By [Landolfa] at [2007-11-26 15:05:07]
# 1

> hey all and thank u for ur time,

>

> i ve created an applet where i initiated some

> jtextfields:

>

> JTextField valEp = new JTextField

> ("valeur Ep");

>

> the problem is that they can be seen only if i click

> on them.

> is there a trick?

> and does anyone know a simple tutorial for managing

> the positions of buttons, text and all on an applet?

http://java.sun.com/docs/books/tutorial/uiswing/layout/visual.html

qUesT_foR_knOwLeDgea at 2007-7-8 8:54:53 > top of Java-index,Java Essentials,New To Java...
# 2
> the problem is that they can be seen only if i click> on them. > is there a trick?Did you add something on top of them? It should not do that. Try posting your code. Also; in the future, Swing questions should be posted in the Swing forum.
CaptainMorgan08a at 2007-7-8 8:54:53 > top of Java-index,Java Essentials,New To Java...
# 3

import javax.swing.*;

import java.awt.*;

import java.util.*;

import java.text.SimpleDateFormat;

/* <APPLET CODE = "work.class" WIDTH=600 HEIGHT=700>

</APPLET> */

public class work extends JApplet {

Font fontTitre = new java.awt.Font("TimesRoman", Font.BOLD, 20);

Font font = new java.awt.Font("TimesRoman", Font.PLAIN, 14);

//construction du bouton calculer

Button ok = new Button(" Calculer ");

public void init() {

super.init();

setBackground(Color.WHITE);

getContentPane().add(ok);

//construction du bouton de choix de type de maconnerie

Choice type = new Choice();

type.addItem("MB, MBL, MK ");

type.addItem("MC, MCL, MPL");

//construction du bouton de choix de facteur de conversion eta 3

Choice eta = new Choice();

eta.addItem("cas general ");

eta.addItem("joints verticaux totalement remplis");

//construction du bouton de choix de coefficient du frottement interne

Choice MmM = new Choice();

MmM.addItem(" 0.6 ");

MmM.addItem(" 0.7 ");

MmM.addItem(" 0.8 ");

MmM.addItem(" 0.9 ");

MmM.addItem(" 1.0 ");

//construction de l'espace pour lintroduction de la valeur de h

JTextField valH = new JTextField ("valeur h");

//construction de l'espace pour lintroduction de la valeur de l

JTextField valL = new JTextField ("valeur L");

//construction de l'espace pour lintroduction de la valeur de tw

JTextField valEp = new JTextField ("valeur Ep");

//construction de l'espace pour lintroduction de la valeur caracteristique de la resistance a la compression

JTextField valResComp = new JTextField ("valeur resComp");

//construction de l'espace pour lintroduction de la valeur de l'effort normal de compression

JTextField valEfComp = new JTextField ("valeur comp");

JPanel panel = new JPanel();

panel.add(ok);

panel.add(type);

panel.add(eta);

panel.add(MmM);

panel.add(valH);

panel.add(valL);

panel.add(valEp);

panel.add(valResComp);

panel.add(valEfComp);

setContentPane(panel);

setSize(1075,700);

setVisible(true);

}

public void paint (Graphics g) {

g.setFont(fontTitre);

g.drawRect (0, 0, getSize().width - 1, getSize().height - 1);

g.drawString ( "Etude de la r閟istance lat閞ale d'un mur en ma鏾nnerie non arm閑", 250, 50);

g.setFont(font);

g.drawString ( "H : hauteur (0.0 - 4.0[m])", 35, 100);

g.drawString ( "L : largeur (0.0 - 10.0[m])", 35, 135);

g.drawString ( "tw : epaisseur (0.0 - 0.3[m])", 35, 170);

g.drawString ( "Type de ma鏾nnerie: ", 35, 205);

g.drawString ( "Coefficient du frottement interne (Mu): ", 35, 240);

g.drawString ( "Facteur de conversion (eta 3): ", 35, 275);

g.drawString ( "Effort normal de compression: ", 35, 310);

/*Image im = getImage(getCodeBase(), "mur.gif");

g.drawImage(im, 130, 20, this);*/

// construction du rectangle du mur

g.setColor( Color.BLACK );

g.drawRect( 35, 450, 975, 300);

g.drawRect( 600, 100, 400, 210);

String name = "mur.gif";

Image image = Toolkit.getDefaultToolkit().getImage(name);

g.drawImage(image, 200, 150, 200, 150, null);

}

Landolfa at 2007-7-8 8:54:53 > top of Java-index,Java Essentials,New To Java...
# 4
take off the pic and run it, u ll see on top if u click on the white fond tha jtext fields appear...sorry i didnt know, thx for tellin
Landolfa at 2007-7-8 8:54:53 > top of Java-index,Java Essentials,New To Java...