🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.java
Article #153081

problem z getGlassPane()

#153081
From: zoska
Date: Thu, 27 Oct 2011 14:04
77 lines
3481 bytes
Witam
Czy ktos moglby powiedziec dlaczego szyba nie odcina buttonow. Mimo
zalozenia szyby buttony sa aktywne.
Dziekuje za pomoc
Z

------------------------------------------------------------------------------------------------------------------------------

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class CreateGUI implements ItemListener, ActionListener,
MouseListener {
   JFrame frame;
   Component glass;
   JCheckBox jcb;
   JButton b1, b2;


    public CreateGUI() {
        frame = new JFrame("Proba z GlassPane");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setLocation(10,10);
        frame.setSize(300,300);
        frame.addMouseListener(this);

        Container cont = frame.getContentPane();
        cont.setLayout(new FlowLayout());
        b1 = new JButton("OK");
        b1.addActionListener(this);
        b2 = new JButton("EXIT");
        b2.addActionListener(this);
        jcb = new JCheckBox("select");
        jcb.setSelected(false);
        jcb.addItemListener(this);
        JPanel panel = new JPanel();
        panel.add(b1);
        panel.add(b2);
        panel.add(jcb);
        cont.add(panel);

        glass = frame.getGlassPane();
        if (glass.isVisible() != true) {
            System.out.println("brak szyby");
        }
        frame.setVisible(true);
    }

    public void itemStateChanged(ItemEvent e) {
        if (e.getStateChange() == ItemEvent.SELECTED) {
            glass.setVisible(true);
        } else {
            if (glass.isVisible()) {
                glass.setVisible(false);
            }
        }
    }
    public void actionPerformed(ActionEvent e) {
        System.out.println("kliknales button");
    }

    public void mouseClicked(MouseEvent e) {}
    public void mousePressed(MouseEvent e) {
    //tu sobie kontroluje czy szyba jest
        if (e.isShiftDown()) {
            if (glass.isVisible()) {
                System.out.println("Szyba zalozona");
            } else {
                System.out.println("brak szyby");
            }
        }
    }
    public void mouseReleased(MouseEvent e) {}
    public void mouseEntered(MouseEvent e) {}
    public void mouseExited(MouseEvent e) {}
}
Technical Details
Message-ID: <acf4fc09-a5ec-4b58-b436-bff9a17ca911@eh5g2000vbb.googlegroups.com>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!news.nask.pl!news.nask.org.pl!goblin3!goblin.stu.neva.ru!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeder.news-service.com!postnews.google.com!eh5g2000vbb.googlegroups.com!not-for-mail

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!news.nask.pl!news.nask.org.pl!goblin3!goblin.stu.neva.ru!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeder.news-service.com!postnews.google.com!eh5g2000vbb.googlegroups.com!not-for-mail
From: zoska <klociaciocia@gmail.com>
Newsgroups: pl.comp.lang.java
Subject: problem z getGlassPane()
Date: Thu, 27 Oct 2011 07:04:09 -0700 (PDT)
Organization: http://groups.google.com
Lines: 77
Message-ID: <acf4fc09-a5ec-4b58-b436-bff9a17ca911@eh5g2000vbb.googlegroups.com>
NNTP-Posting-Host: 80.11.130.129
Mime-Version: 1.0
X-Trace: posting.google.com 1319724250 28701 127.0.0.1 (27 Oct 2011 14:04:10 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Thu, 27 Oct 2011 14:04:10 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: eh5g2000vbb.googlegroups.com; posting-host=80.11.130.129; posting-account=U2aqgAoAAABLAjDHgvN_bz1PZSnI3gOz
User-Agent: G2/1.0
X-Google-Web-Client: true
X-Google-Header-Order: HUALESNKRC
X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 6.1; rv:7.0.1) Gecko/20100101 Firefox/7.0.1,gzip(gfe)
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit