javaでOverrideした関数が呼ばれない
現在、ゲームに使うライブラリーを作っています。
その際、ゲームによって処理を分けられるよう、オーバーライドをする
前提の関数を作りました。しかし、タイトルのように、その関数が呼ばれません。
発生している問題・エラーメッセージ
タイトルの通り
該当のソースコード
java
1package Lib.Game; 2 3import java.awt.Color; 4import java.awt.event.KeyEvent; 5 6import javax.swing.JFrame; 7 8public class BaseGame extends JFrame 9{ 10 BaseAction ba; 11 12 public BaseGame(){} 13 14 public BaseGame( int width, int height ) 15 { 16 ba = new BaseAction( this ); 17 18 setSize( width, height ); 19 setLocationRelativeTo( null ); 20 setDefaultCloseOperation( EXIT_ON_CLOSE ); 21 add( ba ); 22 setVisible( true ); 23 } 24 25 public void b_Panel() 26 { 27 System.out.println( "えらー" ); 28 } 29 30 public void b_Key( KeyEvent e ) 31 { 32 } 33 34 public void b_Graphic() 35 { 36 } 37 38 public void repaint( int tag ) 39 { 40 ba.paint(); 41 } 42 43 public void Background( Color c ) 44 { 45 ba.Background( c ); 46 } 47 48 public void Background( int c ) 49 { 50 ba.Background( c ); 51 } 52 53 public void setColor( Color c ) 54 { 55 ba.setColor( c ); 56 } 57 58 public void setColor( int c ) 59 { 60 ba.setColor( c ); 61 } 62 63 public void fillRect( int x, int y, int width, int height ) 64 { 65 ba.fillRect( x, y, width, height ); 66 } 67 68 public void add( BaseAction ba ) 69 { 70 this.ba.add( ba ); 71 } 72} 73 74package Lib.Game; 75 76import java.awt.Color; 77import java.awt.Graphics; 78import java.awt.event.KeyEvent; 79 80import javax.swing.JPanel; 81 82public class BaseAction extends JPanel 83{ 84 Graphics m_g; 85 86 BaseGame m_bg; 87 88 public BaseAction(){} 89 90 public BaseAction( BaseGame bg ) 91 { 92 m_bg = bg; 93 } 94 95 @Override protected void processKeyEvent( KeyEvent e ) 96 { 97 b_Key( e ); 98 } 99 100 @Override protected void paintComponent( Graphics g ) 101 { 102 requestFocusInWindow(); 103 super.paintComponent( g ); 104 m_g = g; 105 106 b_Graphic(); 107 } 108 109 public void b_Panel() 110 { 111 m_bg.b_Panel(); 112 } 113 114 public void b_Key( KeyEvent e ) 115 { 116 m_bg.b_Key( e ); 117 } 118 119 public void b_Graphic() 120 { 121 m_bg.b_Graphic(); 122 } 123 124 public void Background( Color c ) 125 { 126 setBackground( c ); 127 } 128 129 public void Background( int c ) 130 { 131 setBackground( new Color( c ) ); 132 } 133 134 public void setColor( Color c ) 135 { 136 m_g.setColor( c ); 137 } 138 139 public void setColor( int c ) 140 { 141 m_g.setColor( new Color( c ) ); 142 } 143 144 public void fillRect( int x, int y, int width, int height ) 145 { 146 m_g.fillRect( x, y, width, height ); 147 } 148 149 public void add( BaseAction ba ) 150 { 151 b_Panel(); 152 } 153 154 public void paint() 155 { 156 repaint(); 157 } 158} 159
試したこと
Eclipseで確認したところ、しっかりオーバーライドできるソースになっているようです。
補足情報(FW/ツールのバージョンなど)
javaのバージョンは7です。

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/07/26 13:15
2018/07/26 13:18
2018/07/26 14:54 編集
2018/07/26 22:49