From ad5029edaf36ceaafb4e269f2e00b0e1e0d7ffc4 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Wed, 17 Sep 2014 10:56:45 +0100 Subject: [PATCH] JAL-1360 workaround for user defined colours display on Java 7 --- src/jalview/gui/UserDefinedColours.java | 24 +++++++++++++++--------- src/jalview/jbgui/GUserDefinedColours.java | 9 +++++++++ 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/jalview/gui/UserDefinedColours.java b/src/jalview/gui/UserDefinedColours.java index f719d27..50108e7 100755 --- a/src/jalview/gui/UserDefinedColours.java +++ b/src/jalview/gui/UserDefinedColours.java @@ -58,7 +58,11 @@ import javax.swing.event.ChangeListener; public class UserDefinedColours extends GUserDefinedColours implements ChangeListener { - AlignmentPanel ap; + private static final int MY_FRAME_HEIGHT = 420; + private static final int MY_FRAME_WIDTH = 810; + private static final int MY_FRAME_WIDTH_CASE_SENSITIVE = 970; + +AlignmentPanel ap; SequenceGroup seqGroup; @@ -147,19 +151,14 @@ public class UserDefinedColours extends GUserDefinedColours implements colorChooser.getSelectionModel().addChangeListener(this); frame = new JInternalFrame(); frame.setContentPane(this); - Desktop.addInternalFrame(frame, - MessageManager.getString("label.user_defined_colours"), 720, - 370, true); + Desktop.addInternalFrame(frame, + MessageManager.getString("label.user_defined_colours"), MY_FRAME_WIDTH, + MY_FRAME_HEIGHT, true); if (seqGroup != null) { frame.setTitle(frame.getTitle() + " (" + seqGroup.getName() + ")"); } - - if (new jalview.util.Platform().isAMac()) - { - frame.setSize(760, 370); - } } void resetButtonPanel(boolean caseSensitive) @@ -230,6 +229,12 @@ public class UserDefinedColours extends GUserDefinedColours implements buttonPanel.add(makeButton("x", "x", lowerCaseButtons, 22)); } + // JAL-1360 widen the frame dynamically to accommodate case-sensitive AA codes + if (this.frame != null) { + int newWidth = caseSensitive ? MY_FRAME_WIDTH_CASE_SENSITIVE : MY_FRAME_WIDTH; + this.frame.setSize(newWidth, this.frame.getHeight()); + } + buttonPanel.validate(); validate(); } @@ -409,6 +414,7 @@ public class UserDefinedColours extends GUserDefinedColours implements button.setMargin(new java.awt.Insets(2, 14, 2, 14)); } + button.setOpaque(true); // required for the next line to have effect button.setBackground(col); button.setText(label); button.setForeground(col.darker().darker().darker()); diff --git a/src/jalview/jbgui/GUserDefinedColours.java b/src/jalview/jbgui/GUserDefinedColours.java index 1cc1f11..7a485fd 100755 --- a/src/jalview/jbgui/GUserDefinedColours.java +++ b/src/jalview/jbgui/GUserDefinedColours.java @@ -25,7 +25,9 @@ import jalview.util.MessageManager; import java.awt.*; import java.awt.event.*; + import javax.swing.*; +import javax.swing.colorchooser.AbstractColorChooserPanel; /** * DOCUMENT ME! @@ -227,6 +229,13 @@ public class GUserDefinedColours extends JPanel jPanel4.add(panel1, java.awt.BorderLayout.CENTER); this.add(jPanel4, java.awt.BorderLayout.CENTER); this.add(colorChooser, java.awt.BorderLayout.EAST); + + AbstractColorChooserPanel[] choosers = colorChooser.getChooserPanels(); + // JAL-1360 larger JColorChooser in Java 7 overwrites AA panel; restrict to swatch picker only + if (choosers.length > 3) { + // Java 7 default has 5 options rather than 3 for choosing colours; keep the first only + colorChooser.setChooserPanels(new AbstractColorChooserPanel[]{choosers[0]}); + } } /** -- 1.7.10.2