Макет распадается в Windows 7, но выглядит хорошо в Windows XP - PullRequest
0 голосов
/ 16 мая 2011

У меня странная проблема с Java, мое приложение выглядит нормально на Windows XP, но на Windows 7 оно выглядит странно (макет просто распался).У кого-нибудь была такая же проблема?Текстовые поля имеют разный размер.

GroupLayout gl_panel = new GroupLayout(this);
        gl_panel.setHorizontalGroup(
                gl_panel.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(gl_panel.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(gl_panel.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(lblPulseFrequency, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(lblChannelDelay_4, javax.swing.GroupLayout.DEFAULT_SIZE, 86, Short.MAX_VALUE)
                        .addComponent(lblChannelDelay, javax.swing.GroupLayout.DEFAULT_SIZE, 86, Short.MAX_VALUE)
                        .addComponent(lblChannelDelay_1, javax.swing.GroupLayout.DEFAULT_SIZE, 86, Short.MAX_VALUE)
                        .addComponent(lblChannelDelay_2, javax.swing.GroupLayout.DEFAULT_SIZE, 86, Short.MAX_VALUE)
                        .addComponent(lblChannelDelay_3, javax.swing.GroupLayout.DEFAULT_SIZE, 86, Short.MAX_VALUE)
                        .addComponent(lblBlankingTime, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(gl_panel.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(pulseFreqTextField, javax.swing.GroupLayout.Alignment.TRAILING, 0, 0, Short.MAX_VALUE)
                        .addComponent(blankingTimeTextField, 0, 0, Short.MAX_VALUE)
                        .addComponent(textField_9)
                        .addComponent(textField_8)
                        .addComponent(textField_7)
                        .addComponent(textField_6)
                        .addComponent(textField_5, javax.swing.GroupLayout.DEFAULT_SIZE, 85, Short.MAX_VALUE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(gl_panel.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(gl_panel.createSequentialGroup()
                            .addGroup(gl_panel.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(lblus_3)
                                .addComponent(lblus_2)
                                .addComponent(lblus_1)
                                .addComponent(lblus)
                                .addComponent(lblus_4))
                            .addGap(18, 18, 18)
                            .addGroup(gl_panel.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(lblChannelDelay_5, javax.swing.GroupLayout.DEFAULT_SIZE, 84, Short.MAX_VALUE)
                                .addComponent(lblChannelDelay_6)
                                .addComponent(lblChannelDelay_7, javax.swing.GroupLayout.DEFAULT_SIZE, 84, Short.MAX_VALUE)
                                .addComponent(lblChannelDelay_8, javax.swing.GroupLayout.DEFAULT_SIZE, 84, Short.MAX_VALUE)
                                .addComponent(lblChannelDelay_9, javax.swing.GroupLayout.DEFAULT_SIZE, 84, Short.MAX_VALUE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(gl_panel.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(textField_14)
                                .addComponent(textField_13)
                                .addComponent(textField_12)
                                .addComponent(textField_11)
                                .addComponent(textField_10, javax.swing.GroupLayout.DEFAULT_SIZE, 86, Short.MAX_VALUE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(gl_panel.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(gl_panel.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(lblus_6, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(lblus_5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(lblus_7, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(lblus_8, javax.swing.GroupLayout.Alignment.LEADING))
                                .addComponent(lblus_9))
                            .addGap(230, 230, 230))
                        .addGroup(gl_panel.createSequentialGroup()
                            .addComponent(lblkhz)
                            .addContainerGap())))
            );
            gl_panel.setVerticalGroup(
                gl_panel.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(gl_panel.createSequentialGroup()
                    .addGroup(gl_panel.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(gl_panel.createSequentialGroup()
                            .addGap(117, 117, 117)
                            .addGroup(gl_panel.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(lblChannelDelay)
                                .addComponent(textField_5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(lblus)
                                .addComponent(lblChannelDelay_5)
                                .addComponent(textField_10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(lblus_5, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(gl_panel.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(lblChannelDelay_1)
                                .addComponent(textField_6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(lblus_1)
                                .addComponent(lblChannelDelay_6)
                                .addComponent(textField_11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(lblus_6))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(gl_panel.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(lblChannelDelay_2)
                                .addComponent(textField_7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(lblus_2)
                                .addComponent(lblChannelDelay_7, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(textField_12, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(lblus_7))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(gl_panel.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(lblChannelDelay_3)
                                .addComponent(textField_8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(lblus_3)
                                .addComponent(lblChannelDelay_8)
                                .addComponent(textField_13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(lblus_8))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(gl_panel.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(gl_panel.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(lblChannelDelay_4)
                                    .addComponent(textField_9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(gl_panel.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(lblus_4)
                                    .addComponent(lblChannelDelay_9)
                                    .addComponent(textField_14, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lblus_9))))
                        .addGroup(gl_panel.createSequentialGroup()
                            .addGap(42, 42, 42)
                            .addGroup(gl_panel.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(lblPulseFrequency)
                                .addComponent(pulseFreqTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(lblkhz))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(gl_panel.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(lblBlankingTime)
                                .addComponent(blankingTimeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addContainerGap(35, Short.MAX_VALUE))
            );

1 Ответ

1 голос
/ 16 мая 2011

Вы пробовали с разными разрешениями экрана?Даже если обе машины имеют одинаковое разрешение, XP и 7 по-разному рисуют свои поля, строки заголовка и т. Д., Что влияет на эффективные размеры кадра, и поэтому компоновка Java может вести себя по-разному в зависимости только от ОС.Вполне возможно, что компоновка полностью взорвется, если вы на самом деле измените разрешение экрана.

Ваш код выглядит так, как будто он сгенерирован каким-то конструктором графического интерфейса, таким как NetBeans Matisse.Извините, но они просто плохие.Они производят впечатление WYSIWYG , но они просто не WYSIWYG.Подумайте о кодировании GUI вручную, используя хороший менеджер раскладки, такой как MIGLayout .

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...