पर रेडियो बटन लेबल पर माउस को घुमाएं मेरी समस्या में मेरे पास एक अपारदर्शी जेपीनल और दूसरा जेपीनल है जो पारदर्शी (अर्द्ध पारदर्शी) है जो पहले जेपीनेल पर बैठता है। जब मैंने शीर्ष जेपीनल पर रेडियो बटन जोड़े हैं। समस्या हर बार जब मैं प्रत्येक रेडियो बटन के लेबल के क्षेत्र में माउस दर्ज करता हूं (और जब भी मैं लेबल से माउस को दूर ले जाता हूं), यह गहरा और गहरा हो जाता है।स्विंग: पारदर्शी जेपीनेल
package trial;
import java.awt.Color;
import javax.swing.ButtonGroup;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
public class Test {
public static void main(String arg[]){
JFrame rootframe = new JFrame("Test panel");
rootframe.setSize(800, 550);
rootframe.setExtendedState(JFrame.MAXIMIZED_BOTH);
JPanel basePanel = new JPanel(); //fills rootFrame
basePanel.setOpaque(true);
basePanel.setBackground(Color.yellow);
JPanel panelContainingRadioButtons = new JPanel();//wraps radio buttons
panelContainingRadioButtons.setOpaque(true);
panelContainingRadioButtons.setBackground(new Color(0,0,0,100));
ButtonGroup buttonGroup1 = new ButtonGroup();
JRadioButton jRadioButton1 = new JRadioButton();
jRadioButton1.setText("Text A...............................");
jRadioButton1.setOpaque(false);
jRadioButton1.setForeground(Color.white);
buttonGroup1.add(jRadioButton1);
JRadioButton jRadioButton2 = new JRadioButton();
jRadioButton2.setOpaque(false);
jRadioButton2.setForeground(Color.white);
buttonGroup1.add(jRadioButton2);
jRadioButton2.setText("Text B.......................");
JRadioButton jRadioButton3 = new JRadioButton();
jRadioButton3.setOpaque(false);
jRadioButton3.setForeground(Color.white);
buttonGroup1.add(jRadioButton3);
jRadioButton3.setText("Text C................................");
panelContainingRadioButtons.add(jRadioButton1);
panelContainingRadioButtons.add(jRadioButton2);
panelContainingRadioButtons.add(jRadioButton3);
basePanel.add(panelContainingRadioButtons);
rootframe.add(basePanel);
rootframe.setVisible(true);
}
}
मेरा मानना है कि इस रेडियो बटन के साथ एक समस्या नहीं है क्योंकि, एक अन्य अवसर में मैं देखा है कि इन्हीं परिस्थितियों में, अगर मैं शीर्ष JPanel करने के लिए एक JLabel जोड़ा, और शीर्ष पैनल में श्रोताओं जोड़ सकते हैं ताकि JLabel के पाठ का रंग जब माउस पर होवर किया है बदलने के लिए, और मूल रंग पर सेट हो जाएंगे जब माउस बाहर निकलता है, पाठ नीचे छवि में के रूप में अलग अलग स्थानों में दोबारा बनाई हो जाता है: -
यदि आवश्यक हो मैं भी उस कोड को पोस्ट करूंगा। मुझे लगता है कि यह वही समस्या है जो दोनों मामलों में है।
+1 अच्छा लेख। – trashgod
बिल्कुल मुझे क्या चाहिए .. बहुत बहुत धन्यवाद श्रीमान! –