• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

Java Structure Help!

Joined
Feb 26, 2008
Messages
4,876 (0.83/day)
Location
Joplin, Mo
System Name Ultrabeast GX2
Processor Intel Core 2 Duo E8500 @ 4.0GHZ 24/7
Motherboard Gigabit P35-DS3L
Cooling Rosewill RX24, Dual Slot Vid, Fan control
Memory 2x1gb 1066mhz@850MHZ DDR2
Video Card(s) 9800GX2 @ 690/1040
Storage 750/250/250/200 all WD 7200
Display(s) 24" DCLCD 2ms 1200p
Case Apevia
Audio Device(s) 7.1 Digital on-board, 5.1 digital hooked up
Power Supply 700W RAIDMAXXX SLI
Software winXP Pro
Benchmark Scores 17749 3DM06
I am setting up a program for our organization to automatically run installations and updates when a computer is first set up on a domain.

I want the best customization of the look, even if I have to set each object by the pixel using object.setBounds(x,y,width,height)

The problem is that if I use this without any particular layout, the final button using add() covers the whole window.

Let me know your thoughts (yes Kreij, lookin at you :) )

I can show you the code, but because of it being a small program , but you might get sick and throw up at the amount of terrible organization and lack of notation.

Code:
//Directions for each task:
//COMPLETED Windows Date/Time: Control.exe TIMEDATE.CPL,,/Z (GMT-06:00) Central Time (US & Canada)
//Wired Autoconfig: net start "wired autoconfig"
//802.1x: ncpa.cpl

package arsocapp;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;

public class buttons extends JFrame{

    JButton setTime, mapBat, openNetFolders, pushIt, set802, windowsUpdate;
    JButton wsusUpdate, socomFrame, cmdagent, gpupdateRegister;
    public buttons() {
        //Container Panel;
        //LayoutManager Layout;
        //Layout = new GridLayout();

        //Panel = getContentPane ();
        //Panel.setLayout (Layout);

        setTime = new JButton("Set Time to Central", null);
        mapBat = new JButton("Map your network drives", null);
        openNetFolders = new JButton(" Time to Central", null);
        pushIt = new JButton("Set Time to Central", null);
        set802 = new JButton("Set Time to Central", null);
        windowsUpdate = new JButton("Set Time to Central", null);
        wsusUpdate = new JButton("Set Time to Central", null);
        socomFrame = new JButton("Set Time to Central", null);
        cmdagent = new JButton("Set Time to Central", null);
        gpupdateRegister = new JButton("Set Time to Central", null);
        setTime.setBounds(0, 0, 150, 25);
        mapBat.setBounds(200,1,199,49);
        add (setTime);
        add (mapBat);
        add (openNetFolders);
        /*add (pushIt);
        add (set802);
        add (windowsUpdate);
        add (wsusUpdate);
        add (socomFrame);
        add (cmdagent);
        add (gpupdateRegister);*/

        


        mapBat.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e){
                mapBat.setEnabled(false);
                try{
        String command = "C:\\Windows\\system32\\net.exe use j: \\\\campuua-napp-01\\25b_adm";
        Runtime.getRuntime().exec(command);
                    }
                    catch (Exception err) {
                        err.printStackTrace();
                        
                }
            }
        });
        setTime.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e){
                setTime.setEnabled(false);
                try{
        String command = "Control.exe TIMEDATE.CPL,,/Z (GMT-06:00) Central Time (US & Canada)";
        Runtime.getRuntime().exec(command);
                    }
                    catch (Exception err) {
                        err.printStackTrace();
                        setTime.setEnabled(false);
                }
            }
        });
    }

}

Just a reminder, the program is far from done, so it is shabby. If you want to run it create your main method and call buttons.
 

Kreij

