JLabel сверху другого JLabel

Два запроса эквивалентны, и Ваш оптимизатор запросов DBMS должен распознавать это и производить, производят тот же план запросов. Это не может, но ситуация довольно проста распознать, таким образом, я ожидал бы, что любая современная система - даже Sybase - будет иметь дело с ним.

пункты НАЛИЧИЯ должны использоваться для применения условий на функции группы, иначе они могут быть mvoed в ГДЕ условие. Например. если бы Вы хотели ограничить свой запрос группами, которые имеют КОЛИЧЕСТВО (DZIALU)> 10, скажем, то необходимо было бы поместить условие в НАЛИЧИЕ, потому что это действует на группы, не отдельные строки.

6
задан coobird 3 October 2009 в 08:35
поделиться

3 ответа

Короткий ответ - да, поскольку JLabel является Контейнером , поэтому он может принимать Компонент ( JLabel является подклассом Component ) для добавления в JLabel с помощью метода add :

JLabel outsideLabel = new JLabel("Hello");
JLabel insideLabel = new JLabel("World");
outsideLabel.add(insideLabel);

В приведенном выше коде insideLabel добавляется к outsideLabel .

Однако визуально отображается метка с текстом «Hello», поэтому на самом деле нельзя см. метку, которая содержится внутри метки.

Итак, вопрос сводится к тому, чего на самом деле нужно достичь, добавляя метку поверх другой метки.


Изменить:

Из комментариев:

Что ж, я хотел сначала, read a certain fraction from a file, then display that fraction in a jlabel. what i thought of was to divide the fraction into 3 parts, then use a label for each of the three. then second, i want to be able to drag the fraction, so i thought i could use another jlabel, and place the 3'mini jlabels' over the big jlabel. i don't know if this will work though..:|

It sounds like one should look into how to use layout managers in Java.

A good place to start would be Using Layout Managers and A Visual Guide to Layout Managers, both from The Java Tutorials.

It sounds like a GridLayout could be one option to accomplish the task.

JPanel p = new JPanel(new GridLayout(0, 1));
p.add(new JLabel("One"));
p.add(new JLabel("Two"));
p.add(new JLabel("Three"));

In the above example, the JPanel is made to use a GridLayout as the layout manager, and is told to make a row of JLabels.

8
ответ дан 10 December 2019 в 02:50
поделиться

it's a matter of layout. you can do that using null layout (with hard coded locations) or with a custom layout.

0
ответ дан 10 December 2019 в 02:50
поделиться

The answer to your original question is yes for the reasons given that any Component can be added to a Container.

The reason you don't see the second label is because by default a JLabel uses a null layout manager and the size of the second label is (0, 0) so there is nothing to paint. So all you need to do is set the bounds of the second label and away you go.

You can't use a layout manager if you want to drag components around because as soon as you resize the frame etc, the layout manager will be invoked and the components will be repositioned based on the layout manager of the component.

1
ответ дан 10 December 2019 в 02:50
поделиться
Другие вопросы по тегам:

Похожие вопросы: