2014-11-16 3 views
1

저는 투명한 GUI를 가지고 있습니다.하지만 창을 스크롤하면 마지막 픽셀을 가져 와서 늘리는 것처럼 보입니다. 스크롤이 깨끗하고 흐리게하지 않는투명한 GUI 스크롤하기 텍스트를 흐리게 처리합니다. JAVA

public class Tabs { 

public String title; 
public ImageIcon image; 
public String[] text; 
public String toolTip; 
public JPanel panel; 

public JScrollPane scrollFrame; 


Node[] node; 

public Tabs(String _title, ImageIcon _image, String[] _text, String _toolTip){ 
    title = _title; 
    image = _image; 
    text = _text; 
    toolTip = _toolTip; 

} 

public Tabs(Node[] _node){ 
    node = _node; 
} 

public void makeTextPanel() { 
    panel = new JPanel(false); 
    panel.setBackground(new Color(0, 0, 0, 0)); 
    panel.setLayout(new GridLayout((text.length/3), 3)); 
    for(int i=0; i<text.length; i++){ 
     JLabel filler = new JLabel(text[i]); 
     //filler.setHorizontalAlignment(JLabel.LEFT); 
     panel.add(filler); 
    } 
    scrollFrame = new JScrollPane(panel); 
    scrollFrame.setBackground(new Color(0, 0, 0, 0)); 
    panel.setAutoscrolls(true); 
    //this.add(scrollFrame); 
    //return scrollFrame; 
} 

} 

어떻게 있도록해야합니까 :

public class MainGUI extends JPanel { 
static final JFrame frame = new JFrame("GuildWars2 Map Overlay"); 

public ArrayList<Tabs> tabList = new ArrayList<Tabs>(); 
final JTabbedPane tabbedPane = new JTabbedPane(); 

int leftRight = 350; 
int upDown = 400; 

String[] text = {"1.1","1.2","1.3","2.1","2.2","2.3","3.1","3.2","3.3","4.1","4.2","4.3","5.1","5.2","5.3","6.1","6.2","6.3", 
       "1.1","1.2","1.3","2.1","2.2","2.3","3.1","3.2","3.3","4.1","4.2","4.3","5.1","5.2","5.3","6.1","6.2","6.3", 
       "1.1","1.2","1.3","2.1","2.2","2.3","3.1","3.2","3.3","4.1","4.2","4.3","5.1","5.2","5.3","6.1","6.2","6.3", 
       "1.1","1.2","1.3","2.1","2.2","2.3","3.1","3.2","3.3","4.1","4.2","4.3","5.1","5.2","5.3","6.1","6.2","6.3", 
       "1.1","1.2","1.3","2.1","2.2","2.3","3.1","3.2","3.3","4.1","4.2","4.3","5.1","5.2","5.3","6.1","6.2","6.3", 
       "1.1","1.2","1.3","2.1","2.2","2.3","3.1","3.2","3.3","4.1","4.2","4.3","5.1","5.2","5.3","6.1","6.2","6.3", 
       "1.1","1.2","1.3","2.1","2.2","2.3","3.1","3.2","3.3","4.1","4.2","4.3","5.1","5.2","5.3","6.1","6.2","6.3", 
       "1.1","1.2","1.3","2.1","2.2","2.3","3.1","3.2","3.3","4.1","4.2","4.3","5.1","5.2","5.3","6.1","6.2","6.3", 
       "1.1","1.2","1.3","2.1","2.2","2.3","3.1","3.2","3.3","4.1","4.2","4.3","5.1","5.2","5.3","6.1","6.2","6.3", 
       "1.1","1.2","1.3","2.1","2.2","2.3","3.1","3.2","3.3","4.1","4.2","4.3","5.1","5.2","5.3","6.1","6.2","6.3", 
       "1.1","1.2","1.3","2.1","2.2","2.3","3.1","3.2","3.3","4.1","4.2","4.3","5.1","5.2","5.3","6.1","6.2","6.3"}; 
String[] text2 = {"Much WOW", "very seperated", "Such Tab"}; 
String[] emptyText = {"", "", ""}; 

ImageIcon icon = createImageIcon(""); 

public MainGUI() { 
    Tabs p1 = new Tabs("Tab 1", icon, text, ""); 
    p1.makeTextPanel(); 
    p1.scrollFrame.setPreferredSize(new Dimension(leftRight, upDown)); 
    tabList.add(p1); 

    Tabs p2 = new Tabs("Tab 2", icon, text, ""); 
    p2.makeTextPanel(); 
    p2.scrollFrame.setPreferredSize(new Dimension(leftRight, upDown)); 
    tabList.add(p2); 

    Tabs p3 = new Tabs("Tab 3", icon, text, ""); 
    p3.makeTextPanel(); 
    p3.scrollFrame.setPreferredSize(new Dimension(leftRight, upDown)); 
    tabList.add(p3); 

    Tabs p4 = new Tabs("Tab 4", icon, text2, ""); 
    p4.makeTextPanel(); 
    p4.scrollFrame.setPreferredSize(new Dimension(leftRight, upDown)); 
    tabList.add(p4); 

    Tabs p5 = new Tabs("+", icon, emptyText, ""); 
    p5.makeTextPanel(); 
    p5.scrollFrame.setPreferredSize(new Dimension(leftRight, upDown)); 
    tabList.add(p5); 

    for(int i=0; i<tabList.size(); i++){ 
     tabbedPane.addTab(tabList.get(i).title, tabList.get(i).image, tabList.get(i).scrollFrame, tabList.get(i).toolTip); 
    } 

    add(tabbedPane); 
    //tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); 
} 


/* 
* Creates and displays the main application frame. 
*/ 
public void display() { 
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 

    // Add content to the window. 
    frame.add(this, BorderLayout.CENTER); 

    //set ALL to clear //DONT Do 
    //frame.setUndecorated(true); 

    //set to clear 
    frame.setBackground(new Color(0, 0, 0, 0)); 

    // Set's the window to be "always on top" 
    frame.setAlwaysOnTop(true); 

    // Display the window. 
    frame.pack(); 
    frame.setVisible(true); 
} 
} 

이 내 탭 클래스입니다 : 여기

내 mainGUI입니까?

+0

[Java Swing에서 크기 (기본 | 최대 | 최소) 크기를 사용하지 않아야합니까?] http://stackoverflow.com/questions/7229226/should-i-avoid-the-use-of-setpreferredmaximumminimumsize-methods-in-java-swi) – MadProgrammer

답변

1

스윙, 당신은 panel.setBackground(new Color(0, 0, 0, 0)); 대신, 단순히 setOpaque를 사용하고 false

는 또한이 panel = new JPanel(false); 좋은 생각이 아니다 전달할 사용할 수 없습니다, 투명 배경 색상이 컴퍼넌트를 처리하는 방법을 알고하지 않습니다 이중 버퍼링을 유지하고 싶다면 그렇지 않으면 UI가 업데이트 될 때마다 깜박 거리며 끝날 것입니다.