Java Swing JPanel クリエーター クラスにディメンションを渡そうとしています。これまでのところ運がありません。try / catch ブロックに入れてcontentPane.setPreferredSize(new Dimension(intWidth, intHeight));も、システム出力は得られませんでした。かなり大きな値 を渡してframe.setContentPane(ContentPaneCreator.createContentPane("darkseagreen", 800, 255));いますが、アプリケーションはコンポーネントと同じくらい小さいです。それを修正するために何ができますか?ありがとう。
import java.awt.Container;
import java.awt.Dimension;
import javax.swing.JPanel;
public final class ContentPaneCreator {
    public static Container createContentPane(String color, int intWidth, int intHeight) {
        JPanel contentPane = new JPanel();
        // Pass the colour
        contentPane.setBackground(ColorFactory.getInstance().getColor(color));
        // Pass the dimensions
        try {
        contentPane.setPreferredSize(new Dimension(intWidth, intHeight));
        }
        catch (Exception ex) {
            System.out.println(ex);
        }
        return contentPane;
    }
}
ポストイット()
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
public class StickyNotes extends JFrame {
    private static final long serialVersionUID = 1L;
    public static String appName;
    public static String fileConfirmSave;
    public static String txtConfirmChange;
    private void createStickyNotesGUI() {
        ConfigProperties config = new ConfigProperties();
        // ConfigProperties config2 = new ConfigProperties().getFileIn();
        appName = config.getConfigProperties("appName").toUpperCase();
        fileConfirmSave = config.getConfigProperties("fileConfirmSave");
        txtConfirmChange = config.getConfigProperties("txtConfirmChange");
        // Create and set up the window.
        JFrame frame = new JFrame();
        frame.setTitle(appName);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setLayout(new FlowLayout(FlowLayout.LEFT));
        /* BEGIN ROOT Pane: */
        /* BEGIN Layered Pane: */
        // Add Main Menu
        MainMenuBar mainMenu = new MainMenuBar();
        frame.setJMenuBar(mainMenu.createMainMenuBar(frame));
        /* BEGIN CONTENT Pane(s): */
        // Add JPanel Content // can I pass a layout object?
        frame.setContentPane(ContentPaneCreator.createContentPane("darkseagreen", 800, 255));
        // Add Tool Bar /* needs to be run AFTER we .setContentPane() in order for it to be layerd on top */
        ToolBarCreator toolBar = new ToolBarCreator();
        frame.getContentPane().add(toolBar.createToolBar(), BorderLayout.NORTH);
        // TODO
        /*
         * Pass dynamic color values to LabelCreator() once you get
         * newStickyNote() working
         */
        frame.getContentPane().add(
                LabelCreator.createLabel(frame, "Java Swing", "purple"),
                BorderLayout.NORTH);
        // Display the window here with JFrame//
        //frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
        // TODO
        /* set configuration to remember frame size */
        frame.pack();
        frame.setVisible(true);
    }
    public void doExit(JFrame frame) {
        boolean fDirty = true;
        if (fDirty)
            switch (JOptionPane.showConfirmDialog(StickyNotes.this,
                    fileConfirmSave, txtConfirmChange,
                    JOptionPane.YES_NO_OPTION)) {
            case JOptionPane.YES_OPTION:
                // if (doSave())
                frame.dispose();
                break;
            case JOptionPane.NO_OPTION:
                frame.dispose();
            }
        else
            frame.dispose();
    }
    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                new StickyNotes().createStickyNotesGUI();
            }
        });
    }
}