JFrame/JPanel Problem

Hi all,
I'm having trouble chaging the backgound color of my JFrame. It contains a JList.
MY Code:
panel.setBackground(Color.black);
Please help. Thanks

What is panel? Is it your JFrame? I think you need to do getContentPane().setBackgroundColor()

Similar Messages

  • Urgent!!!!!!!! JFrame+JPanel problem

    How can I add a JFrame to a JPanel? What kind of objects can be contained Frames in at all?
    Thanks in advance

    Hi
    You cant add JFrame,JWindow,JApplet,JDialog to any other component.
    These are top level component and can not be added to any other.
    Ashish

  • JFrame Repaint problem

    I am new to Java Swing and I have a problem.
    I have a GUI program which extends JFrame and contains some business logic. In the middle of executing the business logic, I need to display a chart and I used another JFrame to display the chart. The chart did display but once the control return back to the original process, the chart Jframe turn blank. How can I get the display of the chart until user closes it?
    public class ChangeMetric extend JFrame implements ActionListener {
    public void actionPerformed(ActionEvent event) {
    JFrame jf = new JFrame();
    JPanel jp = new JPanel();
    jp.setSize(500,500);
    jf.getContentPane().add(jp);
    jf.setVisible(true);
    JOptionPane.showConfirmDialog(null, "Report has been saved to : " + path + "\n " +
                   "Do you want another report?", "Completed", JOptionPane.YES_NO_OPTION);
    //Jf turn blank after the JoptionPane displayed.
    Thanks in advance.
    Alex

    I need to display a chart and I used another JFrame to display the chart.An application should only have a single JFrame. Use a JDialog instead. You create it the same way you do a JFrame, the only difference is you specify the frame as the owner.
    Jf turn blank after the JoptionPane displayed.Then you must be doing something really wierd in your code. There is no reason for the option pane to have any effect on your dialog.
    And when you post your SSCCE, don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.

  • How to force to wait and get input from a jframe-jpanel?

    I would like to use a jframe-jpanel to get user input instead of using JOptionPane.showInputDialog since there will be more than 1 input.
    But I could not do it. The code reads the panel lines and passes to other lines below without waiting for the okay button to be pressed.
    This is the part of code of my main frame;
    jLabel10.setText(dene.toString());
    if (dene == 0) {
    // todo add button input panel
    //String todo_write = JOptionPane.showInputDialog("Please enter a todo item");
    JFrame frameTodoAddInput = new JFrame( "Please input..." );
    TodoAddAsk1JPanel todoaddpanel = new TodoAddAsk1JPanel();
    frameTodoAddInput.add(todoaddpanel);
    frameTodoAddInput.setSize( 600, 200 ); // set frame size
    frameTodoAddInput.setLocation(300, 300);
    //String todo_write = todoaddpanel.getNewTodoItem();
    String todo_write = todoaddpanel.getNewTodoItem();
    jLabel10.setText("Satir 1822 de".concat(todo_write));
    // end of todo add button input panel
    todoTextPane1.setText(todo_write);
    This is the code of input panel;
    * TodoAddAsk1JPanel.java
    * Created on May 6, 2007, 12:03 AM
    package javaa;
    public class TodoAddAsk1JPanel extends javax.swing.JPanel {
    /** Creates new form TodoAddAsk1JPanel */
    public TodoAddAsk1JPanel() {
    initComponents();
    private String NewTodoItem = "";
    public String getNewTodoItem() {
    NewTodoItem = ANewTodoItemTextField.getText();
    return this.NewTodoItem;
    /** This method is called from within the constructor to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">
    private void initComponents() {
    jLabel1 = new javax.swing.JLabel();
    ANewTodoItemTextField = new javax.swing.JTextField();
    jLabel2 = new javax.swing.JLabel();
    PriorityComboBox = new javax.swing.JComboBox();
    jLabel3 = new javax.swing.JLabel();
    DayValueComboBox = new javax.swing.JComboBox();
    MonthValueComboBox = new javax.swing.JComboBox();
    YearValueComboBox = new javax.swing.JComboBox();
    OkayButton = new javax.swing.JButton();
    CancelButton = new javax.swing.JButton();
    TimeValueComboBox = new javax.swing.JComboBox();
    jLabel1.setText("Please enter a todo item:");
    jLabel2.setText("Please select its priority level:");
    PriorityComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "A", "B", "C" }));
    jLabel3.setText("Please select its due date:");
    DayValueComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }));
    MonthValueComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }));
    YearValueComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "2007", "2008", "2009", "2010", "2011", "2012", "2013", "2014", "2015", "2016", "2017", "2018", "2019", "2020", "2021", "2022", "2023", "2024", "2025", "2026", "2027", "2028", "2029", "2030", "2031", "2032", "2033", "2034", "2035", "2036", "2037", "2038", "2039", "2040", "2041", "2042", "2043", "2044", "2045", "2046", "2047", "2048", "2049", "2050", "2051", "2052", "2053", "2054", "2055", "2056", "2057", "2058", "2059", "2060", "2061", "2062", "2063", "2064", "2065", "2066", "2067", "2068", "2069", "2070" }));
    OkayButton.setText("OK");
    OkayButton.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    OkayButtonActionPerformed(evt);
    CancelButton.setText("Cancel");
    TimeValueComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "08:30", "09:00", "09:30", "10:00", "10:30", "11:00", "11:30", "12:00", "12:30", "13:00", "13:30", "14:00", "14:30", "15:00", "15:30", "16:00", "16:30", "17:00", "17:30", "18:00", "18:30", "19:00", "19:30", "20:00", "20:30", "21:00", "21:30", "22:00", "22:30", "23:00", "23:30", "00:00", "00:30", "01:00", "01:30", "02:00", "02:30", "03:00", "03:30", "04:00", "04:30", "05:00", "05:30", "06:00", "06:30", "07:00", "07:30", "08:00" }));
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addContainerGap()
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
    .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 142, Short.MAX_VALUE)
    .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, 142, Short.MAX_VALUE))
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addComponent(PriorityComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(ANewTodoItemTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 279, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGroup(layout.createSequentialGroup()
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
    .addComponent(OkayButton, javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 133, Short.MAX_VALUE)
    .addComponent(CancelButton))
    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
    .addComponent(DayValueComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addComponent(MonthValueComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
    .addComponent(YearValueComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
    .addGap(13, 13, 13)
    .addComponent(TimeValueComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGap(42, 42, 42)))
    .addContainerGap())
    layout.setVerticalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addContainerGap()
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(ANewTodoItemTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(jLabel1))
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(jLabel2)
    .addComponent(PriorityComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(jLabel3)
    .addComponent(DayValueComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(MonthValueComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(YearValueComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(TimeValueComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addGap(18, 18, 18)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(OkayButton)
    .addComponent(CancelButton))
    .addContainerGap())
    }// </editor-fold>
    private void OkayButtonActionPerformed(java.awt.event.ActionEvent evt) {                                          
    // TODO add your handling code here:
    NewTodoItem = ANewTodoItemTextField.getText();
    // Variables declaration - do not modify
    private javax.swing.JTextField ANewTodoItemTextField;
    private javax.swing.JButton CancelButton;
    private javax.swing.JComboBox DayValueComboBox;
    private javax.swing.JComboBox MonthValueComboBox;
    private javax.swing.JButton OkayButton;
    private javax.swing.JComboBox PriorityComboBox;
    private javax.swing.JComboBox TimeValueComboBox;
    private javax.swing.JComboBox YearValueComboBox;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    // End of variables declaration
    I want to get the resulted input of "NewTodoItem"
    Thanks in advance for your kind help.
    Guven

    Thank you very much for your help. But I would like
    to get 3 inputs from 1 window at the same time and I
    could not find any example code for JDialog for more
    than 1 input. If any body can show how to write this
    code, it would be appreciated.
    ThanksYou can write your own. A JDialog is a container just look a JFrame is.

  • Problem with JFrame, JPanel and getInsets()...

    hi, this is my problem:
    I have a JFrame and I want add a JPanel to its ContentPan, I need to know the JFrame's getInsets values to set (with setBounds()) the right dimensions of the JPanel, but if I call getInsets() before of setVisible(true) I obtain all 0 values, if I call setVisible(true) before of add() I obtain the right values, but the JPanel is not showed.
    By now I have solved with this sequence:
    new panel();
    contpan.add(panel);
    getInsets();
    panel.setBounds();but I would pass the bounds values to my panel constructor, something like this:
    new panel(getInsets(););
    contpan.add(panel);Could someone help me?

    I have just found this post:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=302473
    And the first way seems to be the only way to solve the problem... :(
    Now the question is, does it exist a way to refresh a JFrame after that I have uset setVisible(true)?
    If it does exist I could have something like this:
    setVisible(true)
    new panel(getInsets(););
    contpan.add(panel);
    REFRESH();

  • GUI Problem (Swing JFrame/JPanel). HELP!

    Hi,
    I made an small application for calculate some things.
    I download i piece of code for creating bar chart and i icluded in my code. But i have problem when i am trying to show the chart in the Frame. All the buttons, textfields, labels goes to left and half are hiding.
    If i open the chart on a new frame i dont have problem.
    the problem apears when after i put the panel in the frame i try to put the chart in the frame. Look the code:
    add(p);     //Put the panel in the Frame
    this.getContentPane().add(new ChartPanel(values, names, "Fertilizer Plant")); // <-- The problem!!that command mades me the problem!
    Here are 2 screenshots
    1. When i put the chart in the Frame (the problem)
    http://www.iweb.gr/images/InFrame.jpg
    2. When i put the chart on new frame (works fine)
    http://www.iweb.gr/images/NewFrame.jpg
    Hopes someone can help. Thanks
    The code List:
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    //The main class of the program
    public class PlantFertilizer  extends JFrame{//The main class is a subclass of Frame
         private Label lN, lP,lK;//These show the value of the observable
         public TextField tN, tP, tK;
         private MyData thedata;//The observable we are going to watch
         private double[] values=new double[3];
        private String[] names=new String[3];
        private String title;
    public PlantFertilizer(){
         thedata=new MyData();// create the observable
         addWindowListener(new WindowAdapter(){//if user closes the Frame, quit
              public void windowClosing(WindowEvent e){
                   System.exit(0);
         setSize(400,500);//Set size
         setTitle(getClass().getName()+" By Pantelis Stoumpis");
         JPanel p = new JPanel();    //Make a panel for buttons and output
         //Input Data Area
         p.add(new Label("-------------------------Input Data Area--------------------------",Label.CENTER));
         p.add(new Label("Nitrogen (N)"));
         tN = new TextField();p.add(tN);
         p.add(new Label("Phosphorus (P)"));
         tP = new TextField();p.add(tP);
         p.add(new Label("Potassium (K)"));
         tK = new TextField();p.add(tK);
         lN=new Label("N = %", Label.CENTER);
         p.add(lN);     //Put the N label in the panel
         lP=new Label("P = %", Label.CENTER);
         p.add(lP);          //Put the P label in the panel
         lK=new Label("K = %", Label.CENTER);
         p.add(lK);          //Put the K label in the panel
         addButton(p,"Apply",          //Apply new Values
         new ActionListener(){
         public void actionPerformed(ActionEvent evt){
              int iNt = Integer.parseInt(tN.getText());
              int iPt = Integer.parseInt(tP.getText());
              int iKt = Integer.parseInt(tK.getText());
              thedata.addOne(iNt,iPt,iKt);          //which adds one to the observable
              JFrame f = new JFrame();
             f.setSize(400, 300);
              values[0] = 40;
             names[0] = "N";
             values[1] = 20;
             names[1] = "P";
             values[2] = 30;
             names[2] = "K";
             f.getContentPane().add(new ChartPanel(values, names, "Fertilizer Plant"));
              f.setVisible(true);
         addButton(p,"Close",          //add a close button to quit the program
         new ActionListener(){
         public void actionPerformed(ActionEvent evt){
              System.exit(0);
    add(p);     //Put the panel in the Frame
    this.getContentPane().add(new ChartPanel(values, names, "Fertilizer Plant")); // <-- The problem!!
    //A utility function to add a button with a given title and action
    public void addButton(Container c, String title,ActionListener a)
              Button b=new Button(title);
              c.add(b);
              b.addActionListener(a);
    public class ChartPanel extends JPanel {
      private double[] values;
      private String[] names;
      private String title;
      public ChartPanel(double[] v, String[] n, String t) {
        names = n;
        values = v;
        title = t;
      public void paintComponent(Graphics g) {
        super.paintComponent(g);
        if (values == null || values.length == 0)
          return;
        double minValue = 0;
        double maxValue = 0;
        for (int i = 0; i < values.length; i++) {
          if (minValue > values)
    minValue = values[i];
    if (maxValue < values[i])
    maxValue = values[i];
    //Dimension d = getSize();
    //int clientWidth = d.width;
    //int clientHeight = d.height;
    //int barWidth = clientWidth / values.length;
    //Dimension d = 100;
         int clientWidth = 100;
         int clientHeight = 150;
    int barWidth = clientWidth / values.length;
    Font titleFont = new Font("SansSerif", Font.BOLD, 12);
    FontMetrics titleFontMetrics = g.getFontMetrics(titleFont);
    Font labelFont = new Font("SansSerif", Font.PLAIN, 10);
    FontMetrics labelFontMetrics = g.getFontMetrics(labelFont);
    int titleWidth = titleFontMetrics.stringWidth(title);
    int y = titleFontMetrics.getAscent();
    int x = (clientWidth - titleWidth) / 2;
    g.setFont(titleFont);
    g.drawString(title, 10, 300);
    int top = titleFontMetrics.getHeight();
    int bottom = labelFontMetrics.getHeight();
    if (maxValue == minValue)
    return;
    double scale = (clientHeight - top - bottom) / (maxValue - minValue);
    y = clientHeight - labelFontMetrics.getDescent();
    g.setFont(labelFont);
    for (int i = 0; i < values.length; i++) {
    int valueX = i * barWidth + 1;
    int valueY = top;
    int height = (int) (values[i] * scale);
    if (values[i] >= 0)
    valueY += (int) ((maxValue - values[i]) * scale);
    else {
    valueY += (int) (maxValue * scale);
    height = -height;
    g.setColor(Color.red);
    g.fillRect(valueX, valueY, barWidth - 2, height);
    g.setColor(Color.black);
    g.drawRect(valueX, valueY, barWidth - 2, height);
    int labelWidth = labelFontMetrics.stringWidth(names[i]);
    x = i * barWidth + (barWidth - labelWidth) / 2;
    g.drawString(names[i], x, y);
    //main is called when we start the application
    public static void main(String[]args){
                   PlantFertilizer od = new PlantFertilizer();//make an observationsDemo frame
                   NWatcher watchitN = new NWatcher(od.lN);//make an observer
                   od.thedata.addObserver(watchitN);//register observer with the observable
                   PWatcher watchitP = new PWatcher(od.lP);//make an observer
                   od.thedata.addObserver(watchitP);//register observer with the observable
                   KWatcher watchitK = new KWatcher(od.lK);//make an observer
                   od.thedata.addObserver(watchitK);//register observer with the observable
                   od.setVisible(true);//show the frame on the screen

    Why are you putting Labels and TextFields (heavyweight AWT components) into a lightweight JPanels?
    What's the first rule of Swing? DO NOT MIX heavyweight AWT components and lightweight Swing components. Period. Never.
    There's Swing equivalents for every single AWT component, and then some. There's no excuse for not using them.
    However, if this chart library code is AWT based, then you should make a completely AWT based UI. Or find a different library based on Swing (like JFreeChart).
    And finally:
    add(p);     //Put the panel in the Frame
    this.getContentPane().add(new ChartPanel(values, names, "Fertilizer Plant")); // <-- The problem!!is wrong....
    add(p);      // <-- The problem!!
    this.getContentPane().add(new ChartPanel(values, names, "Fertilizer Plant"));You don't call add on JFrame or JDialog to add things to it, unless you know what you're doing. And you clearly don't, else you wouldn't have done it. What you probably want to do is this:
    this.getContentPane().add(p, BorderLayout.SOUTH);
    this.getContentPane().add(new ChartPanel(values, names, "Fertilizer Plant"), BorderLayout.CENTER);

  • JFrame restoration problem.

    Hello everyone!!
    My problem is:
    I have a jframe inside of that there's a jpanel.
    the jpanel mouse listener calls a method in a different class that uses the graphic reference of the jpanel to draw. once I minimize and maximize the jframe the drawing disappear. once I click on the area where drawing used to be it appears again.
    I have an inner window listener class in the jframe which calls the same method in the same instance of the other class but nothing happens until I click on the area on the mouse listener calls the method!!
    please help.

    Go through ths tutorial:
    The Java&#8482; Tutorials: [Performing Custom Painting|http://java.sun.com/docs/books/tutorial/uiswing/painting/index.html]
    After that, if you still have a question, post a SSCCE that clearly demonstrates the problem.
    db

  • Paint JPanel problem

    Hi All
    I have 2 classes
    class1. has a Jframe with a JPanel.
    class1 2. A Has a JPanel called contact
    I am calling class2 from class1.
    It is placing the the contact Panel onto the JPanel in class1 but does not show. If I resize class1 it the shows that it is there.
    I have tried repaint(); with out any luck
    any other help would be helpfull
    Thanks
    Craig

    Ok Here you go
    I have class1 witch is my main frame called Command class
    I have a menu class that has a jTree on it called Menu_Panel
    Then I have a class called DataClient which is the panel that I am have Problems with.
    Here is the Code
    This is the jbInit in the Command Class.
        mainPanel.setLayout(borderLayout3);
        mainPanel.setLayout(borderLayout4);
        topPanel = new Panel_Top();
        mainPanel.add(topPanel, BorderLayout.NORTH);
        menuPanel = new Menu_Panel();
        dataPanel = new DataPanel();
        setMenuItems();
        contentPane = (JPanel)this.getContentPane();
        contentPane.setLayout(borderLayout1);
        this.setSize(new Dimension(900, 600));
        this.setTitle("Frame Title");
        jMenuFile.add(jMenuFileExit);
        jMenuHelp.add(jMenuHelpAbout);
        jMenuBar1.add(jMenuFile);
        jMenuBar1.add(jMenuHelp);
        contentPane.add(mainPanel, BorderLayout.CENTER);
        mainPanel.add(menuPanel, BorderLayout.WEST);
        mainPanel.add(topPanel, BorderLayout.NORTH);
        mainPanel.add(dataPanel, BorderLayout.CENTER);
        mainPanel.revalidate();
        this.setJMenuBar(jMenuBar1);
        fontResize();
        menuPanel.setDataPanel(dataPanel);   // This is where the Menu_Panel calls the show of DataPanel This is from the Menu_Panel at which point fires the menuPanel.setDataPanel(dataPanel); in the Command Class.
    /** Required by TreeSelectionListener interface. */
      public void valueChanged(TreeSelectionEvent e) {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode)
            tree.getLastSelectedPathComponent();
        if (node != null) {
          fromMenu = tree.getLastSelectedPathComponent().toString();
          checkMenuNames ();
    public void checkMenuNames (){
      if(fromMenu.equals("Client")){
              dataPanel.showClient();
    }This is the DataPanel Class
    public class DataPanel
        extends JPanel {
      private DataClient dataClient;
      public void showClient() {
        //  dClient = new Data_Client();
    if (dataClient == null){
      System.out.println("This worked");
    dataClient = new DataClient();
    this.add(dataClient);
    }and this is the DataClient class
    public class DataClient  extends JPanel{
      XYLayout xYLayout1 = new XYLayout();
      JLabel jLabel1 = new JLabel();
      public DataClient() {
        try {
          jbInit();
        catch(Exception e) {
          e.printStackTrace();
      private void jbInit() throws Exception {
        jLabel1.setText("This is Client");
        this.setLayout(xYLayout1);
        this.add(jLabel1,    new XYConstraints(110, 95, 179, -1));
    }Hope you can help me :)
    Craig

  • A strange JPanel problem

    i have a JPanel which have a picture as a background the problem is when i wnat to add a JLabel or JTextField into this JPanel it didnt word but it works for labels bat JLabels no???why??
    here u are the code
    import java.util.*;
    import javax.swing.*;
    import java.awt.*;
    public class d extends Container
        JTextField text1,text2,text3,text4,text5,text6;
         ImageIcon icon ;
       public d()
    {  super();
       setLayout(null );                                                                         
        setBackground(Color.RED);                                                                                                 
        text1=new JTextField();
       text2=new JTextField();
       text3=new JTextField();
       text4=new JTextField();
       text5=new JTextField();
        text6=new JTextField();
        panel p=new panel();
       p.setBounds(10,10,500,500);
         p.setLayout(null);
         p.setOpaque(true);
    p.setBackground(Color.WHITE);
    text1.setBounds(160,30,100,20);
    p.add(text1);
    text2.setBounds(10,30,100,20);
      p.add(text2);
      text3.setBounds(300,30,100,20);
      p.add(text3);
      text4.setBounds(10,100,100,20);
      p.add(text4);
    text5.setBounds(160,100,100,20);
      p.add(text5);
      text6.setBounds(300,100,100,20);
      p.add(text6);
    JLabel l1=new JLabel("touti");
    l1.setBackground(Color.WHITE);
      l1.setBounds(10,10,80,15);
      add(p);
       class panel extends JPanel
           public  void paint(Graphics g) {
           super.paint(g);
           icon=new ImageIcon("c:/bachir.jpg");
            g.drawImage(icon.getImage(),0,0, this);
    public static void main(String args[])
       JFrame frm = new JFrame( "test panel back ground" );
            frm.setBounds( 100, 100, 800, 800 );
            frm.getContentPane().setLayout( new BorderLayout() );
        d pnl=new d();
            frm.getContentPane().add(pnl , BorderLayout.CENTER );
      frm.setIconImage(Toolkit.getDefaultToolkit().getImage("c:/java/oicon.gif"));
            frm.setVisible( true );
    }

    You seem to be mixing AWT and Swing. You should use all AWT or all Swing but not a mixture. Try changing
    public class d extends Container
    to
    public class d extends JPanel.
    P.S. Your choice of class name stinks! It does not describes the role the class plays and it does not meet the Sun recommended coding standards.
    Message was edited by:
    sabre150

  • Undecorated jframe resize problem

    i created a custom jframe look by setting a jframe to undecorated and designing my own maximize/minimize/close buttons and other things to improve its appearence
    the problem is that when set to undercorated all the default resizing/move methods are gone
    i tried implementing my own resize methods, they seem to work but it flashes like crazy while resizing
    anyone have any idea how to stop all the flashing or a better way to implement this?
    the following is a small example of the problem i am having, i only implemented the north resize part so the code can be easier to read.
    thnx in advance
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.imageio.*;
    import java.io.*;
    import java.awt.image.BufferedImage;
    public class TestFrame extends JFrame implements MouseMotionListener, MouseListener
         Point sp;
         int     compStartHeight;
         int minHeight = 100;
         JPanel frameContent = new JPanel();
         public TestFrame()
              super("testing frame");
              setSize(600, 600);
              setContentPane(frameContent);
              frameContent.setBackground(Color.black);
              frameContent.setLayout(new BoxLayout(frameContent, BoxLayout.Y_AXIS));     
              setUndecorated(true);
              addMouseMotionListener(this);
              addMouseListener(this);
              JButton testButton = new JButton("TEST");
              JButton testButton2 = new JButton ("TEST2");
              frameContent.add(testButton);
              frameContent.add(Box.createVerticalGlue());
              frameContent.add(testButton2);
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              setVisible(true);
         public void mouseMoved(MouseEvent e)
              Point p = e.getPoint();
              if (p.y > e.getComponent().getSize().height - 5)
                   setCursor( Cursor.getPredefinedCursor( Cursor.N_RESIZE_CURSOR ));
              else
                   setCursor( Cursor.getPredefinedCursor( Cursor.DEFAULT_CURSOR));
         public void mouseDragged(MouseEvent e)
              Point p = e.getPoint();
              int compWidth = getSize().width;
              if (getCursor().getType() == Cursor.N_RESIZE_CURSOR)
                   int nextHeight = compStartHeight+p.y-sp.y;
                   if (nextHeight > minHeight)
                        setSize(compWidth,nextHeight);
                        validate();
              else
                   int x = getX()+p.x-sp.x;     
                   int y = getY()+p.y-sp.y;     
                   setLocation(x,y);
         public void mousePressed(MouseEvent e)
              sp = e.getPoint();
              compStartHeight = getSize().height;
         public void mouseEntered(MouseEvent e)
        public void mouseExited(MouseEvent e)
              if (sp == null)
                   setCursor( Cursor.getPredefinedCursor( Cursor.DEFAULT_CURSOR));
        public void mouseClicked(MouseEvent e)
        public void mouseReleased(MouseEvent e)
              sp = null;
         public static void main(String[] args)
         new TestFrame();
    }

    I doubt there is a faster / easier way to resize.
    Have you tried adding
    public boolean isDoubleBuffered()
      return true;
    }To over-ride Component.isDoubleBuffered. This should sort out your flickering problem.
    Bamkin

  • Unexplained JFrame loading problems

    I keep getting a problem whenever i try and use a window that i extended off of JFrame. By its self the frame works perfectly, but when i actually try to use it for the purpose intended, the winow pops up, and is in the right spot, but nothing i put in it is visible. Any ideas?
    The class in question is called "PassFrame". It runs into the problem on lines 239-240 where i try to use it.
    import java.util.*;
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    public class Secrecy {
         private int[] code;
         private int[] cipher;
         private Dice dice;
         private GUI gui;
         private PassFrame passframe;
         public static final char SPACE = ' ';
         //if encrypting, crypt is true, decrypting, crypt is false
         //crypt is set to true by default
         boolean crypt = true;
         public Secrecy() {
              code = new int[93];
              cipher = new int[93];
              dice = new Dice(93);
         void setUp() {
              for(int i = 0; i < code.length; i++) {
                   code[i] = 32+i;
                   code[i] = -1;
         public void setSeed(char[] c) {
              dice.setSeed(seedSetter(c));
         public int seedSetter(char[] pass) {
              int i = 0;
              for(int j = 0; j < pass.length; j++) {
                   i += (int)pass[j];
              return i;
         static void frameWait(JFrame frame) {
              while(frame.isVisible()) {
                   nap(100);
         static void fileChooserWait(JFileChooser chooser) {
              while(chooser.isVisible()) {
                   nap(100);
         void generateCipher() {
              for(int i = 0; i < cipher.length; i++) {
                   int go = dice.roll();
                   if(cipher[go] == -1) {
                        cipher[go] = code;
         //takes input string and converts it using substitution of a different char sequence, then returns converted string
         String encrypt(String s) {
              String now = "";
              for(int i = 0; i < s.length(); i++) {
                   char c = s.charAt(i);
                   now += findMatch(c, crypt);
              return now;
         //looks through one char array to find a match of input char'c', returns corresponding char in different char array
         public int findMatch(char c, boolean b) {
              if(b) {
                   for(int j = 0; j < code.length; j++) {
                        if((int)c == code[j]) {
                             return cipher[j];
              }else{
                   for(int j = 0; j < cipher.length; j++) {
                        if((int)c == cipher[j]) {
                             return code[j];
              return (int)SPACE;          
         void runEncryption(JTextArea area, char[] password) {
              setSeed(password);
              String now = encrypt(area.getText());
              area.setText(now);
         static void nap(int ms) {
              try{
                   Thread.currentThread().sleep(ms);
              }catch (InterruptedException ivt) {
         static void center(JFrame frame) {
              Toolkit tk = Toolkit.getDefaultToolkit();
              Dimension d = tk.getScreenSize();
              frame.setLocation((d.width/2) - (frame.getWidth()/2), (d.height/2) - (frame.getHeight()/2));
         void runChooser() {
              ChooserFrame chooser = new ChooserFrame();
              fileChooserWait(chooser);
         void runPass(JTextArea area) {
              passframe.show();
              while(passframe.isVisible()) {
                   nap(100);
              char[] c = passframe.getPassword();
              setSeed(c);
              generateCipher();
              encrypt(area.getText());
         void run() {
              gui = new GUI(this);
              gui.show();
         public static void main(String[] args) {
              Secrecy sec = new Secrecy();
              sec.run();
    class PassFrame extends JFrame {
         private int length = 16;
         private char[] password;
         private JLabel label = new JLabel("Please enter your Password");
         private JPasswordField jpf = new JPasswordField(length);
         private JPanel panel = new JPanel();
         public PassFrame() {
              setTitle("Password");
              setResizable(false);
              panel.add(label);
              jpf.addKeyListener(new KeyAdapter() {
                   public void keyPressed(KeyEvent kvt) {
                        int code = kvt.getKeyCode();
                        if(code == KeyEvent.VK_ENTER) {
                             password = jpf.getPassword();
                             hide();
              addWindowListener(new WindowAdapter() {
                   public void windowClosing(WindowEvent evt) {
                        WindowCloser wc = new WindowCloser();
              panel.add(jpf);
              getContentPane().add(panel);
              pack();
              Secrecy.center(this);
         public char[] getPassword() {
              return password;
         void run() {
              Secrecy.center(this);
              show();
              Secrecy.frameWait(this);
              if(password != null) {
                   System.out.println(password);
         public static void main(String[] args) {
              PassFrame pf = new PassFrame();
              pf.run();
    class ChooserFrame extends JFileChooser {
         public ChooserFrame() {
    class GUI extends JFrame {
         private JButton encrypt;
         private JButton open;
         private JTextArea area;
         private JPanel panel;
         private JScrollPane pane;
         private Secrecy prog;
         public GUI(Secrecy sec) {
              addWindowListener(new WindowAdapter() {
                   public void windowClosing(WindowEvent evt) {
                        WindowCloser wc = new WindowCloser();
              prog = sec;
              encrypt = new JButton("Encrypt");
              open = new JButton("Open");
              area = new JTextArea();
              panel = new JPanel();
              setup();
              Secrecy.center(this);
         public void setup() {
              setupButtons();
              setupText();
              pack();
         void setupButtons() {
              encrypt.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent evt) {
                        PassFrame pf = new PassFrame();
                        pf.show();
                        Secrecy.frameWait(pf);     
                        System.out.println("Trying to run Encryption sequence");                    
                        prog.runEncryption(area, pf.getPassword());
              open.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent evt) {
                        prog.runChooser();
              getContentPane().add(encrypt, BorderLayout.EAST);
              getContentPane().add(open, BorderLayout.SOUTH);
         void setupText() {
              area = new JTextArea(10, 55);
              area.setLineWrap(true);
              area.setWrapStyleWord(true);
              pane = new JScrollPane(area);
              getContentPane().add(pane, BorderLayout.CENTER);
    class Dice {
         // random num generator
         static Random r;
         int sides;
         private static long seedLockVal;
         public Dice( int si ) {
              sides = si;
         public int roll() {
              return d( sides ) + 1;
         static {
              setSeedLock();
         public static int d( int what ) {
              if ( what <= 1 ) return 0;
              int val = r.nextInt() / 64;
              int v = (int)( val % what );
              if ( v < 0 ) v *= -1;
              return v;
         public static long setSeedLock() {     
              seedLockVal = System.currentTimeMillis();
              r = new Random( seedLockVal );
              return seedLockVal;
         public static void setSeed( long val ) {
              seedLockVal = val;
              r = new Random( val );
    class WindowCloser extends JFrame {
         JButton ok;
         JButton cancel;
         JLabel check;
         JLabel warning;
         JPanel panel;
         WindowCloser() {
              setResizable(false);
              check = new JLabel("Are you sure you wish to exit? You will lose all data.");
              warning = new JLabel("Closing this window will exit the program.");
              ok = new JButton("OK");
              cancel = new JButton("Cancel");
              ok.addActionListener( new ActionListener() {
                   public void actionPerformed(ActionEvent evt) {
                        System.exit(0);
              cancel.addActionListener( new ActionListener() {
                   public void actionPerformed(ActionEvent evt) {
                        hide();
              addWindowListener(new WindowAdapter() {
                   public void windowClosing(WindowEvent evt) {
                        System.exit(0);
              panel = new JPanel();
              panel.add(check);
              panel.add(warning);
              panel.add(ok);
              panel.add(cancel);
              getContentPane().add(panel);
              pack();
              Secrecy.center(this);
              show();
         public static void main(String[] args) {
              WindowCloser wc = new WindowCloser();

    Oh shit...
    Please post concise pieces of code where problems occur.
    Just a few remarks:
         static void fileChooserWait(JFileChooser chooser) {
              while(chooser.isVisible()) {
                   nap(100);
         }If you use JFileChooser#showXXXDialog, the method will block until the dialog has been disposed of (closed).
         WindowCloser() {
              setResizable(false);
    check = new JLabel("Are you sure you wish to exit?
    t? You will lose all data.");
    warning = new JLabel("Closing this window will exit
    it the program.");
              ok = new JButton("OK");
              cancel = new JButton("Cancel");Have a look at the static methods of the javax.swing.JOptionPane class. They're pretty useful.
    These remarks may not help you much, but I for one am not going to read all of this.
    Oh, and please acknowledge the [url http://forum.java.sun.com/help.jspa?sec=formatting]Formatting tips and post your code between [code[b]][[b]code] blocks.

  • Design issue using JFrame, JPanel, JLabel

    I have been working on this problems for several months now and I and nearly finished.
    I have a design question I hope others from this forum can provide some incite to the best approach.
    The problem space is a 8 X 8 Chessboard. I have designed a board using JPanels and JLables sitting inside a JFrame. In each square on the chessboard is a JLabel with an image. The "board" sits in the DEFAULT LAYER of a JLayeredPane. As the user clicks a specific square, a queen is placed in the square (8-queens problem). The only thing I do is swap out the image. All this works well--thanks to several of you from this forum. :-)
    When I add a new queen to the board, the application goes through the evaluation of attack positions. Next, the application should display the new chessboard with only the queens not threaten by other queens. I keep up with the chessboard using an boolean array internally. I build a second boolean array for the new or refreshed chessboard.
    What I want to do is build a second chessboard and "swap" it out with the one in the default layered pane. Can someone be so kind and shine some light on this design issue for me?
    Thank you for taking the time to read my post.

    I don't understand this approach. Swing is by default 'double buffered' and will not flicker. You will get this be default since this is one of the things the Swing painting model gives over AWT.
    You should look at just using JComponent and the paintComponent() method for drawing what you need.
    What I've done in the past is have a simple XML JDoM model. Have components that render themselves based on this model.
    Changing the model then I just issues a call to repaint() at the top level container.
    You can also add and remove items from the parent container. Then issue validate() or repaint(). Can't remember now but I think validate() hits the layout manager logic and then repaints.
    I'm pretty sure the Romain guy posted an example of how to easily draw a background chess board in a panel. ;-)
    The tree concept might really prove useful for a 'gaming tree' approach at the AI also.
    If you look at the Java3D API you will see they use a tree to represent what is rendered and the details about it. Really nice until you change something in the tree that cause the renderer to blow up. ;-)
    I guess the moral is always make small simple changes and test.
    Hope this is helpful.

  • Scaling JFrames/JPanels/JInternalFrames

    Hey,
    After having a lot of trouble trying to scale the contents of JFrames/JInternalFrames using mouse events, I decided that I should try using a popup menu to allow me to specify a certain content ratio to scale the container's contents.
    A little history: I wanted to be able to scale JInternalFrames so that the contents (images) maintain their aspect ratio. I modified my code via some suggestions, but the results were not as good as I wanted them to be. If you have any ideas on mouse scaling, I'd really appreciate them. Here's a link to an old forum thread: http://forum.java.sun.com/thread.jsp?forum=57&thread=149864
    Back to the present: Now the problem I'm having using the popup is that, if I scale to a size greater than 100%, the parent window will scale, but the child components will not scale. I've included a copy of the code below. Your suggestions will be greatly appreciated.
    TJDeep.
    Code:
    //ImagePanel.java
    /* This class defines a generic image panel that allows for:
    * - image resizing
    * - image containment
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class ImagePanel extends JPanel
        implements ComponentListener {
        //variables
        JFrame parent;
        ImagePanelPopupMenu popupMenu;
        JPopupMenuShower popupShower;
        Dimension originalDimension;
        boolean originalSet = false;
        public ImagePanel(JFrame parent) {
            this.parent = parent;
            init();
        private void init() {
            popupMenu = new ImagePanelPopupMenu(this);
            popupShower = new JPopupMenuShower(popupMenu);
            addMouseListener(popupShower);
            setLayout(new BorderLayout());
            addComponentListener(this);
        public void setOriginalDimension(Dimension dim) {
            originalDimension = new Dimension(dim);
        public Dimension getOriginalDimension() {
            return new Dimension(originalDimension);
        public void componentHidden(ComponentEvent ce) { }
        public void componentMoved(ComponentEvent ce) { }
        public void componentShown(ComponentEvent ce) { }
        public synchronized void componentResized(ComponentEvent ce) {
            Point parentOrigin = parent.getLocation();
            Dimension parentSize = parent.getSize();
            Dimension parentContentSize = parent.getContentPane().getSize();
            int deltaWidth = parentSize.width - parentContentSize.width;
            int deltaHeight = parentSize.height - parentContentSize.height;
            parent.getContentPane().setSize(getSize());
            parent.setBounds(parentOrigin.x, parentOrigin.y,
                           getSize().width + deltaWidth,
                           getSize().height + deltaHeight);
        public void paint(Graphics g) {
            g.dispose();
            g.setColor(Color.black);
            g.fillRect(0, 0, getSize().width, getSize().height);
            g.setColor(Color.white);
            g.drawRect(5, 5, getSize().width - 10, getSize().height - 10);
        public static void main(String[] args) {
            JFrame frame = new JFrame("Image Panel Test");
            Container contentPane = frame.getContentPane();
            frame.addWindowListener(new WindowAdapter() {
                    public void windowClosing(WindowEvent we) {
                        System.exit(0);
            ImagePanel imagePanel = new ImagePanel(frame);
            Dimension dim = new Dimension(200, 200);
            imagePanel.setOriginalDimension(dim);
            Dimension dim2 = new Dimension(500, 500);
            //imagePanel.setMaximumSize(dim2);
            imagePanel.setPreferredSize(dim);
            //imagePanel.setSize(dim);
            contentPane.add(imagePanel, BorderLayout.CENTER);
            frame.pack();
            //frame.setResizable(false);
            frame.setVisible(true);
            contentPane.setSize(imagePanel.getSize());
    class ImagePanelPopupMenu extends JPopupMenu
        implements ActionListener {
        //identification
        ImagePanel parent;
        //Menu items
        JMenuItem z050;
        JMenuItem z075;
        JMenuItem z100;
        JMenuItem z150;
        JMenuItem z200;
        JMenuItem zCustom;
        //Miscellaneous configuration
        Font defaultFont = new Font("Helvetica", Font.PLAIN, 10);
        public ImagePanelPopupMenu(ImagePanel parent) {
            super("ZOOM");
            this.parent = parent;
            setFont(defaultFont);
            //configure the menu elements
            z050 = new JMenuItem("50 %");
            z050.setActionCommand("z050");
            z050.setFont(defaultFont);
            z050.addActionListener(this);
            add(z050);
            z075 = new JMenuItem("75 %");
            z075.setActionCommand("z075");
            z075.setFont(defaultFont);
            z075.addActionListener(this);
            add(z075);
            z100 = new JMenuItem("100 %");
            z100.setActionCommand("z100");
            z100.setFont(defaultFont);
            z100.addActionListener(this);
            add(z100);
            z150 = new JMenuItem("150 %");
            z150.setActionCommand("z150");
            z150.setFont(defaultFont);
            z150.addActionListener(this);
            add(z150);
            z200 = new JMenuItem("200 %");
            z200.setActionCommand("z200");
            z200.setFont(defaultFont);
            z200.addActionListener(this);
            add(z200);
            zCustom = new JMenuItem("Custom...");
            zCustom.setActionCommand("zCustom");
            zCustom.setFont(defaultFont);
            zCustom.addActionListener(this);
            addSeparator();
            add(zCustom);
            pack();
        public void actionPerformed(ActionEvent ae) {
            String item = ae.getActionCommand();
            Dimension dim = new Dimension(parent.getSize());
            if (item.equals("z050")) {
                dim = computeDimension(50);
            else if (item.equals("z075")) {
                dim = computeDimension(75);
            else if (item.equals("z100")) {
                dim = computeDimension(100);
            else if (item.equals("z150")) {
                dim = computeDimension(150);
            else if (item.equals("z200")) {
                dim = computeDimension(200);
            else if (item.equals("zCustom")) {
                String inputString =
                    JOptionPane.showInputDialog(this, "Please enter a view percentage:",
                                                "Custom Zoom", JOptionPane.OK_CANCEL_OPTION);
                if (inputString == null) return;
                try {
                    double inputNumber = Double.parseDouble(inputString);
                    dim = computeDimension(inputNumber);
                } catch (NumberFormatException nfe) { }
            parent.setSize(dim);
            //parent.setBounds(0, 0, dim.width, dim.height);
            //modify for use with custom, and captions.
        public Dimension computeDimension(double percent) {
            double factor = percent/100;
            Dimension dim = parent.getOriginalDimension();
            dim.height *= factor;
            dim.width *= factor;
            return dim;
    class JPopupMenuShower extends MouseAdapter {
        private JPopupMenu popup;
        public JPopupMenuShower(JPopupMenu popup) {
            this.popup = popup;
        private void showIfPopupTrigger(MouseEvent me) {
            if (popup.isPopupTrigger(me))
                popup.show(me.getComponent(), me.getX(), me.getY());
        public void mousePressed(MouseEvent me) {
            showIfPopupTrigger(me);
        public void mouseReleased(MouseEvent me) {
            showIfPopupTrigger(me);
    }

    Isn't there anyone out there who can help me with this problem...
    TJDeep

  • JFRAME- JPANEL question

    I have a JFrame that holds a JPanel. If that JPanel needs to contact the JFrame how do I get access to parent? I tried panelname.getParent, when I did I got a
    java.lang.ClassCastException
    Any help would be great.
    Brock

    i think you have to buid your own JPanel class lyke this:
    public class MyJPanel extends JPanel{
    JFrame parent;
    public MyJPanel(JFrame p){
    parent = p;
    // here you have access to the parent JFrame in your JPanel
    public JFrame getParentFrame(){
    return parent;
    // here you return the parent of the JPanel
    so in your JFrame class you add the JPanel like this:
    getContentPane().add(new MyJpanel(this));
    i hope it helps you. :)

  • JFrame/JPanel background

    How do I set the background of a JPanel or JFrame to a gif instead of just a color
    thanks

    Hi all!
    Hope this helps, it works for me...
    public class BackgroundPanel extends JPanel {
    BufferedImage background = null;
    public BackgroundPanel(String imagepath) {
    setDoubleBuffered(true);
    setBackground(new Color(255,255,255,0));
    try{
    background = ImageIO.read(new File(imagepath));
    catch(java.io.IOException ioe) {
    System.out.println("Shit happens!" + ioe.getMessage());
    public void paint(Graphics g) {
    Graphics2D g2d = (Graphics2D) g;
    g2d.drawImage(background,0,0, background.getWidth(), background.getHeight(), this);
    super.paint(g);
    }

Maybe you are looking for

  • Vendor Text

    Hi, We need the vendor texts tobe pulled into PO header text. So I configure as follows: SPRO->IMG->Materials Management->PO->Texts for PO->Define copying rules for Header Texts. In header text linkages -> added the source object -"Vendor Master"  to

  • HT1420 how can I get a list of the computers authorized for iTunes?

    I am trying to associate a new MacBook to my iTunes account.  I am told that I have 5 computers already associated to the account.  The option I am presented is to deauthorize all 5, then start over.  Short of this, no other options are available.  I

  • Help re: lost Home Hub

    I was living in student accomodation untill the turn of the year, where a family incident lead to me moving home. We signed the 18 month contract for phone and broadband, and since the last of my then housemates have moved out, I tried to get hold of

  • I want to learn ebook designig and publishing. I am working in a press and known to InDesign for priting purpose.

    I want to learn ebook designig and publishing. I am working in a press and known to InDesign for priting purpose.

  • Battery time dramatically down after Leopard update

    I got my battery replaced in august 2006 (the battery exchange program). Before upgrading to Leopard I had a capacity of 4200mAh. Now with Leopard I only get 1475mAh. The computer will not even go to sleep when the battery runs out, it just shuts dow