Foro de elhacker.net

Programación => Java => Mensaje iniciado por: Mario Olivera en 28 Noviembre 2015, 12:42 pm



Título: Ayuda problema con Multiples Fuentes en Java
Publicado por: Mario Olivera en 28 Noviembre 2015, 12:42 pm
 Hola gente, que tal, hacia mucho no andaba por aquí, me encuentro con un problema en java, al trabajar con multiples fuentes, el problema es que no me aparecen los JButton, si bien si me aparecen estos se ven pero sin rellenar, solo el contorno en gris, espero me puedan ayudar

Saludos!

Código
  1. import javax.swing.JPanel;
  2. import javax.swing.JFrame;
  3. import java.awt.Color;
  4. import java.awt.FlowLayout;
  5. import java.awt.event.ActionEvent;
  6. import java.beans.PropertyChangeListener;
  7. import javax.swing.Action;
  8. import javax.swing.Icon;
  9. import javax.swing.ImageIcon;
  10. import javax.swing.JButton;
  11.  
  12.  
  13. public class principal {
  14.  
  15. public static void main(String[] args)
  16. {
  17. Marco ventana = new Marco();
  18. }
  19. }
  20.  
  21. class Marco extends JFrame
  22. {
  23. public Marco()
  24. {
  25. Lamina panel = new Lamina();
  26.  
  27. this.add(panel);
  28. this.setTitle("ventana");
  29. this.setSize(500, 500);
  30. this.setVisible(true);
  31. this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  32. }
  33. }
  34.  
  35. class Lamina extends JPanel
  36. {
  37. private JButton amarillo;
  38. private JButton azul;
  39. private JButton rojo;
  40.  
  41. public Lamina()
  42. {
  43. AccionColor accionAmarillo = new AccionColor("Amarillo",(new ImageIcon("src/amarillo.gif")),Color.YELLOW);
  44. AccionColor accionAzul = new AccionColor("Azul",(new ImageIcon("src/azul.gif")),Color.BLUE);
  45. AccionColor accionRojo = new AccionColor("Rojo",(new ImageIcon("src/rojo.gif")),Color.RED);
  46.  
  47. amarillo = new JButton(accionAmarillo);
  48. azul = new JButton(accionAzul);
  49. rojo = new JButton(accionRojo);
  50.  
  51.  
  52. this.add(amarillo);
  53. this.add(rojo);
  54. this.add(azul);
  55.  
  56. }
  57.  
  58.  
  59.  
  60. class AccionColor implements Action
  61. {
  62. public AccionColor(String nombre,Icon icono,Color c)
  63. {
  64. this.putValue(Action.NAME, nombre);
  65. this.putValue(Action.SMALL_ICON, icono);
  66. this.putValue("color_de_fondo", c);
  67. this.putValue(Action.SHORT_DESCRIPTION, "poner fondo en " + nombre);
  68. }
  69.  
  70. @Override
  71. public void actionPerformed(ActionEvent arg0) {
  72. // TODO Auto-generated method stub
  73.  
  74. }
  75.  
  76. @Override
  77. public void addPropertyChangeListener(PropertyChangeListener arg0) {
  78. // TODO Auto-generated method stub
  79.  
  80. }
  81.  
  82. @Override
  83. public Object getValue(String arg0) {
  84. // TODO Auto-generated method stub
  85. return null;
  86. }
  87.  
  88. @Override
  89. public boolean isEnabled() {
  90. // TODO Auto-generated method stub
  91. return false;
  92. }
  93.  
  94. @Override
  95. public void putValue(String arg0, Object arg1) {
  96. // TODO Auto-generated method stub
  97.  
  98. }
  99.  
  100. @Override
  101. public void removePropertyChangeListener(PropertyChangeListener arg0) {
  102. // TODO Auto-generated method stub
  103.  
  104. }
  105.  
  106. @Override
  107. public void setEnabled(boolean arg0) {
  108. // TODO Auto-generated method stub
  109.  
  110. }
  111. }
  112.  
  113. }
  114.  
  115.