Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
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  
  Damn you Swing!  (Read 3091 times)
0 Members and 1 Guest are viewing this topic.
Offline Shin_Bet

Senior Newbie

« Posted 2006-01-21 21:55:56 »

Ok, i've made a variety of panels which ive put onto my frame. The problem is everything is gray! I used paintcomponent to put a nice background in and the damn thing doesnt show up! Help please? Huh Huh
Offline Grand Poeba

Junior Devvie

« Reply #1 - Posted 2006-01-21 23:51:51 »

do u use super.paint(g)?

layout used?

c-an you give some more info
Offline Shin_Bet

Senior Newbie

« Reply #2 - Posted 2006-01-21 23:59:54 »

class OpeningScreen extends JFrame implements ActionListener{
   Image BackGround = Toolkit.getDefaultToolkit().getImage("BackGroundOpen.gif");
   JPanel TeamPanel = new JPanel(); Border b1 = BorderFactory.createTitledBorder("Choose Your Team");
   JPanel HostPanel = new JPanel(); Border b2 = BorderFactory.createTitledBorder("Are you Host?");
   JPanel PlayPanel = new JPanel(); Border b3 = BorderFactory.createTitledBorder("Play!");
   Box LabelPanel = Box.createVerticalBox();
   boolean bool = false;
   JButton RED = new JButton("Red Team"); JButton BLUE = new JButton("Blue Team");
   JButton Host = new JButton("Host"); JButton Leech = new JButton("Leech");
   JButton Play = new JButton("Play!");
   JLabel QHost = new JLabel(); JLabel QTeam = new JLabel();
   char OpeningTeam = ' ';
   char OpeningHost = ' ';
   Test t;

      Font f = new Font("Comic Sans MS", Font.PLAIN, 30);
      Color c = Color.BLUE;
      PlayPanel.setLayout(new BorderLayout());
      HostPanel.setBorder(b2); TeamPanel.setBorder(b1); PlayPanel.setBorder(b3);
      PlayPanel.add(Play, BorderLayout.CENTER);
      HostPanel.add(Host); HostPanel.add(Leech);
      TeamPanel.add(RED); TeamPanel.add(BLUE);
      QHost.setFont(f); QTeam.setFont(f);
      QHost.setForeground(c); QTeam.setForeground(c);
      LabelPanel.add(Box.createRigidArea(new Dimension(30,60)));
      this.setLayout(new BorderLayout());
      this.add(HostPanel, BorderLayout.NORTH);
      this.add(TeamPanel, BorderLayout.SOUTH);
      this.add(PlayPanel, BorderLayout.EAST);
      this.add(LabelPanel, BorderLayout.CENTER);

    //public void paintComponent(Graphics g) {
    ///   g.drawImage(BackGround,10,10,this);

   public void actionPerformed(ActionEvent e){
      if(e.getSource() == Play){bool = true;t = new Test();}
      if(e.getSource() == RED){QTeam.setText("Red  ");OpeningTeam = 'R';}
      if(e.getSource() == BLUE){QTeam.setText("Blue ");OpeningTeam = 'B';}
      if(e.getSource() == Host){QHost.setText("Host ");OpeningHost = 'H';}
      if(e.getSource() == Leech){QHost.setText("Leech");OpeningHost = 'L';}

here is the code. i know it probaly sucks, but its for a final project, and i need to get that damn image there!Thanks
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Grand Poeba

Junior Devvie

« Reply #3 - Posted 2006-01-22 01:06:41 »

is it an image with transparant parts?

try adding super.paint(g);
to paint method
Offline Ask_Hjorth_Larsen

Junior Devvie

Java games rock!

« Reply #4 - Posted 2006-01-22 19:37:31 »

If this is really for a final project my first advice would be: please adhere to the java coding conventions. Identifiers should start with lower case letters. Also, your paintComponent method is obviously commented out. Third, if you add a large number of panels to to frame they will cover it. Therefore it doesn't matter what you draw in the paintComponent method, since the nontransparent panels will simply be drawn there instead.
Offline Shin_Bet

Senior Newbie

« Reply #5 - Posted 2006-01-24 23:30:16 »

Ok, thanks for the advice. It is only commented out because i was working on it without the image at the time i copied and pasted it. Not an error, i assure you.
How do i make an image semi-transparent?

Offline Ask_Hjorth_Larsen

Junior Devvie

Java games rock!

« Reply #6 - Posted 2006-01-25 16:44:17 »

I suppose what you want is to make the backgrounds of those PANELS transparent. That is done by calling .setOpaque(false). If you still want to tinker with images, check out java.awt.Transparency.
Pages: [1]
  ignore  |  Print  

EgonOlsen (42 views)
2018-06-10 19:43:48

EgonOlsen (22 views)
2018-06-10 19:43:44

EgonOlsen (43 views)
2018-06-10 19:43:20

DesertCoockie (197 views)
2018-05-13 18:23:11

nelsongames (124 views)
2018-04-24 18:15:36

nelsongames (123 views)
2018-04-24 18:14:32

ivj94 (864 views)
2018-03-24 14:47:39

ivj94 (125 views)
2018-03-24 14:46:31

ivj94 (768 views)
2018-03-24 14:43:53

Solater (140 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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‑
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!