| | |
how do i set background as an image with Jframe? ... and other stuff
![]() |
•
•
Join Date: Oct 2006
Posts: 116
Reputation:
Solved Threads: 0
ARG!!!!!!!!!!
This is really driving me nuts.
Can some one create a simple JFrame with two buttons(One realy big, one realy small) and have one bottom left and the other upper right and have the JFrame at a size of 800x800. I know how to make the buttons work, so listeners are not needed. I just need to see how to size and position things.
I tried using the Borderlayout with no succss. I tried add(button, BorderLayout.SOUTH) but it still goes north.
Please help me......
This is really driving me nuts.
Can some one create a simple JFrame with two buttons(One realy big, one realy small) and have one bottom left and the other upper right and have the JFrame at a size of 800x800. I know how to make the buttons work, so listeners are not needed. I just need to see how to size and position things.
I tried using the Borderlayout with no succss. I tried add(button, BorderLayout.SOUTH) but it still goes north.
Please help me......
Last edited by Mr.UNOwen; Mar 11th, 2007 at 6:00 pm.
•
•
•
•
Thanks for the help but now I'm pulling my hair out with another thing.... How do I properly position a button (or anything else), and have it at a locked size? Also how do I lock jframe?
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class a extends JFrame
{
// Variables declaration
private JButton jButton1;
private JPanel contentPane;
// End of variables declaration
public a()
{
super();
initializeComponent();
this.setVisible(true);
}
private void initializeComponent()
{
jButton1 = new JButton();
contentPane = (JPanel)this.getContentPane();
jButton1.setBackground(new Color(182, 169, 92));
jButton1.setText("jButton1");
jButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jButton1_actionPerformed(e);
}
});
contentPane.setLayout(null);
addComponent(contentPane, jButton1, 140,107,83,28);
this.setTitle("a - extends JFrame");
this.setLocation(new Point(0, 0));
this.setSize(new Dimension(390, 300));
}
private void addComponent(Container container,Component c,int x,int y,int width,int height)
{
c.setBounds(x,y,width,height);
container.add(c);
}
private void jButton1_actionPerformed(ActionEvent e)
{
System.out.println("\njButton1_actionPerformed(ActionEvent e) called.");
}
` public static void main(String[] args)
{
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
try
{
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
}
catch (Exception ex)
{
System.out.println("Failed loading L&F: ");
System.out.println(ex);
}
new a();
}
}
Adios,
Vinod......
Vinod......
![]() |
Similar Threads
- CSS - strech a background image? (Site Layout and Usability)
- problem with background image repeat-y (HTML and CSS)
- Background image flickers in IE.... (JavaScript / DHTML / AJAX)
Other Threads in the Java Forum
- Previous Thread: Java Swing : handling hyperlinks in JEditorPane
- Next Thread: button help
| Thread Tools | Search this Thread |
account android applet application apps array automation awt bidirectional binary birt bluetooth businessintelligence busy_handler(null) card class classes client code collision columns component constructor database designadrawingapplicationusingjavajslider draw eclipse error eventlistener exception expand fractal free game givemetehcodez graphics gui guidancer homework html ide image inheritance integer integration intellij j2me java javafx javamicroeditionuseofmotionsensor javaprojects jlabel jme jni jpanel jtextfield jtree julia linux loop method midlethttpconnection migrate mobile mobiledevelopmentcreatejar monitoring myaggfun netbeans newbie nullpointerexception open-source oracle plazmic print problem program property ria scanner server set sharepoint smart sms smsspam sourcelabs splash sql sqlite subclass support swing testautomation textfield threads tree trolltech unlimited utility windows






