JPanel without JFrame / JApplet / Window

hello,
I want to show a JPanel as an output without JFrame / JApplet / Window in background. My program ran successfully but without showing output.
Actually I dont want title bar in an output, thats why i have selected JPanel.
If anybody have idea about this plz tell me.
Regards
Nikhil

This code works for me,
import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class Forum extends JFrame {
     public Forum()
          setUndecorated(true);
          setBounds(100,100,400,400);
          JPanel pnl = new JPanel();
          JLabel lbl = new JLabel("THIS IS A LABEL IN A JPANEL IN AN UNDECORATED JFRAME");
          pnl.setBounds(0,0,400,300);
          pnl.setBackground(Color.CYAN);
          lbl.setBounds(0,0,200,100);
          pnl.add(lbl);
          getContentPane().add(pnl);
          setVisible(true);
     public static void main(String[] args) {
          Forum f = new Forum();
}Just a quick and dirty example to show it's possible;
~Tim

Similar Messages

  • Repost:  JPanel or JFrame Problem?

    Hello Everyone,
    I am working on a solitaire program. I am able to run and compile the program. Every time I resize the frame, I get small gray squares to the right of my buttons. Also, my cards get changed every time I resize the frame. Any suggestions are appreciated.
    Thanks,
    E
    //SolitaireProject.java
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class SolitaireProject extends JApplet
    public SolitaireProject()
    this.setContentPane(new SolitaireProjectPanel());
    public static void main(String[] args)
    JFrame window = new JFrame();
    window.setTitle("Solitaire by E");
    window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    window.setContentPane(new SolitaireProjectPanel());
    window.pack();
    window.show();
    //SolitaireProjectPanel.java
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.util.*;
    import java.applet.*;
    public class SolitaireProjectPanel extends JPanel
    private static final int CARD_WIDTH = 77;
    private static final int CARD_HEIGHT = 110;
    private final int ACES_DISTANCE_BETWEEN_CARDS = 97;
    private final int ACES_DISTANCE_FROM_LEFT = 425;
    private final int ACES_DISTANCE_FROM_TOP = 50;
    private final int ACES_MAXIMUM = 793;
    private final int PLAYCARDS_DISTANCE_FROM_LEFT = 300;
    private final int PLAYCARDS_DISTANCE_FROM_TOP = 200;
    private final int PLAYCARDS_DISTANCE_BETWEEN_COLUMNS = 87;
    private final int PLAYCARDS_DISTANCE_BETWEEN_ROWS_FACEDOWN = 5;
    private final int PLAYCARDS_DISTANCE_BETWEEN_ROWS_FACEUP = 30;
    private final int PLAYCARDS_MAXIMUM = 899;
    private final int PILE_DISTANCE_FROM_LEFT = 75;
    private final int PILE_DISTANCE_FROM_TOP = 50;
    private final int SHOWCARD_DISTANCE_FROM_LEFT = 75;
    private final int SHOWCARD_DISTANCE_FROM_TOP = 200;
    private int _initX = 0; // x coord - set from drag
    private int _initY = 0; // y coord - set from drag
    private Card[] _cardFronts = new Card[52]; //Creates an array of cards
    private Card _currentCard = null; //Current draggable card
    private Card[] _cardBacks = new Card[52];
    public SolitaireProjectPanel()
    String suits = "CDHS";
    String faces = "A23456789TJQK";
    int cardPosition = 0;
    int crdBackPosition = 0;
    for(int suit = 0; suit < suits.length(); suit++)
    for(int face = 0; face<faces.length(); face++)
    ImageIcon img = new ImageIcon("card " + faces.charAt(face) + suits.charAt(suit) + ".jpg");
    Image image = img.getImage();
    Image scaledImage = image.getScaledInstance(77, 110, Image.SCALE_FAST);
    img.setImage(scaledImage);
    _cardFronts[cardPosition ++] = new Card (img, _initX++, _initY++);
    for(int crdBack = 0; crdBack < 52; crdBack++)
    ImageIcon img2 = new ImageIcon("cardBack.jpg");
    Image image = img2.getImage();
    Image scaledImage = image.getScaledInstance(CARD_WIDTH, CARD_HEIGHT, Image.SCALE_FAST);
    img2.setImage(scaledImage);
    _cardBacks[crdBackPosition ++] = new Card (img2, _initX++, _initY++);
    //shuffle();
    JPanel setUpPanel = new JPanel();
    setPreferredSize(new Dimension(1000, 700));
    setBackground(Color.white);
    JButton newGameButton = new JButton("New Game");
    JButton exitButton = new JButton("Exit");
    exitButton.addActionListener(new ExitAction());
    newGameButton.addActionListener(new NewGameAction());
    this.add(newGameButton);
    this.add(exitButton);
    class ExitAction implements ActionListener
    public void actionPerformed(ActionEvent e)
    System.exit(0);
    class NewGameAction implements ActionListener
    public void actionPerformed(ActionEvent e)
    shuffle();
    repaint();
    public void paintComponent(Graphics g)
    shuffle();
    JPanel drawAndDealPanel = new JPanel();
    super.paintComponent(g);
    setBackground(Color.white);
    g.drawRect(PILE_DISTANCE_FROM_LEFT, PILE_DISTANCE_FROM_TOP, CARD_WIDTH, CARD_HEIGHT);
    g.drawRect(SHOWCARD_DISTANCE_FROM_LEFT, SHOWCARD_DISTANCE_FROM_TOP, CARD_WIDTH, CARD_HEIGHT);
    for(int position1 = ACES_DISTANCE_FROM_LEFT; position1 <= ACES_MAXIMUM; position1 += ACES_DISTANCE_BETWEEN_CARDS)
    g.drawRect(position1, ACES_DISTANCE_FROM_TOP, CARD_WIDTH, CARD_HEIGHT);
    for(int position2 = PLAYCARDS_DISTANCE_FROM_LEFT; position2 <= PLAYCARDS_MAXIMUM; position2 += PLAYCARDS_DISTANCE_BETWEEN_COLUMNS)
    g.drawRect(position2, PLAYCARDS_DISTANCE_FROM_TOP, CARD_WIDTH, CARD_HEIGHT);
    int crd1 = 1;
    int column1 = 300;
    int fromTop1 = PLAYCARDS_DISTANCE_FROM_TOP;
    Card cf = _cardFronts[crd1];
    cf.image.paintIcon(this, g, column1, fromTop1);
    crd1 = 2;
    column1 = 300 + PLAYCARDS_DISTANCE_BETWEEN_COLUMNS;
    for(int count = 0; count < 6; count ++)
    Card cb = _cardBacks[crd1];
    cb.image.paintIcon(this, g, column1, fromTop1);
    crd1 ++;
    column1 += PLAYCARDS_DISTANCE_BETWEEN_COLUMNS;
    int crd2 = 8;
    int column2 = 387;
    int fromTop2 = fromTop1 + PLAYCARDS_DISTANCE_BETWEEN_ROWS_FACEDOWN;
    cf = _cardFronts[crd2];
    cf.image.paintIcon(this, g, column2, fromTop2);
    crd2 = 9;
    column2 = 387 + PLAYCARDS_DISTANCE_BETWEEN_COLUMNS;
    for(int count = 0; count < 5; count ++)
    Card cb = _cardBacks[crd2];
    cb.image.paintIcon(this, g, column2, fromTop2);
    crd2 ++;
    column2 += PLAYCARDS_DISTANCE_BETWEEN_COLUMNS;
    int crd3 = 14;
    int column3 = 474;
    int fromTop3 = fromTop2 + PLAYCARDS_DISTANCE_BETWEEN_ROWS_FACEDOWN;
    cf = _cardFronts[crd3];
    cf.image.paintIcon(this, g, column3, fromTop3);
    crd3 = 15;
    column3 = 474 + PLAYCARDS_DISTANCE_BETWEEN_COLUMNS;
    for(int count = 0; count < 4; count ++)
    Card cb = _cardBacks[crd3];
    cb.image.paintIcon(this, g, column3, fromTop3);
    crd3 ++;
    column3 += PLAYCARDS_DISTANCE_BETWEEN_COLUMNS;
    int crd4 = 19;
    int column4 = 561;
    int fromTop4 = fromTop3 + PLAYCARDS_DISTANCE_BETWEEN_ROWS_FACEDOWN;
    cf = _cardFronts[crd4];
    cf.image.paintIcon(this, g, column4, fromTop4);
    crd4 = 20;
    column4 = 561 + PLAYCARDS_DISTANCE_BETWEEN_COLUMNS;
    for(int count = 0; count < 3; count ++)
    Card cb = _cardBacks[crd4];
    cb.image.paintIcon(this, g, column4, fromTop4);
    crd4 ++;
    column4 += PLAYCARDS_DISTANCE_BETWEEN_COLUMNS;
    int crd5 = 23;
    int column5 = 648;
    int fromTop5 = fromTop4 + PLAYCARDS_DISTANCE_BETWEEN_ROWS_FACEDOWN;
    cf = _cardFronts[crd5];
    cf.image.paintIcon(this, g, column5, fromTop5);
    crd5 = 24;
    column5 = 648 + PLAYCARDS_DISTANCE_BETWEEN_COLUMNS;
    for(int count = 0; count < 2; count ++)
    Card cb = _cardBacks[crd5];
    cb.image.paintIcon(this, g, column5, fromTop5);
    crd5 ++;
    column5 += PLAYCARDS_DISTANCE_BETWEEN_COLUMNS;
    int crd6 = 26;
    int column6 = 735;
    int fromTop6 = fromTop5 + PLAYCARDS_DISTANCE_BETWEEN_ROWS_FACEDOWN;
    cf = _cardFronts[crd6];
    cf.image.paintIcon(this, g, column6, fromTop6);
    crd6 = 27;
    column6 = 735 + PLAYCARDS_DISTANCE_BETWEEN_COLUMNS;
    for(int count = 0; count < 1; count ++)
    Card cb = _cardBacks[crd6];
    cb.image.paintIcon(this, g, column6, fromTop6);
    crd6 ++;
    column6 += PLAYCARDS_DISTANCE_BETWEEN_COLUMNS;
    int crd7 = 28;
    int column7 = 822;
    int fromTop7 = fromTop6 + PLAYCARDS_DISTANCE_BETWEEN_ROWS_FACEDOWN;
    cf = _cardFronts[crd7];
    cf.image.paintIcon(this, g, column7, fromTop7);
    for(int playCard = 29; playCard < 52; playCard ++)
    Card cb = _cardBacks[playCard];
    cb.image.paintIcon(this, g, PILE_DISTANCE_FROM_LEFT, PILE_DISTANCE_FROM_TOP);
    this.add(drawAndDealPanel);
    //shuffle
    public void shuffle()
    Random rgen = new Random();
    for (int i=0; i<52; i++)
    int randomPosition = rgen.nextInt(52);
    Card temp = _cardFronts;
    _cardFronts = _cardFronts[randomPosition];
    _cardFronts[randomPosition] = temp;
    class Card
    ImageIcon image;
    int x;
    int y;
    public Card(ImageIcon image, int x, int y)
    this.image = image;
    this.x = x;
    this.y = y;
    }

    Please don't crosspost. It cuts down on the effectiveness of responses, leads to people wasting their time answering what others have already answered, makes for difficult discussion, and is generally just annoying and bad form.
    P.S. Repost your CODE, not a new thread....
    &#167;

  • Create a new instance of a class without starting new windows.

    I've a class with basic SWING functions that displays an interface. Within this class is a method which updates the status bar on the interface. I want to be able to reference this method from other classes in order to update the status bar. However, in order to do this, I seem to have to create a new instance of the class which contains the SWING code, and therefore it creates a new window.
    Can somebody give me an example, showing how I might update a component on the interface without a new window being created.
    Many thanks in advance for any help offererd.

    I've a class with basic SWING functions that displays
    an interface. Within this class is a method which
    updates the status bar on the interface. I want to be
    able to reference this method from other classes in
    order to update the status bar. However, in order to
    do this, I seem to have to create a new instance of
    the class which contains the SWING code, and
    therefore it creates a new window.
    Can somebody give me an example, showing how I might
    update a component on the interface without a new
    window being created.
    Many thanks in advance for any help offererd.It sounds like you have a class that extends JFrame or such like and your code must be going
               Blah  test = new Blah();
                test.showStatus("text");Whereas all you need is a reference to that Classs.
    So in your class with basic SWING functions that displays an interface.
    You Might have something like this
              // The Label for displaying Status messages on
              JLabel statusLabel = new JLabel();
              this.add( statusLabel , BorderLayout.SOUTH );What you want to do is provide other Classes a 'method' for changing your Status Label, so in that class you might do something like:
          Allow Setting of Text in A JLabel From various Threads.
         And of course other classes......
         The JLabel statusLabel is a member of this class.
         ie defined in this class.
        @param inText    the new Text to display
       public void setStatusText( String inText )
                    final String x = inText;
                    SwingUtilities.invokeLater( new Runnable()
                              public void run()
                                       statusLabel.setText( x );
      }You still need a reference to your first class in your second class though.
    So you might have something like this:
            private firstClass firstClassReference;        // Store Reference
            public secondClass(  firstClass  oneWindow )
                          // create whatever.........
                         this.firstClassReference = oneWindow;
    // blah blah.
          private someMethod()
                            firstClassReference.setStatusText( "Hello from Second Class");
        }Hope that gives you some ideas

  • How can i transform MFC HWND into jpanel or jframe instance

    Hi!
    I want to open a MFC window, then with the HWND , i want to open java subwindow created inside the MFC window with the HWND, i wonder if there is a way. how can i transform the HWND into jpanel or jframe instance.

    Look at the article in CodeProject and read the example in it. The other questions you can send to my email because I cannot give you concrete response in this forum.

  • How to save component to jpg without jframe

    the code shows 2 methods to save component to jpg,
    but if comment
    f.getContentPane().add(lb);neither saveJPG_1() nor saveJPG_2() works.
    can you explain why and how to work without jframe?
    thanks.
    public class Test1 {
          * @param args
          * @throws Exception
         public static void main(String[] args) throws Exception {
              new Test1().run();
         private void run() throws IOException {
              JLabel lb = new JLabel("Test Text");
              lb.setOpaque(true);
              JFrame f = new JFrame();          
              f.getContentPane().add(lb);
              f.pack();
              saveJPG_1(lb, new File("test1.jpg"));
              saveJPG_2(lb, new File("test2.jpg"));
              f.dispose();
         private void saveJPG_1(Component c, File file) throws IOException {
              Dimension dim = c.getPreferredSize();
              Image im = c.createImage(dim.width,dim.height);     
              c.paint(im.getGraphics());          
              ImageIO.write((RenderedImage)im, "jpg", file);
         private void saveJPG_2(Component c, File file) throws IOException {
              Dimension dim = c.getPreferredSize();
              BufferedImage im = new BufferedImage(dim.width,dim.height,BufferedImage.TYPE_INT_RGB);                    
              c.paint(im.getGraphics());
              ImageIO.write(im, "jpg", file);
    }

    Lazy loading is common place among variety of
    systems.
    Java GUI runtime must be doing it because on my
    Linux/JDK 1.6(build 61), component c is null at:
    c.paint(....);
    when adding onto contentpane is commented out.Lazy loading means classes are loaded on demand and at the last moment possible. What makes you think that this allows for a variable to be null even after the component has been instantiated? And what does the Java "GUI runtime" have to do with it? It's the class loader that's responsible for this. It should be impossible for c to be null at that point in the code. You're using a beta JDK though right? Perhaps that's the culprit.
    the code shows 2 methods to save component to jpg,
    but if comment
    f.getContentPane().add(lb);neither saveJPG_1() nor saveJPG_2() works.
    can you explain why and how to work without jframe?
    thanks.
    public class Test1 {
          * @param args
          * @throws Exception
    public static void main(String[] args) throws
    s Exception {
              new Test1().run();
         private void run() throws IOException {
              JLabel lb = new JLabel("Test Text");
              lb.setOpaque(true);
              JFrame f = new JFrame();          
              f.getContentPane().add(lb);
              f.pack();
              saveJPG_1(lb, new File("test1.jpg"));
              saveJPG_2(lb, new File("test2.jpg"));
              f.dispose();
    private void saveJPG_1(Component c, File file)
    ) throws IOException {
              Dimension dim = c.getPreferredSize();
              Image im = c.createImage(dim.width,dim.height);     
              c.paint(im.getGraphics());          
              ImageIO.write((RenderedImage)im, "jpg", file);
    private void saveJPG_2(Component c, File file)
    ) throws IOException {
              Dimension dim = c.getPreferredSize();
    BufferedImage im = new
    ew
    BufferedImage(dim.width,dim.height,BufferedImage.TYPE_
    INT_RGB);                    
              c.paint(im.getGraphics());
              ImageIO.write(im, "jpg", file);
    Can you display a JPanel on the screen without help? No. At some level it has to go back to a heavyweight widget. In this case the JFrame is that widget, so without it or a supplement you can't create the graphics context to create an Image of what that JPanel would look like displayed.

  • Problem with JPanel in JFrame

    hai ashrivastava..
    thank u for sending this one..now i got some more problems with that screen .. actually i am added one JPanel to JFrame with BorderLayout at south..the problem is when i am drawing diagram..the part of diagram bellow JPanel is now not visible...and one more problem is ,after adding 6 ro 7 buttons remaing buttons are not vissible..how to increase the size of that JPanel...to add that JPanel i used bellow code
    JFrame f = new JFrame();
    JPanel panel = new JPanel();
    f.getContentPane().add(BorderLayout.SOUTH, panel);

    Hi
    JFrame f = new JFrame();
    JPanel panel = new JPanel();
    // Add this line to ur code with ur requiredWidth and requiredHeight
    panel.setPreferredSize(new Dimension(requiredWidth,requiredHeight));
    f.getContentPane().add(BorderLayout.SOUTH, panel);
    This should solve ur problem
    Ashish

  • Recovery mode without command or windows keys

    Hello,
    I am a mac newbie, but experienced linux and windows user. I am trying to restore my mac mini (mid 2011) running mavericks. The process should normally be very simple; press command-R keys while booting to start recovery mode and go from there.
    Unfortunately my keyboard is a palm-sized keyboard without command or windows keys. So I am stuck. I have 2 windows laptops that I can use to remote login but I cannot do remote login during boot.
    I tried mapping the Command key to Ctrl key inside OS X, but it seems like this only works after reboot.
    I tried to use recovery disk assistant as it requires "Option" key, but the assistant does not allow me select the HD, as I guess I do not have a recovery system on the HD.
    I tried doing network install, but it requires the install CD, which I don't have.
    Can you help me get out of this situation?  I have an ipad and two iphones if it helps.
    Thanks!

    I tried to use recovery disk assistant as it requires "Option" key, but the assistant does not allow me select the HD, as I guess I do not have a recovery system on the HD.
    If you mean holding down the OPTION (alt) key during restart, that takes you to the Startup Manager. AFAIK, there's no recovery disk assistant app in OS X. If you can't do that, then get an Apple keyboard. Without a recovery HD, you'll have to reinstall the OS.

  • Display image in JPanel without saving any file to disk

    Hi,
    I am fetching images from database. I am saving this image, display in JPanel and delete it. But this is not actually I want.
    I wish to fetch this image as stream , store in memory and display in JPanel without saving any fiel in disk.
    I wonder if it is Possible or any used implementation that I can use in my project. Any idea or experienced knowledge is enough.
    Thanks

    In what format is the image coming to you from the database? If it's an InputStream subclass, just use javax.imageio.ImageIO:
    InputStream in = getImageInputStream();
    BufferedImage image = null;
    try {
       image = ImageIO.read(in);
    } finally {
       in.close();
    // ... Display image in your JPanel as you have beenIf you receive the image as an array of bytes, use the same method as above, but with a ByteArrayInputStream:
    byte[] imageData = getImageData();
    ByteArrayInputStream in = new ByteArrayInputStream(imageData);
    BufferedImage image = null;
    try {
       image = ImageIO.read(in);
    } finally {
       in.close();
    // ... Display image in your JPanel as you have been

  • AppleScript: How to reload a Safari window without bring the window to the foreground while I am on other Desktop space

    I want to write an AppleScript to achive a simple task. That is, I open a Safari window on Desktop 1 and automatically reload every 30 minutes while I do my dialy work on desktop 2.
    Here is my script:
    tell application "Safari"
        activate
        tell application "System Events"
            tell process "Safari"
                keystroke "r" using {command down}
            end tell
        end tell
    end tell
    This script works. However, whenever the script is executed, my current Desktop 2 will be brought back to Desktop 1. It is distracting to my workflow.
    Is there any way to just let Safari to reload in the background without bring Safari window to foreground on Desktop 1?
    I have done a coumple of researches; many of them say I should not use "activate" in my script. I tried that but then the script will just do nothing.

    Hi, Hiroto
    your approach works perfectly fine. Thank you.
    I just found there is also a more generic approach without tweaking of javascript or any third party scripting language involed:
    #!/usr/bin/osascript
    tell application "Safari"
        set docUrl to URL of document 1
        set URL of document 1 to docUrl
    end tell
    From there, I can do a simple cron job task now.

  • Error in Smartforms a page without a main window

    Dear Friends
    I have suffred one problam in Smartforms, whe we create new page then system gives error
    "A page without a main window cannot point to itself as next page".
    Please provide solution.
    Regards
    Ajit Sharma

    Hello Ajit,
    In Smart Form Main window is optional but check if this satisfies in your case ....
    Main Window
    In a main window you display text and data, which can cover several pages (flow text). As soon
    as a main window is completely filled with text and data, the system continues displaying the text
    in the main window of the next page. It automatically triggers the page break.
    You can define only one window in a form as main window.
    The main window must have the same width on each page, but can differ in height.
    A page without main window must not call itself as next page, since this would trigger
    an endless loop. In such a case, the system automatically terminates after three
    pages.
    It means if you have Next page you need to use a Main window in your smart form.
    Regards,
    Kittu

  • Can i install windows 8.1 as a virtual machine without an existing windows os

    can i install windows 8.1 as a virtual machine without an existing windows os? I only have the download of 8.1, no cd.

    You have to download and run the setup.exe on a Windows system.
    That will then download Windows and you can choose at the end to create install media, then choose to save as an iso.
    It has to be done on a Windows machine and if you want to download 64 bit Windows it must be run on a 64 bit Windows machine.

  • Embedding PDF File into JPanel or JFrame

    Does anyone know how to embedd a PDF file or document into a JPanel or JFrame.

    I can suggest you ways
    1)pdf to Image
    2)pdf to html
    http://www.verypdf.com/pdf2htm/
    Free online service
    http://www.gohtm.com/

  • Xcopy without a command window....

    Hi,
    I need to download from the network a folder, not always the same folder as this will hopefully be pragmatically controlled, along with its sub folders, if present.
    As far as I can see the best option is xcopy, with its switches, or is there another option?
    Err = system ("xcopy /S/Q/Y/R/K \\\\NW_Drive\\Test_Fol\\TestDataSource\\Rel\\TestC​ode\\*.* C:\\Test_Loc\\test\\SRM\\");
    If it is to be xcopy can it be done without a command window or at least a small or minimized command window?
    Thanks for the help
    Simon
    Solved!
    Go to Solution.

    You may want to explore LaunceExecutableEx possibilities, especially for its ability to hide the launched program window. Keep in mind that this is an asynchronous call, so if you want to survey the process you need to save the handle returned by the command and periodically check its state with ExecutableHasTerminated () function.
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

  • Beginners Questions about Multiple JPanels in JFrame and event handling

    I am a newbie with SWING, and even a newerbie in Event Handling. So here goes.
    I am writing a maze program. I am placing a maze JPanel (MazePanel) at the center of a JFrame, and a JPanel of buttons (ButtonPanel) on the SOUTH pane. I want the buttons to be able to re-randomize the maze, solve the maze, and also ouput statistics (for percolation theory purposes). I have the backbone all done already, I am just creating the GUI now. I am just figuring out EventHandlers and such through the tutorials, but I have a question. I am adding an ActionListener to the buttons which are on the ButtonPanel which are on JFrame (SOUTH) Panel. But who do I make the ActionListener--Basically the one doing the work when the button is pressed. Do I make the JFrame the ActionListener or the MazePanel the ActionListener. I need something which has access to the maze data (the backbone), and which can call the Maze.randomize() function. I'm trying to make a good design and not just slop too.
    Also I was wondering if I do this
    JButton.addActionListener(MazePanel), and lets say public MazePanel implments ActionListenerdoesn't adding this whole big object to another object (namely the button actionlistener) seem really inefficient? And how does something that is nested in a JPanel on JFrame x get information from something nested in another JPanel on a JFrame x.
    Basically how is the Buttons going to talk to the maze when the maze is so far away?

    I'm not an expert, but here's what I'd do....
    You already have your business logic (the Maze classes), you said. I'm assuming you have some kind of public interface to this business logic. I would create a new class like "MazeGui" that extends JFrame, and then create the GUI using this class. Add buttons and panels as needed to get it to look the way you want. Then for each button that does a specific thing, add an anonymous ActionListener class to it and put whatever code you need inside the ActionListener that accesses the business logic classes and does what it needs to.
    This is the idea, though my code is totally unchecked and won't compile:
    import deadseasquirrels.mazestuff.*;
    public class MazeGui extends JFrame {
      JPanel buttonPanel = new JPanel();
      JPanel mazePanel = new JPanel();
      JButton randomizeB = new JButton();
      JButton solveB = new JButton();
      JButton statsB = new JButton();
      // create instanc(es) of your Maze business logic class(es)
      myMaze = new MazeClass();
      // add the components to the MazeGui content pane
      Component cp = getContentPane();
      cp.add(); // this doesn't do anything, but in your code you'd add
                // all of your components to the MazeGui's contentpane
      randomizeB.addActionListener(new ActionListener {
        void actionPerformed() {
          Maze newMaze = myMaze.getRandomMazeLayout();
          mazePanel.setContents(newMaze); // this is not a real method!
                                          // it's just to give you the idea
                                          // of how to manipulate the JPanel
                                          // representing your Maze diagram,
                                          // you will probably be changing a
                                          // subcomponent of the JPanel
      solveB.addActionListener(new ActionListener {
        void actionPerformed() {
          Solution mySolution = myMaze.getSolution();
          mazePanel.setContents(mySolution); // again, this is not a real
                                             // method but it shows you how
                                             // the ActionListener can
                                             // access your GUI
      // repeat with any other buttons you need
      public static void main(String[] args) {
        MazeGui mg = new MazeGui();
        mg.setVisible(true);
        // etc...
    }

  • Embeding PDF file into JPanel or JFrame

    Do any one have an idea on how to embed a PDF file into JPanel or JFrame?

    I can suggest you ways
    1)pdf to Image
    2)pdf to html
    http://www.verypdf.com/pdf2htm/
    Free online service
    http://www.gohtm.com/

Maybe you are looking for

  • Need to know how to better manage revolving users in a group

    I have a new Beehive Online group set up for a external partner collaboration. Members of the group are only from Oracle or that external partner. While the BHO group is new, the collaboration has been in place for a long time (since 2007). Initially

  • What is the problem with this event handler in LabView 8.0?

    Please find attached a copy of a simple Event Structure VI. Can anyone please tell me why the Pos 0, Pos 1, Pos 2 work fine, but Pos 3 does Not????? It works in Version 7.1 of Labview, but Not in version 8.0. Any help here would be appreciate Everyth

  • I have unwanted Plugins I want to remove and I can't find a way to do it

    I have plugins other users have installed and I have disabled them but i want to remove them from my browser and i can find way to remove them

  • I found a bug In LabView 2009!!!!!

    When i am using String to Spreadsheet function i observed that there is not effect of "format string" if i declare it as "%.1f", "%.2f","%.3f" and so on. whatever is the input format (Precision) the output will also be of same type. My input data an

  • Splitting of Columns in report

    Hi Guys,    Can some please help me with the following requirement. I have a report built on a multiprovider which brings 3 key figures from 3 different cubes. I have a user entry variable (CALMONTH1) which is used to restrict 2 of the key figures an