473,789 Members | 2,732 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GridbagLayout and Canvas3D

this short program does not do as it should!!! when you resize the frame,
the weights (3 and 1) would not stay the same. why???

import java.applet.App let;
import java.awt.event. *;
import java.util.*;
import java.awt.*;
import com.sun.j3d.uti ls.universe.*;
import javax.swing.*;
import javax.media.j3d .*;
import java.applet.*;
import javax.swing.*;
import com.sun.j3d.uti ls.applet.MainF rame;

public class GridbagLayout1 extends JApplet{
public GridbagLayout1( ) {
setSize(800,600 );
setBackground(C olor.yellow);
GridBagLayout gbl = new GridBagLayout() ;
getContentPane( ).setLayout(gbl );
GridBagConstrai nts c = new GridBagConstrai nts();
GraphicsConfigu ration config=
SimpleUniverse. getPreferredCon figuration();
Canvas3D c3d=new Canvas3D(config );
c.fill = GridBagConstrai nts.BOTH;
c.weightx = 1;
c.weighty = 1;
c.insets = new Insets(0,0,0,0) ;
JPanel pan1 = new JPanel();
JPanel pan2 = new JPanel();
pan2.setBackgro und(new Color(200,200,0 ));
c.gridx = 0;
c.gridy = 0;
c.gridwidth = 1;
c.gridheight = 1;
gbl.setConstrai nts(c3d, c);
getContentPane( ).add(c3d);
c.gridx = 1;
c.weightx = 3;
gbl.setConstrai nts(pan2, c);
getContentPane( ).add(pan2);
}

public static void main(String argv[]) {
MainFrame a=new MainFrame(new GridbagLayout1( ),1000,1000);
}
}
Jul 17 '05 #1
0 1423

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5024
by: Rui Pacheco | last post by:
Hi everyone I'm trying to develop an applet using JApplet. As the layout manager I decided to use GridBagLayout. My layout will consist mainly of 7 JComboBox's in a single row and one JTable beneath them. My problem is, I can't even put the JComboBox's on the top of the Applet. Everytime I do the add method, they stay put in the middle of the Applet. I've tried setting GridBagConstraints.gridy = 0 but it didn't do me any good. Any help...
0
1974
by: Merlin_1102 | last post by:
I have read previous posts on the gridbaglayout and none seem to answer my questions (sorry if any of these have been aske dI really did search and found one large thread which took me an hour to read.. Anyway my problem is as such i need to make something like a simcity game (not quite though). Bassically I need a grid in which labels (using the image icon command) can be disbladed. This grid needs to be resizable ie it could go from...
2
1934
by: Pablo | last post by:
Could someone please help me to figure out how to use subj? I need to arrange 12 buttons in four rows - four in 1st row, two in 2nd, another two in 3rd , and last four in 4th row. I follow tutorial from JDK docs but for some reason on the 4th row only two buttons show up. Thanks.
1
1739
by: python473 | last post by:
Friends - I have tried to do abolute positioning using gridbaglayout, but am having no success in jython. One book I have been referencing says that it only works with JPanels. Could someone post a snippet of code that works for a button? I am so close so just a hint would help. Thanks as always. - John
1
4633
by: vsp15584 | last post by:
Hii..i use the coding as below :- import java.applet.applet; import java.awt.*; import com.sun.j3d.utils.applet.mainframe; import com.sun.j3d.utils.universe.*; import com.sun.j3d.utils.geometry.*; import javax.media.j3d.*; import javax.vecmath.*;
7
2641
by: sreenulanka | last post by:
please help me in my forum i have labels and textareas .iwant to add textarea components dyanamically when i am clicking the button.please help me import java.awt.*; import javax.swing.*; import javax.swing.event.*; import java.awt.event.*; import java.io.*; import java.applet.*;
16
3540
by: eben | last post by:
I've been playing with the canvas primitive available in some of the modern browsers, and have put together a little 3d engine that I thought other people might find useful. See http://ajax3d.sourceforge.net/ I'd appreciate any feedback (and an explanation of why it doesn't seem to like Safari). Eben
0
1132
by: Didje | last post by:
Hi, I'm trying to design a kind of calculator GUI using gridbaglayout. At the top of the calculator will be a couple of menus and then will come the section with all the buttons etc. Initially, I have designed the menu titles purely as labels (since I haven't figured out how to create actual menus - any help there would be great!) but the final menu item is separated by a mysterious space from the other ones. Here is the code I've got so far...
5
3378
by: cblank | last post by:
I'm having some trouble with my inventory program. Its due tom and my teacher is not wanting to help. He keeps giving me a soluction that is not related to my code. I have everything working except the Delete and Modify Button. The Search button works but it only searchs the new .dat file or what is set in the array. Not sure what is going on there. But if I can get my delete and modify button to work that will be good. Code.... ...
0
9511
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10410
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9984
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9020
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7529
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5418
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3701
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.