Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (536)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Any idea why my desktopPane doesn't show up?  (Read 811 times)
0 Members and 1 Guest are viewing this topic.
Offline jamesco

Senior Newbie





« Posted 2006-12-18 10:14:44 »

here's the code attached =)


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
      //////////////////////////////////////
     // Panel for Tile Game Area
     //////////////////////////////////////
     JPanel gamearea = new JPanel();
      gamearea.add(game);
      gamearea.addMouseListener(new MouseAdapter() {
            public void mouseEntered(MouseEvent e) {
               game.requestFocus(true); // also try adding the param 'true'
           }
       });
      //////////////////////////////////////
     // Panel for UserList and Login Button
     //////////////////////////////////////
     JPanel userlistPane = new JPanel();
      userList = new JList(new DefaultListModel());
        userList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
        userList.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent evt) {
                if (evt.getClickCount() > 1) {
                    BYTEARRAY ba = (BYTEARRAY) userList.getSelectedValue();
                    if (ba != null) {
                        String message = JOptionPane.showInputDialog(
                                Login.this, "Enter private message:");
                        doDCCMessage(ba.data(), message);
                    }
                }
            }
        });
        userList.setCellRenderer(new ListCellRenderer() {
            JLabel text = new JLabel();
            public Component getListCellRendererComponent(JList arg0,
                    Object arg1, int arg2, boolean arg3, boolean arg4) {
                byte[] data = ((BYTEARRAY) arg1).data();
                text.setText(StringUtils.bytesToHex(data,0,data.length>4?4:data.length));
                return text;
            }
        });
        userlistPane.setLayout(new BorderLayout(1,2));
        userlistPane.add(new JScrollPane(userList));
        login.setSize(100, 200);
        userlistPane.add(login, BorderLayout.SOUTH);
      userlistPane.setBackground(Color.gray);
     
       
       
      //////////////////////////////////////
     // Main Panel for Adding other Panels
     //////////////////////////////////////
     //JPanel c = new JPanel();
     Container c = getContentPane();
        c.setLayout(new BoxLayout(c, BoxLayout.X_AXIS));
        //c.setLayout(new BorderLayout());
       c.setBackground(Color.gray);
        //desktop = new JDesktopPane();
       c.add(desktop, BorderLayout.CENTER);
        c.add(gamearea, BorderLayout.CENTER);
        c.add(userlistPane, BorderLayout.EAST);

        c.setSize(600, 400);
        //... Set window characteristics
       //setContentPane(c);
       //setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       setTitle("Game");
        c.setVisible(true);
        pack();
Offline Mr_Light

Senior Member




shiny.


« Reply #1 - Posted 2006-12-18 16:50:43 »

try calling setVisible on Frame instead of the panel.

1  
 c.setVisible(true); -> setVisible(true);


also you might want to pack(); first and then display it as it will be faster.


on a differend note, blocks like

1  
2  
3  
//////////////////////////////
// bla
//////////////////////////////

is an indicator for me that someone is using ide's from the stoneage or no ide at all. That or your profiding support for those still on B/W monitors.
(next to the whole discussion that inline comments might be bad to begin with)

setting the sarcasm aside, in this case I'd would stick stuff in separate methods reguardless.

like:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
protected JPanel createGameArea() {
  JPanel gameArea = new JPanel();
  gameArea.add(game);
  gameArea.addMouseListener(new MouseAdapter() {
    public void mouseEntered(MouseEvent e) {
      game.requestFocus(true); // also try adding the param 'true'
   }
  });
  return gameArea;
}



It's harder to read code than to write it. - it's even harder to write readable code.

The gospel of brother Riven: "The guarantee that all bugs are in *your* code is worth gold." Amen brother a-m-e-n.
Offline jamesco

Senior Newbie





« Reply #2 - Posted 2006-12-19 02:26:09 »

oh ok thanks for the reply as for the comments

i just want to spilt the comments bigger well for my own reference will be changing soon

and also for my teammate to find the codes

anyway thanks for your help and tips

i still can't get the destopPane to pop up , i am jus going to try out more ways
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline jamesco

Senior Newbie





« Reply #3 - Posted 2006-12-22 07:09:51 »

anyway solved it by using jFrame thanks


any one has idea on how to make a certain JPanel focus in a container?
Offline Mr_Light

Senior Member




shiny.


« Reply #4 - Posted 2006-12-22 21:02:01 »

of the top of my head requestFocusInWindow();

in my reply I presumed you where using a JFrame, if I may ask what where you using before then?

It's harder to read code than to write it. - it's even harder to write readable code.

The gospel of brother Riven: "The guarantee that all bugs are in *your* code is worth gold." Amen brother a-m-e-n.
Offline jamesco

Senior Newbie





« Reply #5 - Posted 2006-12-27 03:10:01 »

was using JdesktopPane to call JInternalFrame

thanks

tried requestFocusInWindow(); doesn't work ;
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CogWheelz (15 views)
2014-07-30 21:08:39

Riven (22 views)
2014-07-29 18:09:19

Riven (14 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (32 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (42 views)
2014-07-24 01:59:36

Riven (42 views)
2014-07-23 21:16:32

Riven (30 views)
2014-07-23 21:07:15

Riven (31 views)
2014-07-23 20:56:16
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!