Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

DummyPeg.java

By: rburgosnavas on Dec 17th, 2012  |  syntax: Java  |  size: 1.54 KB  |  hits: 28  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. package com.rburgos.mastermindtestlayout;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Dimension;
  5. import java.awt.Graphics;
  6. import java.beans.Transient;
  7.  
  8. import javax.swing.JComponent;
  9.  
  10.  
  11. @SuppressWarnings("serial")
  12. public class DummyPeg extends JComponent
  13. {
  14.     Dimension prefSize;
  15.     public DummyPeg()
  16.     {
  17.         prefSize = new Dimension(40, 40);
  18.     }
  19.  
  20.         @Override
  21.     public void paintComponent(Graphics g)
  22.         {
  23.                 super.paintComponent(g);
  24.                 g.setColor(Color.DARK_GRAY);
  25.                 // g.fillRoundRect(x1, y1, x2, y2, 15, 15);
  26.                 g.drawRoundRect(1, 1, this.getWidth()-2, this.getHeight()-2, 15, 15);
  27.         // g.setColor(Color.DARK_GRAY.brighter());
  28.         // g.fillRoundRect(x1+10, y1+10, x2-15, y2-15, 20, 20);
  29.         // g.fillRoundRect(10, 10, this.getWidth()-15, this.getHeight()-15, 20, 20);
  30.         }
  31.        
  32.         @Override
  33.     public Dimension getPreferredSize()
  34.     {
  35.         return prefSize;
  36.     }
  37.  
  38.     @Override
  39.     public void setPreferredSize(Dimension preferredSize)
  40.     {
  41.         // TODO Auto-generated method stub
  42.         // super.setPreferredSize(preferredSize);
  43.         prefSize.setSize(preferredSize);
  44.     }
  45.  
  46.     @Override
  47.     @Transient
  48.     public Dimension getMaximumSize()
  49.     {
  50.         // TODO Auto-generated method stub
  51.         // return super.getMaximumSize();
  52.         return (new Dimension(200, 200));
  53.     }
  54.  
  55.     @Override
  56.     @Transient
  57.     public Dimension getMinimumSize()
  58.     {
  59.         // TODO Auto-generated method stub
  60.         // return super.getMinimumSize();
  61.         return (new Dimension(50, 50));
  62.     }
  63. }