Jump to content
Fórum Script Brasil
  • 0

Gettextfield


Ivopcb
 Share

Question

Olá, sou noob em programação e num to conseguindo usar um JTextField

pra pegar um int.

eis meu codigo:

import java.util.Arrays;

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

public class Escal extends JFrame

{

private JTextField edCiclos;

private JTextField edQp;

private JLabel lbMsg;

public Escal()

{

setTitle("Calculos de escalonamentos");

setSize(350,250);

setLocationRelativeTo(null);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

JPanel Pc = (JPanel) getContentPane();

Pc.setLayout(null); //elimina as frescuras do painel (north, south, east, west)

Pc.setBackground (new Color(0x6CD2E8)); // cor do fundo

/**********/

JLabel lbQtd = new JLabel("Quantidade de processos:");

lbQtd.setBounds(10,10,150,20); // dimensões da label

lbQtd.setOpaque(true); //transforma a label em opaca

lbQtd.setBackground(new Color (0x79ceb3)); //cor de fundo da label

Pc.add(lbQtd); //insere a label no painel

/********/

edQp = new JTextField(); // cria a nova label

edQp.setBounds(165,10,40,20); // tamanho da label

edQp.setBackground(new Color (0xA5DECB)); //cor de fundo do label

Pc.add (edQp); //adiciona a edit no painel

/*********/

/*Botão OK*/

JButton btOK = new JButton("Ok!"); //cria o botao ok

btOK.setBounds(220,10,60,20); // coordenadas e tamanho do botao processar

btOK.addActionListener

(

new ActionListener()

{

public void actionPerformed (ActionEvent e)

{

int qp;

qp = String.parseInt(edQp.getText());

//n1=Double.parseDouble(tnumero1.getText());

}

}

);

Pc.add (btOK); //insere o botao

/*****FIM DO BOTÃO OK*/

JButton btProcessar = new JButton("Processar"); //cria o botao processar

btProcessar.setBounds(10,40,150,30); // coordenadas e tamanho do botao processar

btProcessar.addActionListener

(

new ActionListener()

{

public void actionPerformed (ActionEvent e)

{

}

}

);

Pc.add (btProcessar); //insere o botao

lbMsg = new JLabel(); //cria a nova label msg

lbMsg.setBounds(10,80,220,30); //coordenadas da label msg

lbMsg.setOpaque(true); //label fica opaca

lbMsg.setBackground( new Color (0x89e0ac)); //cor de fundo da label

Pc.add (lbMsg); //adiciona a label no painel;

setVisible(true);

}

public static void main(String args[])

{

new Escal();

}

}

Isso é so o começo, pois pretendo fazer um programa para calcular o tempo de espera de processos nos modos FIFO e SJF.

Obrigado

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Forum Statistics

    • Total Topics
      151k
    • Total Posts
      649.1k
×
×
  • Create New...