私はJavaで作成しているインタフェースに問題があります。 JPanel、JTextField、JCheckBox、JRadioButton、JButtonのために正しく動作しています。これらはすべて正しく描画されます。しかし、JComboBoxはそうではありません。背景色が設定されていても塗りつぶすだけです。JComboBoxが描画されない
プロジェクトの複雑さのために、これらのコンポーネントはコンテナに追加されず、実質的に存在し、コンテナにペイントされ、他のコンポーネントが機能しているため、問題はないと思います。作成コード:
paintableComponent = new JComboBox(new String[]{"test"});
塗料コードは、これは擬似コンポーネント内予め
if(this.getParentComponent() != null && this.getParentComponent() instanceof Component && !((Component)this.getParentComponent()).getValue("style.overflow").equals("visible")){
g.setClip(this.getParentComponent().getX(), this.getParentComponent().getY(), this.getParentComponent().getWidth(), this.getParentComponent().getHeight());
}
Graphics oldG = g;
g = g.create(getX(), getY(), getWidth(), getHeight());
paintableComponent.paint(g);
g = oldG;
Iterator<Component> i = children.iterator();
while(i.hasNext()){
i.next().paint(g);
}
おかげで
すぐに[SSCCE](http://sscce.org/)で質問を編集 – mKorbel
擬似コンポーネントが実際のコンポーネントの境界を手動で設定していたため、この問題が発生しました。これは、子を持たないコンポーネントでうまく動作しますが、それ以外の場合は失敗します。 解決策は、JComboBoxのsetBoundsメソッドをオーバーライドして、childrens境界の設定を可能にすることでした。 –