Urgent help needed with JCheckBox :)

Actually it is more than subject tells. This problem is main also for JRadioButton. Is there a direct way (methods) to change display of it.

Standard way is a line: * JCheckBox label

And i want it in column:label

*

This is needed for case like this:

12345

* * * * *

[310 byte] By [topl0305a] at [2007-10-3 2:51:10]
# 1
Oh, it's urgent. Dang, I must be too late. Sorry...
CeciNEstPasUnProgrammeura at 2007-7-14 20:40:02 > top of Java-index,Java Essentials,Java Programming...
# 2

Swing related questions should be posted in the Swing forum.

It can't be that urgent or you would have read the API and had your answer in a couple of minutes instead of waiting over an hour hoping someone will answer your question.

In case you haven't noticed, stating your question is "urgent" is one way not to get a response. Your question is no more important than anybody elses.

camickra at 2007-7-14 20:40:02 > top of Java-index,Java Essentials,Java Programming...
# 3
[url= http://www.catb.org/~esr/faqs/smart-questions.html#urgent]How To Ask Questions The Smart Way: Don't flag your question as 揢rgent? even if it is for you[/url]
mlka at 2007-7-14 20:40:02 > top of Java-index,Java Essentials,Java Programming...
# 4
I suppose if you put them in a GridLayout without any text label you could get what you are looking for. The first row would contain JLabels and the second row would have your check boxes.
pthorsona at 2007-7-14 20:40:02 > top of Java-index,Java Essentials,Java Programming...
# 5
URGENT! what the h*ll are you even asking? i dont understand at all...do you want to do this:12345* * * * * IN a JLabel?JLabel label = new JLabel("<html>1235*****</html>");
TuringPesta at 2007-7-14 20:40:02 > top of Java-index,Java Essentials,Java Programming...
# 6
http://java.sun.com/docs/books/tutorial/uiswing/layout/visual.html
TuringPesta at 2007-7-14 20:40:02 > top of Java-index,Java Essentials,Java Programming...
# 7
> i dont understand at all...he wants the text above the checkbox, instead of to the right.as mentioned earlier, looking in the api would give him the answer
Michael_Dunna at 2007-7-14 20:40:02 > top of Java-index,Java Essentials,Java Programming...
# 8
Use 10 components instead of 5.5 JLabel components and 5 JCheckbox components.The 5 JCheckbox components have blank text (in other words: without either icon or text name)Then, put the 5 JLabel in the first line, put the 5 checkboxes in the second line.
Eric.Suna at 2007-7-14 20:40:02 > top of Java-index,Java Essentials,Java Programming...
# 9
> Use 10 components instead of 5. 5 JLabel components and 5 JCheckbox components.Why on earth would you do that? Again read the API like I originally suggested. There are methods that allow you to control the postion of the text releative to the icon.
camickra at 2007-7-14 20:40:02 > top of Java-index,Java Essentials,Java Programming...
# 10

Actually i tryed this i got some results, but they are didn't look good.

Somthing like that:

1 2 3 4 5

<SPACER TYPE=HORIZONTAL SIZE=50>* * * * *

And i have problems with centering. If i had found an answer in api i didn't wrote here. I tryed some methods like <b>setVerticalAlignment<\b> from AbstractButton, but it didn't work.

topl0305a at 2007-7-14 20:40:02 > top of Java-index,Java Essentials,Java Programming...
# 11

[code]

import javax.swing.*;

import java.awt.*;

class Test extends JFrame{

JCheckBox j = new JCheckBox("1");

Test(){

setSize(300,300);

getContentPane().setLayout(new FlowLayout());

j.setVerticalTextPosition(SwingConstants.TOP);

getContentPane().add(j);

show();

}

public static void main (String [] args){

new Test();

}

}

[\code]

This is a sample. I use JAVA SE 1.4.xx

And one more thing. Frome your posts i see that no one know how to solve this problem. Why did you wrote then ?

P.S. In my laguage "urgent" have few meanings. Why are some of you so pi****d?

Message was edited by:

topl0305

topl0305a at 2007-7-14 20:40:02 > top of Java-index,Java Essentials,Java Programming...
# 12

[nobr]import java.awt.FlowLayout;

import javax.swing.JButton;

import javax.swing.JCheckBox;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.SwingConstants;

class Test extends JFrame {

JCheckBox j = new JCheckBox("My name1\n****");

JLabel label = new JLabel("<html>1235<br>*****</html>");

JButton b = new JButton();

Test() {

j.setText(label.getText());

b.setText(label.getText());

setSize(300, 300);

getContentPane().setLayout(new FlowLayout());

j.setVerticalTextPosition(SwingConstants.TOP);

getContentPane().add(j);

getContentPane().add(b);

show();

}

public static void main(String[] args) {

new Test();

//System.exit(-1);

}

}

[/nobr]

java_2006a at 2007-7-14 20:40:02 > top of Java-index,Java Essentials,Java Programming...
# 13
sorry : >JCheckBox j = new JCheckBox("My name1\n****");JCheckBox j = new JCheckBox();
java_2006a at 2007-7-14 20:40:02 > top of Java-index,Java Essentials,Java Programming...
# 14
> P.S. In my laguage "urgent" have few meanings. Why> are some of you so pi****d?Because we don't speak "your language", and "urgent" has a very precise meaning in standard English which is expected to be used here.
CeciNEstPasUnProgrammeura at 2007-7-14 20:40:02 > top of Java-index,Java Essentials,Java Programming...
# 15

I see someone do not understand what i needed.

So, i will repeat. JCheckBox have linear form: first is Box and next is Label.

* this is first box

* this is second box

I need vertical form: On TOP is Label and on BOTTOM is Box:

this is first boxthis is second box

**

topl0305a at 2007-7-21 10:00:09 > top of Java-index,Java Essentials,Java Programming...
# 16

You are getting closer. By posting demo code you have showed that you made an effort to read the API, which is all you needed to do in the first place. If there are methods that you tried using that didn't work as expected, then tell us so we can point you in the right directlion.

checkBox.setVerticalTextPosition(JCheckBox.TOP);

checkBox.setHorizontalTextPosition(JCheckBox.CENTER);

camickra at 2007-7-21 10:00:09 > top of Java-index,Java Essentials,Java Programming...
# 17
> I see someone do not understand what i needed.> So, i will repeat. JCheckBox have linear form: first> is Box and next is Label.I see that you don't understand what is being told. If you have a problem reading the API, you should mention that.
el_doradoa at 2007-7-21 10:00:09 > top of Java-index,Java Essentials,Java Programming...