Java GUI help [modified]
-
Hi i have been searching the internet for days and couldn't find the answer .. so please bear with me ;) anyways i have been trying to solve this question .. the question goes as follow: Q: Write a program that fills the component with a large ellipse, filled with your favorite color that touches the window boundaries. The ellipse should resize itself when you resize the window. Guys all i wanna know is how to make it touch the boundaries and how to make it resize itself. Thank you.
modified on Tuesday, July 22, 2008 3:46 PM
-
Hi i have been searching the internet for days and couldn't find the answer .. so please bear with me ;) anyways i have been trying to solve this question .. the question goes as follow: Q: Write a program that fills the component with a large ellipse, filled with your favorite color that touches the window boundaries. The ellipse should resize itself when you resize the window. Guys all i wanna know is how to make it touch the boundaries and how to make it resize itself. Thank you.
modified on Tuesday, July 22, 2008 3:46 PM
how to make it touch the window ? easy :) draw it of the size of the component, and be sure the component is of the size of the window (in your window, add a panel, on which you can draw directly)... if you place the drawing code in the correct event handler, (overload paintComponent(Graphics)).
[VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]
-
how to make it touch the window ? easy :) draw it of the size of the component, and be sure the component is of the size of the window (in your window, add a panel, on which you can draw directly)... if you place the drawing code in the correct event handler, (overload paintComponent(Graphics)).
[VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]
thanx but i figured it out alrdy :) ... i really apprecite ur help ;) but here what i got recently ... i extracted it from netbeans XD this is an example using button instead of ellipse ;)
jButton1 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT\_ON\_CLOSE); jButton1.setText("jButton1"); jButton1.setMaximumSize(new java.awt.Dimension(73, 23)); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jButton1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT\_SIZE, 400, Short.MAX\_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jButton1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT\_SIZE, 300, Short.MAX\_VALUE) );
there u go i hope u also benefited ;)
BlaCk WolViX