Senior Monkey Moderator
Joined
Feb 6, 2007
Messages
13,817 (2.20/day)
Location
Cheeseland (Wisconsin, USA)
So you are saying that the last button (in the above it would be openNetFolders stretches to the size of the whole window if you don't set it's bounds?
 
Joined
Feb 26, 2008
Messages
4,876 (0.83/day)
Location
Joplin, Mo
System Name Ultrabeast GX2
Processor Intel Core 2 Duo E8500 @ 4.0GHZ 24/7
Motherboard Gigabit P35-DS3L
Cooling Rosewill RX24, Dual Slot Vid, Fan control
Memory 2x1gb 1066mhz@850MHZ DDR2
Video Card(s) 9800GX2 @ 690/1040
Storage 750/250/250/200 all WD 7200
Display(s) 24" DCLCD 2ms 1200p
Case Apevia
Audio Device(s) 7.1 Digital on-board, 5.1 digital hooked up
Power Supply 700W RAIDMAXXX SLI
Software winXP Pro
Benchmark Scores 17749 3DM06
even if you do set it's bounds, it will fill the rest of the screen. This happens not matter how many buttons there are.
 

Kreij

Senior Monkey Moderator
Joined
Feb 6, 2007
Messages
13,817 (2.20/day)
Location
Cheeseland (Wisconsin, USA)
Hmmm ... not sure, and I don't have a machine set up here at work to test Java code on. :/
 

Zyon

New Member
Joined
Mar 18, 2011
Messages
264 (0.06/day)
Location
Australia
System Name Computernamehere/Computernamehere2/Computernamehere3
Processor i5-2500/Athlon 6000+/C2D Q6700
Motherboard P67A-UD3R/M2N-SLI Deluxe/P5K-Deluxe
Cooling Stock/Hyper212+/Unknown Coolermaster
Memory Patriot PC3-10666 2x2/A-Data PC2-6400 4x1/OCZ PC2-8500 4x1
Video Card(s) MSI GTX580 Lightning/2x Gigabyte GTS450 OC 1GB/2x HIS HD4870 512MB
Storage Seagate 1TB/Samsung 500GB/Seagate 1TB
Display(s) Samsung BX2440
Case V4 Black/Mystique 631 Silver/Soprano VX
Audio Device(s) WTF is a sound card?
Power Supply Corsair HX650/Antec Earthwatts 650W Green/None
Software Windows 7 Home/Professional/Professional
Benchmark Scores TBA
Joined
Feb 26, 2008
Messages
4,876 (0.83/day)
Location
Joplin, Mo
System Name Ultrabeast GX2
Processor Intel Core 2 Duo E8500 @ 4.0GHZ 24/7
Motherboard Gigabit P35-DS3L
Cooling Rosewill RX24, Dual Slot Vid, Fan control
Memory 2x1gb 1066mhz@850MHZ DDR2
Video Card(s) 9800GX2 @ 690/1040
Storage 750/250/250/200 all WD 7200
Display(s) 24" DCLCD 2ms 1200p
Case Apevia
Audio Device(s) 7.1 Digital on-board, 5.1 digital hooked up
Power Supply 700W RAIDMAXXX SLI
Software winXP Pro
Benchmark Scores 17749 3DM06
who wouldn't use Netbeans? my IDE of choice.

Unless I am programming for Android, in which case I will use eclipse.
 

Kreij

Senior Monkey Moderator
Joined
Feb 6, 2007
Messages
13,817 (2.20/day)
Location
Cheeseland (Wisconsin, USA)
From today's Dr. Dobb's newsletter (in case you are interested) ...
Java 7 and NetBeans 7

The Javasphere is settling into two recent announcements by Oracle: The feature list for Java EE 7 has been finalized and version 7.0 of the NetBeans IDE ships this week. (The identical release numbers are purely a coincidence. Despite that, the numbers are meaningful. I'll take this up in a moment.)

Java EE 7 is not expected to ship until next year and so, as the time approaches and implementations begin to make their way into beta, we will explore the new features both in full articles and undoubtedly in Eric Bruno's blog posts. My focus today is on NetBeans 7, which more than other IDE releases (such as the upcoming Eclipse release train) has special significance.

The first and most important thing to note is that this release exists at all. It fulfills a promise made by Oracle late last year to keep NetBeans going. Version 7 contains numerous new features, many of which are early support for the syntax changes and innovations in Java SE 7. We'll examine these once the NetBeans product ships later this week. I confess that after Oracle's OpenSolaris fiasco and the awkward handling of the Hudson project, it was not clear to me that the company's support for NetBeans would be deep or long. Moreover, I wasn't sure that the open-source aspect of NetBeans would be preserved.

Those concerns have been allayed. NetBeans is still open source, the product is moving forward, and from my conversations with Oracle, it's beginning to occupy an important place in the company's tool offerings. NetBeans is seen internally to the company as the vanguard IDE product. That is, it is the crucible in which the features of the language and supporting technologies are developed, explored, and evaluated. The insight derived from this work is then reused in building out Oracle's enterprise IDE, JDeveloper.

Because JDeveloper is targeted at enterprises, its slow addition of Java 7 features represents no particular limitation. It can wait for NetBeans to test the waters first. JDeveloper advances very much in concert with Oracle's other development products. As a result, it carries the same release number as the database (to wit, JDeveloper 11). And like its product peers, new releases are indicated by adding nearly endless decimal points to the base version number. For example, consider the current version number: JDeveloper 11g Release 1 (11.1.1.4.0). The fact that Oracle retained NetBeans' own numbering (the previous release was indeed v. 6.9) shows that the IDE is not being swallowed by the Borg and will continue to live on as a cutting-edge, open source product from Oracle.

This is good news not only because it shows that Oracle can bring itself to embrace an OSS product in which it sees value, but also because NetBeans is a product that is especially worthy of this support. I've long felt (and frequently stated) that NetBeans is the friendliest and most responsive of the OSS Java IDEs. Its implementation quality is particularly striking if you use Eclipse. Eclipse wins hands-down when you compare the plug-in ecosystems. But if you're like me in that you use primarily mainstream development tools, then the number of alternative plugins doesn't enter much into the choice of IDEs. In such a case, I suggest you have a look at NetBeans. I suspect you'll like what you see.
 
Joined
Feb 26, 2008
Messages
4,876 (0.83/day)
Location
Joplin, Mo
System Name Ultrabeast GX2
Processor Intel Core 2 Duo E8500 @ 4.0GHZ 24/7
Motherboard Gigabit P35-DS3L
Cooling Rosewill RX24, Dual Slot Vid, Fan control
Memory 2x1gb 1066mhz@850MHZ DDR2
Video Card(s) 9800GX2 @ 690/1040
Storage 750/250/250/200 all WD 7200
Display(s) 24" DCLCD 2ms 1200p
Case Apevia
Audio Device(s) 7.1 Digital on-board, 5.1 digital hooked up
Power Supply 700W RAIDMAXXX SLI
Software winXP Pro
Benchmark Scores 17749 3DM06
aww, I tried that thinking it would work, but it still had the same issue. This is not your fault, it is mine because I am too lazy to create a layout :p

What I did do to resolve is make the final button do nothing called fillFrame(), and did the following:

fillFrame = new JButton();
add (fillFrame);
fillFrame.setVisible(false);

This proves that I am a terrible and messy programmer, but it works for me. To be fair, I will never release anything open source. :D

Thank you all for your help, and if you can think of something to write it clean, let me know.
 

Kreij

Senior Monkey Moderator
Joined
Feb 6, 2007
Messages
13,817 (2.20/day)
Location
Cheeseland (Wisconsin, USA)
I'm going to set up Java development on both my home and work rigs so I can be of some use for the Java programmers.
Will take me a week or two to relearn the syntax as there is a lot new in Java since I last worked with it. (plus I'm working on a little C# project ATM) :eek:
 
Top