Jump to content

Java Gui


danielbrthwt

Recommended Posts

I am designing a GUI in java and i need to make a transparent box that is resizeable and all i have found is how to make the whole frame transparent

This is my GUI code

import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;

public class FloodItSolverGUI extends JFrame 
{
	private JButton scanButton;
	private JButton startButton;
	private JPanel window;

	private Board board = new Board();

	private String[][] rawData;


	public FloodItSolverGUI( String[][] Data )
	{	
		super("Flood-It Solver");
		setLayout( new FlowLayout() );
		rawData = Data;

		scanButton = new JButton( "Scan Board" );
		add( scanButton );

		startButton = new JButton( "Start" );
		add(startButton);

		ButtonHandler handler = new ButtonHandler();
		scanButton.addActionListener(handler);
		startButton.addActionListener(handler);

	}

	private class ButtonHandler implements ActionListener
	{

		@Override
		public void actionPerformed(ActionEvent arg0)
		{
			if ( arg0.getActionCommand() == "Scan Board" )
			{
				JOptionPane.showMessageDialog(FloodItSolverGUI.this, String.format("%s", "Sorry This Feture Is Not Available Yet"));
			}
			else if ( arg0.getActionCommand() == "Start" )
			{
				String Result = "";
				int[] results = board.runBot(rawData, 0);
				for ( int i = 0; i < results.length; i++ )
				{
					if ( results[i] != 0) Result += String.format("%d\n", results[i]);
				}
				JOptionPane.showMessageDialog(FloodItSolverGUI.this, Result);
			}
		}

	}

}

Edited by danielbrthwt
Link to comment
Share on other sites

What type of box is it that you need to make transparent?

I was hoping to create a 14, 14 square and then make it so i can see through the square to what ever is underneath transparent

Edited by danielbrthwt
Link to comment
Share on other sites

  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...