JPanel or JFrame

Just a quick question, which is better
public class editor extends JPanel {
public class editor extends JFrame {

Good book will explain the difference, which you really need so you can understand the level of inheritance from Object class on down. Otherwise you will be doomed to posting meaningless, pointless questions....

Similar Messages

  • Problem with JPanel in JFrame

    hai ashrivastava..
    thank u for sending this 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 to increase the size of that add that JPanel i used bellow code
    JFrame f = new JFrame();
    JPanel panel = new JPanel();
    f.getContentPane().add(BorderLayout.SOUTH, panel);

    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

  • 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
    Free online service

  • 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();
        // etc...

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

    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.

  • 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
    Free online service

  • Help! Read raw Image data from a file and display on the JPanel or JFrame.

    PLEASE HELP, I want to Read Binary(Raw Image)data (16 bit integer) from a file and display on the JPanel or JFrame.

    I need to do the same thing. Did you find a way to do that?
    Could you sent me the code?
    It's urgent, please.
    My e-mail is [email protected]

  • How do you set an image into the background of a JPanel or JFrame?

    How do you set an image into the background of a JPanel or JFrame?

    Something like this, Ive thrown in an ImageIcon on a
    button too for good measure.
    import java.awt.*;
    import javax.swing.*;
    public class JFrameImage extends JFrame {
    public JFrameImage() {
    Container c    = getContentPane();
    JPanel panel = new JPanel(){
                 public void paintComponent(Graphics g)     {
    ImageIcon img = new
    = new ImageIcon("background.jpg");
                      g.drawImage(img.getImage(), 0, 0, null);
    ImageIcon icon = new ImageIcon("onButton.jpg");
    JButton button = new JButton(icon);
    public static void main(String[] args) {
    JFrameImage frame = new JFrameImage();
    Going totally fancy pants
    ImageIcon bigImage = new ImageIcon(bgImage.getImage().getScaledInstance(getWidth(), getHeight(),Image.SCALE_REPLICATE));
    g.drawImage(bigImage.getImage(), 0, 0, this); Will scale the image to the size of the panel
    for (int y = 0; y  < getHeight(); y = y + image.getHeight(null))
    for (int x = 0; x< getWidth(); x = x + image.getWidth(null))
    g.drawImage(image, x, y, this); Will give a tiled effect
    Try tiling with an animated gif and bring your processor to a standstill.

  • How to embed a Jpanel in JFrame

    I have made two JPanel classes
    and a JFrame class
    in netbean 5.5.1
    I want to embed that JPanel in the JFrame and when a button is clicked the ist JPanel dissaper and the second JPanel appears on the same JFrame..... i have tried to declare an object of that JPanel class in the JFrame
    Please Help

    One word: CardLayout

  • JPanel in jFrame

    I have a class which is basicly a jpannel
    public class pannel1 extends javax.swing.JPanel {
    public pannel1() {
    Now i have a different class which is basicly a jframe
    How can i display the jpannel class into the jframe class ?

    Read through the tutorials as recommended. However, in answer to your question, something like this.
    public class Class1 extends JPanel {
      //all your methods and jpanel sizes ommitted
    public class Main {
      public static void main(String[] args) {
         JFrame f = new JFrame();
        Class1 cl = new Class1();
    }Hope that helps.
    You can do others such as getContentPane().setContentPane(cl).
    This is just to get you started. All thread safety features have been ommited. Read about Swing thread safety after you get some understanding of Java Swing.

  • Weird problem with jpanel vs jframe

    I'm using jmathplot.jar from JMathTools which lets me do 3d plotting. I used a JFrame to get some code to work and it worked fine. Here's the code that worked for a JFrame:
    public class View extends JFrame
        private Model myModel;
        private Plot3DPanel myPanel;
        // ... Components
        public View(Model m)
            myModel = m; 
            // ... Initialize components
            myPanel = new Plot3DPanel("SOUTH");
            setSize(600, 600);
    }Here's the class that starts everything:
    public class TestApplet extends JApplet
        public void init()
            //Execute a job on the event-dispatching thread; creating this applet's GUI.
                SwingUtilities.invokeAndWait(new Runnable()
                    public void run()
            catch (Exception e)
        private void createGUI()
            System.out.println("Creating GUI");
            Model model = new Model();
            View view = new View(model);
    }And here's the Model:
    public class Model
        private double[] myXRange,myYRange;
        private double[][] myZValues;
        public Model()
        public double[] getXRange()
            return myXRange;
        public double[] getYRange()
            return myYRange;
        public double[][] getZValues()
            return myZValues;
        private void createDataSet()
            myXRange = new double[10];
            myYRange = new double[10];
            myZValues = new double[10][10];
            for(double i=0;i<10;i++)
                for(double j=0;j<10;j++)
                    double x = i/10;
                    double y = j/10;
                    myXRange[(int) i] = x;
                    myYRange[(int) j] = y;
                    myZValues[(int) i][(int) j]= Math.cos(x*Math.PI)*Math.sin(y*Math.PI);
    }However, as you can see, my main class is a JApplet because ideally I want View to be a JPanel that I add to the applet. All I did was change "extends JFrame" to "extends JApplet" and changed:
    setSize(600, 600);
    this.add(myPanel);and added these two lines to createGUI():
            setContentPane(view);When I run it however, it appears really really small. It seems like its drawing the panel to the default size of the applet viewer and doesn't resize it when I resize the applet. I don't know if it's a problem with the library or if I'm doing something wrong in my applet.

    However, as you can see, my main class is a JApplet because ideally I want View to be a JPanel that I add to the applet. All I did was change "extends JFrame" to "extends JApplet" and (...)What do you mean? View extends JApplet? I thought View was meant to extend JPanel in the end...
    When I run it however, it appears really really small. It seems like its drawing the panel to the default size of the applet viewer and doesn't resize it when I resize the applet.Or, the panel has its preferred size, and this latter is too small. Actually the panel has the size its container's layout manager awards it (taking or not the panel's preferred, minimum, and maximum sizes into account). See the tutorial on [layout managers|] .
    In particular, this line adds the myPanel to a parent panel (presumably, it is in class View which extends JPanel, whose default layout is FlowLayout):
    I don't know if it's a problem with the library or if I'm doing something wrong in my applet.Likely not (presumably the library interfers only in how it computes the Plot3DPanel's preferred size). There's an easy way to tell: try to layout correctly a custom JPanel of yours, containing only e.g. a button with an icon. Once you understand the basics of layout management, revisit the example using ther 3rd-party library.
    N.B.: there are a lot of "likely" and "presumably" in my reply: in order to avoid hardly-educated guesses especially on what is or isn't in your actual code, you'd better provide an SSCCE , which means reproducing the problem without the 3rd party library.

  • Adding Canvas3D image to a JPanel or JFrame

    My team has developed a 3D game board and we want to add it to a JPanel. The test code below works fine but we want to add this to a JPanel. Can you put a Canvas3D in a JPanel?
    import java.applet.Applet;
    import java.awt.BorderLayout;
    import java.awt.Frame;
    import java.awt.event.*;
    import com.sun.j3d.utils.applet.MainFrame;
    import com.sun.j3d.utils.universe.*;
    import com.sun.j3d.utils.geometry.*;
    import javax.vecmath.*;
    import java.awt.event.*;
    import java.util.Enumeration;
    import com.sun.j3d.utils.behaviors.mouse.*;
    import com.sun.j3d.utils.behaviors.keyboard.*;
    public class ProxyBoard extends Applet
         public class SimpleBehave extends Behavior
              private TransformGroup targetTG;
              private Transform3D rotation = new Transform3D();
              private double angle = 0.0;
              SimpleBehave(TransformGroup targetTG)
                   this.targetTG = targetTG;
              public void initialize()
                   this.wakeupOn(new WakeupOnAWTEvent(KeyEvent.KEY_PRESSED));
              public void processStimulus(Enumeration criteria)
                   angle +=0.05;
                   this.wakeupOn(new WakeupOnAWTEvent(KeyEvent.KEY_PRESSED));
         public ProxyBoard()
              setLayout(new BorderLayout());
              Canvas3D canvas3D = new Canvas3D(null);
              add("Center", canvas3D);
              SimpleUniverse simpleU = new SimpleUniverse(canvas3D);
              BranchGroup scene = createSceneGraph(simpleU);
         public BranchGroup createSceneGraph(SimpleUniverse su)
              BranchGroup boardBG = new BranchGroup();
              TransformGroup vpTrans = null;
              BoundingSphere mouseBounds = null;
              vpTrans = su.getViewingPlatform().getViewPlatformTransform();
              mouseBounds = new BoundingSphere(new Point3d(), 1000.0);
              KeyNavigatorBehavior keyNavBeh = new KeyNavigatorBehavior(vpTrans);
              MouseRotate myMouseRotate = new MouseRotate(MouseBehavior.INVERT_INPUT);
              MouseTranslate myMouseTranslate = new MouseTranslate(MouseBehavior.INVERT_INPUT);
              MouseZoom myMouseZoom = new MouseZoom(MouseBehavior.INVERT_INPUT);
              Board board = new Board();
              Transform3D pegPositions[] = new Transform3D[8];
              TransformGroup pegPositionsTG[] = new TransformGroup[8];
              Pegs pegs[] = new Pegs[8];
              Transform3D translate = new Transform3D();
              translate.set(new Vector3f(0.0f, -1.0f, -5.0f));
              TransformGroup boardTGT1 = new TransformGroup(translate);
              TransformGroup boardTGR1 = new TransformGroup();
              for(int i = 0; i < 8; i++)
                   pegs[i] = new Pegs();
                   pegPositions[i] = new Transform3D();
                   pegPositions.set(new Vector3f(-2.5f, 0, (float)(-i/4.0)));
                   pegPositionsTG[i] = new TransformGroup(pegPositions[i]);
              SimpleBehave myRotate = new SimpleBehave(boardTGR1);
              myRotate.setSchedulingBounds(new BoundingSphere());
              return boardBG;
         public static void main(String[] args)
              Frame frame = new MainFrame(new ProxyBoard(), 800, 600);
    /*-------------Main Source Container------------------*/
    public class Proxy extends JFrame
         implements MouseMotionListener
         private JDesktopPane myDesktop;
         private JPanel panel;
         private JLabel statusBar, position;
         private JSlider zSlide, zSlide1;
         private ImageIcon test;
         private int i;
         public Proxy()
              super("Proxy Board Prototype 1.2.2");
              statusBar = new JLabel();
              myDesktop = new JDesktopPane();
    public static void main(String args[])
              Proxy app = new Proxy();
              //new MainFrame( new Proxy(), 800, 600 );
    //          app.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    /*-------------JPanel I want to hold to the 3D Graphics--------*/
    class Session extends JPanel
         implements MouseMotionListener
         private ImageIcon test;
         private JLabel position;
         private JSlider zSlide;
         private JPanel panel, gPanel;
         static int openFrameCount = 0;
         public Session()
              //super("", true, true, true, true);
              setLayout(new FlowLayout());
         //setTitle("Untitled Message " + openFrameCount);
    ProxyBoard pb = new ProxyBoard();//<-Graphic Class
    gPanel = new JPanel();
    gPanel.add(pb);//<-I want the 3D Graphic here
              test = new ImageIcon("Layout.jpg");
              JLabel pic = new JLabel(test);
              addMouseMotionListener( this );
              zSlide = new JSlider(SwingConstants.VERTICAL, 600, 10);
              panel.add(zSlide, BorderLayout.NORTH);
              panel.add(gPanel, BorderLayout.CENTER);//<-Graphic Here
              panel.add(position, BorderLayout.SOUTH);
              setVisible (true);

    Yes you can. Just use the add method of JPanel. However note this (specially read this:
    when mixing Lightweight (JPanel) and Heavyweight (Canvas3D) components.

  • JTable on JPanel on JFrame, not appearing

    I can't see the JTable that I was expecting to between the two labels, any ideas why?
    public class Workout extends JFrame {
            final String[] exercisesDoneColumnNames = {"Exercise", "# Sets", "Set 1", "Set 2", "Set 3", "Set 4", "Set 5", "Set 6", "Set 7", "Set 8", "Set 9", "Set 10"};
            private ExercisesDoneTable myModel = new ExercisesDoneTable exercisesDoneColumnNames,0);
            private JTable table = new JTable(myModel);
            public Workout() {
                Toolkit tk = Toolkit.getDefaultToolkit();
                Dimension d = new Dimension();
                d = tk.getScreenSize();
                setSize((int)d.getWidth(), (int)d.getHeight());
                addWindowListener(new java.awt.event.WindowAdapter() {
                    public void windowClosing(java.awt.event.WindowEvent evt) {   
                JPanel p = new JPanel();
                p.add(new JLabel("left of"));
                p.add(new JLabel("right of"));
        //helper method just splits the code to make it more readable
        private void buildExerciseDoneTable(){
            table.setPreferredScrollableViewportSize(new Dimension(500,100));

    JPanel has a default FlowLayout.
    I think you table is there, but is not displaying anything as you have specified 0 rows when creating your table model. Change that number to 1 and you will see it appear.

  • 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.
    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.setContentPane(new SolitaireProjectPanel());
    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_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);
    _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);
    _cardBacks[crdBackPosition ++] = new Card (img2, _initX++, _initY++);
    JPanel setUpPanel = new JPanel();
    setPreferredSize(new Dimension(1000, 700));
    JButton newGameButton = new JButton("New Game");
    JButton exitButton = new JButton("Exit");
    exitButton.addActionListener(new ExitAction());
    newGameButton.addActionListener(new NewGameAction());
    class ExitAction implements ActionListener
    public void actionPerformed(ActionEvent e)
    class NewGameAction implements ActionListener
    public void actionPerformed(ActionEvent e)
    public void paintComponent(Graphics g)
    JPanel drawAndDealPanel = new JPanel();
    for(int position1 = ACES_DISTANCE_FROM_LEFT; position1 <= ACES_MAXIMUM; position1 += ACES_DISTANCE_BETWEEN_CARDS)
    int crd1 = 1;
    int column1 = 300;
    Card cf = _cardFronts[crd1];
    cf.image.paintIcon(this, g, column1, fromTop1);
    crd1 = 2;
    for(int count = 0; count < 6; count ++)
    Card cb = _cardBacks[crd1];
    cb.image.paintIcon(this, g, column1, fromTop1);
    crd1 ++;
    int crd2 = 8;
    int column2 = 387;
    cf = _cardFronts[crd2];
    cf.image.paintIcon(this, g, column2, fromTop2);
    crd2 = 9;
    for(int count = 0; count < 5; count ++)
    Card cb = _cardBacks[crd2];
    cb.image.paintIcon(this, g, column2, fromTop2);
    crd2 ++;
    int crd3 = 14;
    int column3 = 474;
    cf = _cardFronts[crd3];
    cf.image.paintIcon(this, g, column3, fromTop3);
    crd3 = 15;
    for(int count = 0; count < 4; count ++)
    Card cb = _cardBacks[crd3];
    cb.image.paintIcon(this, g, column3, fromTop3);
    crd3 ++;
    int crd4 = 19;
    int column4 = 561;
    cf = _cardFronts[crd4];
    cf.image.paintIcon(this, g, column4, fromTop4);
    crd4 = 20;
    for(int count = 0; count < 3; count ++)
    Card cb = _cardBacks[crd4];
    cb.image.paintIcon(this, g, column4, fromTop4);
    crd4 ++;
    int crd5 = 23;
    int column5 = 648;
    cf = _cardFronts[crd5];
    cf.image.paintIcon(this, g, column5, fromTop5);
    crd5 = 24;
    for(int count = 0; count < 2; count ++)
    Card cb = _cardBacks[crd5];
    cb.image.paintIcon(this, g, column5, fromTop5);
    crd5 ++;
    int crd6 = 26;
    int column6 = 735;
    cf = _cardFronts[crd6];
    cf.image.paintIcon(this, g, column6, fromTop6);
    crd6 = 27;
    for(int count = 0; count < 1; count ++)
    Card cb = _cardBacks[crd6];
    cb.image.paintIcon(this, g, column6, fromTop6);
    crd6 ++;
    int crd7 = 28;
    int column7 = 822;
    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);
    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....

  • Using JPanel with JFrame

    I am using a JFrame to encapsulate my program. I want to have a JPanel inside my JFrame to handle all of my 2d displaying (like fillRect() etc...). I used forte to set this up but I am having problems dispaying on the JPanel. Here is my code:
    here is how I call the function from the main .java file
    I dubuged this and know it works (proof will come later)
    private void Start_ButtonActionPerformed(java.awt.event.ActionEvent evt)
    here is my entire JPanel class
    import java.awt.*;
    import javax.swing.*;
    public class Display extends javax.swing.JPanel
    public Display() {
    public void paintComponent(Graphics g )
    public void draw()
    this.repaint(); //i also tried repaint() but it didn't work either
    private void initComponents()
    setLayout(new java.awt.BorderLayout());
    when I press the start button, 1 and 2 are displayed but 3 isn't. For some reason the repaint() function is not telling the paintComponent function to work. Any help is appreciated.

    After doing the super.paintComponent(g); you must use Graphics2D. So you next line should cast your graphics object to a graphics 2D object, like this. Graphics2D g2 = (Graphics2D)g;

  • JPanel without JFrame / JApplet / Window

    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.

    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()
              JPanel pnl = new JPanel();
              JLabel lbl = new JLabel("THIS IS A LABEL IN A JPANEL IN AN UNDECORATED JFRAME");
         public static void main(String[] args) {
              Forum f = new Forum();
    }Just a quick and dirty example to show it's possible;

Maybe you are looking for

  • Need information on 'Repeat Delta' process

    Deleted failed request from InfoCube 0PY_C02 Checked Data Mart Status from ODS ZPY_O50 for failed load. When attempting to push the data from the ODS to InfoCube get error message:      Last delta update is not yet completed      Therefore, no new de

  • Putting frame with buttons into a thread

    please help!!! i've got a thread: package aJile; import*; import*; public class SocketHandler extends Thread   private Socket socket;               // Socket used for messages    private int socketNr;   private byte[] inbuf;   priv

  • OS X refuses to shut down

    Anyone know how to shut down my imac? Aperture is frozen and won't stop. This prevents my system from shutting down. Anyone knows a solution?

  • Using BFILE pointer to point to xml data on ifs

    hai all, i need to create a table in which one of the columns is a BFILE pointer which points to XML/HTML/IMAGE content which is stored on iFS(internet file system).how do i go about it? is there any limit on the number of BFILE pointers columns that

  • Doubt in Validation

    Hi All, I need to validate the input given by the user in Table Maintenance Screen. So i used Table Maintenace -> Environment -> Events option to do that. In that , i configured such that whenever a new entry is created, my validation subroutine will