0
I would like when it reaches the maximum number of letters/words on that line, to break automatically.
When I put a pizza works smoothly:
But when I put more than one pizza the text gets bigger than jLabel so you can’t see all the pizzas or the total:
My code:
private void btnAdicionarActionPerformed(java.awt.event.ActionEvent evt) {
//Verificar se o local de entrega foi duplamente selecionado ou se nenhum
if(((checkLocal.isSelected()) && (checkCasa.isSelected())) ||((checkLocal.isSelected()==FALSE) && (checkCasa.isSelected()==FALSE)) ){
JOptionPane.showMessageDialog(null,"Foram escolhidos dois locais de entrega ou nenhum foi selecionado.\nPor favor verifique o local de entrega");
}else if(checkLocal.isSelected()){
String Entregar =checkLocal.getText();
}else if(checkCasa.isSelected()){
String Entregar =checkCasa.getText();
}
//Os dados foram verificados
String Nome = txtNomeVenda.getText();
String Endereco = txtEndereco.getText();
String Sabor1 = (String) SaborPizza1.getSelectedItem();
String Sabor2 = (String) SaborPizza2.getSelectedItem();
String Borda = (String) BordaEscolha.getSelectedItem();
String SaborTodo = "";
if(Borda.equals("Nenhuma")){
Borda = "";
}
if(Sabor2.equals("Nenhum")){
SaborTodo = "1 "+Sabor1+" Borda:"+Borda;
}else{
SaborTodo = " 1/2"+Sabor1+" 1/2"+Sabor2+" \nBorda:"+Borda;
}
PizzaNota.setText(PizzaNota.getText()+"\n"+SaborTodo+"");
txtNomeNota.setText(txtNomeVenda.getText());
}
Another thing, use Jtextfield if you need to break line, not Jlabel. This component is made for short text.
– user28595
There is a jLabel there where it says "Pizzas:" and the goal was to show all the pizzas that were ordered, but when I add more than one pizza jLabel increases and you can not see anything
– Felipe Moreno Borges
This section is not executable.
– user28595
As I said, Jlabel is not to use for long texts and line breaks, so there is Jtextarea, which allows for line breaks and long texts.
– user28595
How so it is not executable??
– Felipe Moreno Borges
Ah understood I’ll try, thanks again kkkk
– Felipe Moreno Borges
You need to provide an example of your code that people can copy and run to see the problem.
– user28595
All right, it’s just that I’m kind of new at Stack, I’m learning to use even kkkk
– Felipe Moreno Borges