Look and Feel Chooser works now

This commit is contained in:
7u83 2017-01-22 09:33:07 +01:00
parent 6decaf50ea
commit a20bb4d86d
4 changed files with 49 additions and 13 deletions

View File

@ -37,7 +37,7 @@ public class AboutDialog extends javax.swing.JDialog {
public AboutDialog(java.awt.Frame parent, boolean modal) { public AboutDialog(java.awt.Frame parent, boolean modal) {
super(parent, modal); super(parent, modal);
initComponents(); initComponents();
this.setLocationRelativeTo(this); this.setLocationRelativeTo(MainWin.instance);
} }
/** /**

View File

@ -29,10 +29,12 @@
<Group type="102" attributes="0"> <Group type="102" attributes="0">
<Component id="lafLabel" min="-2" pref="106" max="-2" attributes="0"/> <Component id="lafLabel" min="-2" pref="106" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="lafComboBox" pref="276" max="32767" attributes="0"/> <Component id="lafComboBox" max="32767" attributes="0"/>
</Group> </Group>
<Group type="102" alignment="1" attributes="0"> <Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/> <EmptySpace min="0" pref="201" max="32767" attributes="0"/>
<Component id="okButton" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="applyButton" min="-2" max="-2" attributes="0"/> <Component id="applyButton" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="cancelButton" min="-2" max="-2" attributes="0"/> <Component id="cancelButton" min="-2" max="-2" attributes="0"/>
@ -54,6 +56,7 @@
<Group type="103" groupAlignment="3" attributes="0"> <Group type="103" groupAlignment="3" attributes="0">
<Component id="cancelButton" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="cancelButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="applyButton" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="applyButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="okButton" alignment="3" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
</Group> </Group>
@ -102,5 +105,14 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="applyButtonActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="applyButtonActionPerformed"/>
</Events> </Events>
</Component> </Component>
<Component class="javax.swing.JButton" name="okButton">
<Properties>
<Property name="mnemonic" type="int" value="111"/>
<Property name="text" type="java.lang.String" value="Ok"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okButtonActionPerformed"/>
</Events>
</Component>
</SubComponents> </SubComponents>
</Form> </Form>

View File

@ -25,6 +25,8 @@
*/ */
package gui; package gui;
import java.awt.Frame;
import java.awt.Window;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.UIManager; import javax.swing.UIManager;
@ -42,6 +44,7 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
public EditPreferencesDialog(java.awt.Frame parent, boolean modal) { public EditPreferencesDialog(java.awt.Frame parent, boolean modal) {
super(parent, modal); super(parent, modal);
initComponents(); initComponents();
this.setLocationRelativeTo(MainWin.instance);
lafInfo = UIManager.getInstalledLookAndFeels(); lafInfo = UIManager.getInstalledLookAndFeels();
lafComboBox.removeAllItems(); lafComboBox.removeAllItems();
@ -63,6 +66,7 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
lafLabel = new javax.swing.JLabel(); lafLabel = new javax.swing.JLabel();
cancelButton = new javax.swing.JButton(); cancelButton = new javax.swing.JButton();
applyButton = new javax.swing.JButton(); applyButton = new javax.swing.JButton();
okButton = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
@ -91,6 +95,14 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
} }
}); });
okButton.setMnemonic('o');
okButton.setText("Ok");
okButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
okButtonActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout); getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(
@ -101,9 +113,11 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addComponent(lafLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(lafLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lafComboBox, 0, 276, Short.MAX_VALUE)) .addComponent(lafComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE) .addGap(0, 201, Short.MAX_VALUE)
.addComponent(okButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(applyButton) .addComponent(applyButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cancelButton))) .addComponent(cancelButton)))
@ -119,7 +133,8 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 236, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 236, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cancelButton) .addComponent(cancelButton)
.addComponent(applyButton)) .addComponent(applyButton)
.addComponent(okButton))
.addContainerGap()) .addContainerGap())
); );
@ -141,21 +156,28 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
for (UIManager.LookAndFeelInfo lafInfo1 : this.lafInfo) { for (UIManager.LookAndFeelInfo lafInfo1 : this.lafInfo) {
if (lafInfo1.getName().equals(selected)) { if (lafInfo1.getName().equals(selected)) {
String x = lafInfo1.getClassName(); String lafClassName = lafInfo1.getClassName();
System.out.printf("Set Callsname: %s\n", x);
try { try {
UIManager.setLookAndFeel(x); UIManager.setLookAndFeel(lafClassName);
SwingUtilities.updateComponentTreeUI(MainWin.instance); break;
MainWin.instance.pack();
} catch (Exception e) { } catch (Exception e) {
} }
} }
} }
for (Window w : Window.getWindows()) {
System.out.print("Setting frame\n");
SwingUtilities.updateComponentTreeUI(w);
w.pack();
}
}//GEN-LAST:event_applyButtonActionPerformed }//GEN-LAST:event_applyButtonActionPerformed
private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
this.applyButtonActionPerformed(evt);
this.dispose();
}//GEN-LAST:event_okButtonActionPerformed
/** /**
* @param args the command line arguments * @param args the command line arguments
*/ */
@ -203,5 +225,6 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
private javax.swing.JButton cancelButton; private javax.swing.JButton cancelButton;
private javax.swing.JComboBox<String> lafComboBox; private javax.swing.JComboBox<String> lafComboBox;
private javax.swing.JLabel lafLabel; private javax.swing.JLabel lafLabel;
private javax.swing.JButton okButton;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables
} }

View File

@ -25,7 +25,6 @@ package gui;
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
/** /**
* *
* @author 7u83 <7u83@mail.ru> * @author 7u83 <7u83@mail.ru>
@ -34,12 +33,14 @@ public class TraderListDialog extends javax.swing.JDialog {
/** /**
* Creates new form TraderList * Creates new form TraderList
*
* @param parent * @param parent
* @param modal * @param modal
*/ */
public TraderListDialog(java.awt.Frame parent, boolean modal) { public TraderListDialog(java.awt.Frame parent, boolean modal) {
super(parent, modal); super(parent, modal);
initComponents(); initComponents();
this.setLocationRelativeTo(MainWin.instance);
} }
/** /**