From d7a15d6458454838d085330774f2e0ee7cdb5eeb Mon Sep 17 00:00:00 2001 From: Akarshit Wal Date: Sat, 15 Aug 2015 22:33:39 +0530 Subject: [PATCH] Possible sets the font correctly --- .../app/contrib/ContributionListPanel.java | 6 +-- .../contrib/ContributionManagerDialog.java | 4 ++ .../processing/app/contrib/StatusPanel.java | 43 +++++++++---------- 3 files changed, 26 insertions(+), 27 deletions(-) diff --git a/app/src/processing/app/contrib/ContributionListPanel.java b/app/src/processing/app/contrib/ContributionListPanel.java index 865e11bd6..4bacd04fc 100644 --- a/app/src/processing/app/contrib/ContributionListPanel.java +++ b/app/src/processing/app/contrib/ContributionListPanel.java @@ -59,7 +59,6 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib protected ContributionListing contribListing = ContributionListing.getInstance(); protected JTable table; DefaultTableModel dtm; - Font myFont; public ContributionListPanel() { // TODO Auto-generated constructor stub @@ -97,9 +96,6 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib return c; } }; - - myFont = Toolkit.getSansFont(14, Font.PLAIN); - GraphicsEnvironment.getLocalGraphicsEnvironment().registerFont(myFont); // There is a space before Status String[] colName = { " Status", "Name", "Author" }; @@ -308,7 +304,7 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib if (table.isRowSelected(row)) { label.setBackground(new Color(0xe0fffd)); } - label.setFont(myFont); + label.setFont(ContributionManagerDialog.myFont); label.setOpaque(true); } else { label = new JLabel( diff --git a/app/src/processing/app/contrib/ContributionManagerDialog.java b/app/src/processing/app/contrib/ContributionManagerDialog.java index edc022378..0f642b3e4 100644 --- a/app/src/processing/app/contrib/ContributionManagerDialog.java +++ b/app/src/processing/app/contrib/ContributionManagerDialog.java @@ -74,8 +74,12 @@ public class ContributionManagerDialog { private JLabel updateTabLabel; + static Font myFont; + public ContributionManagerDialog() { + myFont = Toolkit.getSansFont(14, Font.PLAIN); + GraphicsEnvironment.getLocalGraphicsEnvironment().registerFont(myFont); numberLabel = new JLabel(Toolkit.getLibIcon("manager/notification.png"), SwingConstants.CENTER); toolsContributionTab = new ContributionTab(ContributionType.TOOL, this); librariesContributionTab = new ContributionTab(ContributionType.LIBRARY, this); diff --git a/app/src/processing/app/contrib/StatusPanel.java b/app/src/processing/app/contrib/StatusPanel.java index f093957a9..083e8b3bd 100644 --- a/app/src/processing/app/contrib/StatusPanel.java +++ b/app/src/processing/app/contrib/StatusPanel.java @@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ + */ package processing.app.contrib; import java.awt.BorderLayout; @@ -43,7 +43,6 @@ import processing.app.ui.Toolkit; import processing.app.Base; import processing.app.Platform; - class StatusPanel extends JPanel { static final int BUTTON_WIDTH = 150; @@ -55,7 +54,6 @@ class StatusPanel extends JPanel { JButton removeButton; GroupLayout layout; JLabel iconLabel; - ContributionListing contributionListing = ContributionListing.getInstance(); ContributionTab contributionTab; @@ -63,7 +61,7 @@ class StatusPanel extends JPanel { super(); setBackground(new Color(0xebebeb)); // setBorder(BorderFactory.createMatteBorder(2, 0, 0, 0, Color.BLACK)); - this.contributionTab = contributionTab; + this.contributionTab = contributionTab; iconLabel = new JLabel(); @@ -71,7 +69,7 @@ class StatusPanel extends JPanel { label.setEditable(false); label.setOpaque(false); label.setContentType("text/html"); - label.setFont(Toolkit.getSansFont(14, Font.PLAIN)); + label.setFont(ContributionManagerDialog.myFont); label.addHyperlinkListener(new HyperlinkListener() { @Override @@ -83,7 +81,8 @@ class StatusPanel extends JPanel { } } }); - installButton = new JButton("Install", Toolkit.getLibIcon("manager/install.png")); + installButton = new JButton("Install", + Toolkit.getLibIcon("manager/install.png")); installButton.setFont(Toolkit.getSansFont(14, Font.PLAIN)); installButton.setHorizontalAlignment(SwingConstants.LEFT); // installButton.setContentAreaFilled(false); @@ -103,7 +102,8 @@ class StatusPanel extends JPanel { progressBarPanel.setOpaque(false); updateLabel = new JLabel(" "); updateLabel.setFont(Toolkit.getSansFont(14, Font.PLAIN)); - updateButton = new JButton("Update", Toolkit.getLibIcon("manager/update.png")); + updateButton = new JButton("Update", + Toolkit.getLibIcon("manager/update.png")); updateButton.setFont(Toolkit.getSansFont(14, Font.PLAIN)); updateButton.setHorizontalAlignment(SwingConstants.LEFT); // updateButton.setAlignmentX(SwingConstants.LEFT); @@ -120,7 +120,8 @@ class StatusPanel extends JPanel { } }); - removeButton = new JButton("Remove", Toolkit.getLibIcon("manager/remove.png")); + removeButton = new JButton("Remove", + Toolkit.getLibIcon("manager/remove.png")); removeButton.setFont(Toolkit.getSansFont(14, Font.BOLD)); removeButton.setHorizontalAlignment(SwingConstants.LEFT); // removeButton.setContentAreaFilled(false); @@ -169,8 +170,8 @@ class StatusPanel extends JPanel { .addComponent(updateLabel)) .addComponent(updateButton).addComponent(removeButton))); - layout - .linkSize(SwingConstants.HORIZONTAL, installButton, progressBarPanel, updateButton, removeButton); + layout.linkSize(SwingConstants.HORIZONTAL, installButton, progressBarPanel, + updateButton, removeButton); progressBarPanel.setVisible(false); updateLabel.setVisible(false); @@ -226,24 +227,25 @@ class StatusPanel extends JPanel { && (contributionListing.hasUpdates(panel.getContrib()) && !panel .getContrib().isUpdateFlagged())); - String latestVersion = contributionListing.getLatestVersion(panel.getContrib()); + String latestVersion = contributionListing.getLatestVersion(panel + .getContrib()); String currentVersion = panel.getContrib().getPrettyVersion(); - if(latestVersion != null){ + if (latestVersion != null) { latestVersion = "Update to " + latestVersion; - }else{ + } else { latestVersion = "Update"; } - if(currentVersion != null){ + if (currentVersion != null) { currentVersion = "Version " + currentVersion; - }else{ + } else { currentVersion = ""; } - if(updateButton.isEnabled()){ + if (updateButton.isEnabled()) { updateButton.setText(latestVersion); - }else{ + } else { updateButton.setText("Update"); } @@ -251,9 +253,9 @@ class StatusPanel extends JPanel { && contributionListing.hasDownloadedLatestList() && panel.getContrib().isCompatible(Base.getRevision())); - if(installButton.isEnabled()){ + if (installButton.isEnabled()) { updateLabel.setText(currentVersion + " available"); - }else{ + } else { updateLabel.setText(currentVersion + " installed"); } @@ -266,14 +268,11 @@ class StatusPanel extends JPanel { } } } - - /* interface ErrorWidget { void setErrorMessage(String msg); } - class StatusPanel extends JPanel implements ErrorWidget { String errorMessage;