danielbrthwt Posted January 20, 2012 Share Posted January 20, 2012 (edited) 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 January 20, 2012 by danielbrthwt Quote Link to comment Share on other sites More sharing options...
Sparda Posted January 20, 2012 Share Posted January 20, 2012 What type of box is it that you need to make transparent? Quote Link to comment Share on other sites More sharing options...
danielbrthwt Posted January 20, 2012 Author Share Posted January 20, 2012 (edited) 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 January 21, 2012 by danielbrthwt Quote Link to comment Share on other sites More sharing options...
Nanno Posted March 9, 2012 Share Posted March 9, 2012 Answer to an old topic, but i think you want to use a JPanel inside your JFrame and make the JPanel transparent. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.