Search in sources :

Example 21 with Panel

use of java.awt.Panel in project h2database by h2database.

the class Console method showWindow.

private void showWindow() {
    if (frame != null) {
        return;
    }
    frame = new Frame("H2 Console");
    frame.addWindowListener(this);
    Image image = loadImage("/org/h2/res/h2.png");
    if (image != null) {
        frame.setIconImage(image);
    }
    frame.setResizable(false);
    frame.setBackground(SystemColor.control);
    GridBagLayout layout = new GridBagLayout();
    frame.setLayout(layout);
    // the main panel keeps everything together
    Panel mainPanel = new Panel(layout);
    GridBagConstraints constraintsPanel = new GridBagConstraints();
    constraintsPanel.gridx = 0;
    constraintsPanel.weightx = 1.0D;
    constraintsPanel.weighty = 1.0D;
    constraintsPanel.fill = GridBagConstraints.BOTH;
    constraintsPanel.insets = new Insets(0, 10, 0, 10);
    constraintsPanel.gridy = 0;
    GridBagConstraints constraintsButton = new GridBagConstraints();
    constraintsButton.gridx = 0;
    constraintsButton.gridwidth = 2;
    constraintsButton.insets = new Insets(10, 0, 0, 0);
    constraintsButton.gridy = 1;
    constraintsButton.anchor = GridBagConstraints.EAST;
    GridBagConstraints constraintsTextField = new GridBagConstraints();
    constraintsTextField.fill = GridBagConstraints.HORIZONTAL;
    constraintsTextField.gridy = 0;
    constraintsTextField.weightx = 1.0;
    constraintsTextField.insets = new Insets(0, 5, 0, 0);
    constraintsTextField.gridx = 1;
    GridBagConstraints constraintsLabel = new GridBagConstraints();
    constraintsLabel.gridx = 0;
    constraintsLabel.gridy = 0;
    Label label = new Label("H2 Console URL:", Label.LEFT);
    label.setFont(font);
    mainPanel.add(label, constraintsLabel);
    urlText = new TextField();
    urlText.setEditable(false);
    urlText.setFont(font);
    urlText.setText(web.getURL());
    if (isWindows) {
        urlText.setFocusable(false);
    }
    mainPanel.add(urlText, constraintsTextField);
    startBrowser = new Button("Start Browser");
    startBrowser.setFocusable(false);
    startBrowser.setActionCommand("console");
    startBrowser.addActionListener(this);
    startBrowser.setFont(font);
    mainPanel.add(startBrowser, constraintsButton);
    frame.add(mainPanel, constraintsPanel);
    int width = 300, height = 120;
    frame.setSize(width, height);
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setLocation((screenSize.width - width) / 2, (screenSize.height - height) / 2);
    try {
        frame.setVisible(true);
    } catch (Throwable t) {
    // ignore
    // some systems don't support this method, for example IKVM
    // however it still works
    }
    try {
        // ensure this window is in front of the browser
        frame.setAlwaysOnTop(true);
        frame.setAlwaysOnTop(false);
    } catch (Throwable t) {
    // ignore
    }
}
Also used : Panel(java.awt.Panel) Frame(java.awt.Frame) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) Button(java.awt.Button) Label(java.awt.Label) TextField(java.awt.TextField) Dimension(java.awt.Dimension) Image(java.awt.Image)

Example 22 with Panel

use of java.awt.Panel in project TauP by crotwell.

the class TauPApplet method init.

public void init() {
    GridBagLayout gridbag = new GridBagLayout();
    setLayout(gridbag);
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.gridwidth = GridBagConstraints.REMAINDER;
    constraints.weightx = 1.0;
    constraints.insets = new Insets(4, 4, 5, 5);
    Panel choicePanel = new Panel();
    toolChoice = new Choice();
    toolChoice.addItem("TauP_Time");
    toolChoice.addItem("TauP_Pierce");
    toolChoice.addItem("TauP_Path");
    toolChoice.addItem("TauP_Curve");
    toolChoice.select(0);
    toolChoice.addItemListener(this);
    choicePanel.add(new Label("Tool"));
    choicePanel.add(toolChoice);
    getModel = new Choice();
    choicePanel.add(new Label("Choose model."));
    choicePanel.add(getModel);
    getModel.addItemListener(this);
    gridbag.setConstraints(choicePanel, constraints);
    add(choicePanel);
    inputPanel = new Panel();
    inputPanel.setLayout(new GridLayout(0, 4));
    constraints.weighty = 0.0;
    gridbag.setConstraints(inputPanel, constraints);
    add(inputPanel);
    resetInputPanel();
    calculate = new Button("Calculate");
    calculate.addActionListener(this);
    clearTextArea = new Button("Clear");
    clearTextArea.addActionListener(this);
    textOrPlot = new Button("Plot");
    textOrPlot.addActionListener(this);
    constraints.weighty = 0.0;
    constraints.gridwidth = 1;
    add(clearTextArea);
    add(textOrPlot);
    constraints.gridwidth = GridBagConstraints.REMAINDER;
    gridbag.setConstraints(calculate, constraints);
    add(calculate);
    outputPanel = new Panel();
    outputCards = new CardLayout();
    outputPanel.setLayout(outputCards);
    textArea = new TextArea();
    textArea.setEditable(false);
    outputPanel.add(textArea, "Text");
    outputCards.first(outputPanel);
    Panel plotPanel = new Panel();
    plotPanel.setLayout(new BorderLayout());
    Panel buttonPanel = new Panel();
    buttonPanel.setLayout(new GridLayout(0, 1));
    Button fullButton = new Button("Full");
    fullButton.addActionListener(this);
    buttonPanel.add(fullButton);
    Button halfButton = new Button("Half");
    halfButton.addActionListener(this);
    buttonPanel.add(halfButton);
    Button quarterButton = new Button("Quarter");
    quarterButton.addActionListener(this);
    buttonPanel.add(quarterButton);
    plotPanel.add(buttonPanel, BorderLayout.WEST);
    plotArea = new PolarPlot(plotPanel, 250);
    plotPanel.add(plotArea);
    outputPanel.add(plotPanel, "Plot");
    constraints.weighty = 1.0;
    constraints.fill = GridBagConstraints.BOTH;
    gridbag.setConstraints(outputPanel, constraints);
    add(outputPanel);
    findTauModel();
    if (getModel.getItemCount() > 0) {
        getModel.select(0);
        getModel.select("prem");
    }
    validate();
    newline = System.getProperty("line.separator");
}
Also used : Panel(java.awt.Panel) CardLayout(java.awt.CardLayout) GridBagConstraints(java.awt.GridBagConstraints) GridLayout(java.awt.GridLayout) Insets(java.awt.Insets) Choice(java.awt.Choice) GridBagLayout(java.awt.GridBagLayout) BorderLayout(java.awt.BorderLayout) Button(java.awt.Button) TextArea(java.awt.TextArea) Label(java.awt.Label)

Example 23 with Panel

use of java.awt.Panel in project triplea by triplea-game.

the class ReliefImageBreaker method loadImage.

/**
 * Asks the user to select an image and then it loads it up into an Image
 * object and returns it to the calling class.
 *
 * @return The loaded image.
 */
private Image loadImage() {
    ToolLogger.info("Select the map");
    final String mapName = new FileOpen("Select The Map", mapFolderLocation, ".gif", ".png").getPathString();
    if (mapName != null) {
        final Image img = Toolkit.getDefaultToolkit().createImage(mapName);
        final MediaTracker tracker = new MediaTracker(new Panel());
        tracker.addImage(img, 1);
        try {
            tracker.waitForAll();
            return img;
        } catch (final InterruptedException e) {
            Thread.currentThread().interrupt();
        }
    }
    return null;
}
Also used : Panel(java.awt.Panel) MediaTracker(java.awt.MediaTracker) Image(java.awt.Image) BufferedImage(java.awt.image.BufferedImage)

Example 24 with Panel

use of java.awt.Panel in project bioformats by openmicroscopy.

the class ColorDialog method constructDialog.

@Override
protected GenericDialog constructDialog() {
    GenericDialog gd = new GenericDialog("Bio-Formats Custom Colorization");
    // CTR FIXME - avoid problem with MAX_SLIDERS in GenericDialog
    final ImageProcessorReader reader = process.getReader();
    final List<Panel> swatches = new ArrayList<Panel>();
    for (int s = 0; s < process.getSeriesCount(); s++) {
        if (!options.isSeriesOn(s))
            continue;
        reader.setSeries(s);
        for (int c = 0; c < reader.getSizeC(); c++) {
            Color color = options.getCustomColor(s, c);
            if (color == null)
                color = options.getDefaultCustomColor(c);
            gd.addSlider(makeLabel("Red:", s, c), 0, 255, color.getRed());
            gd.addSlider(makeLabel("Green:", s, c), 0, 255, color.getGreen());
            gd.addSlider(makeLabel("Blue:", s, c), 0, 255, color.getBlue());
            Panel swatch = createSwatch(color);
            gd.addPanel(swatch, GridBagConstraints.CENTER, new Insets(5, 0, 5, 0));
            swatches.add(swatch);
        }
    }
    // change swatch colors when sliders move
    List<TextField> colorFields = getNumericFields(gd);
    attachListeners(colorFields, swatches);
    WindowTools.addScrollBars(gd);
    return gd;
}
Also used : Panel(java.awt.Panel) Insets(java.awt.Insets) ImageProcessorReader(loci.plugins.util.ImageProcessorReader) GenericDialog(ij.gui.GenericDialog) Color(java.awt.Color) ArrayList(java.util.ArrayList) TextField(java.awt.TextField)

Example 25 with Panel

use of java.awt.Panel in project bioformats by openmicroscopy.

the class ColorDialog method attachListeners.

private void attachListeners(List<TextField> colors, List<Panel> swatches) {
    int colorIndex = 0, swatchIndex = 0;
    while (colorIndex < colors.size()) {
        final TextField redField = colors.get(colorIndex++);
        final TextField greenField = colors.get(colorIndex++);
        final TextField blueField = colors.get(colorIndex++);
        final Panel swatch = swatches.get(swatchIndex++);
        TextListener textListener = new TextListener() {

            @Override
            public void textValueChanged(TextEvent e) {
                int red = getColorValue(redField);
                int green = getColorValue(greenField);
                int blue = getColorValue(blueField);
                swatch.setBackground(new Color(red, green, blue));
                swatch.repaint();
            }
        };
        redField.addTextListener(textListener);
        greenField.addTextListener(textListener);
        blueField.addTextListener(textListener);
    }
}
Also used : Panel(java.awt.Panel) TextEvent(java.awt.event.TextEvent) Color(java.awt.Color) TextField(java.awt.TextField) TextListener(java.awt.event.TextListener)

Aggregations

Panel (java.awt.Panel)70 BorderLayout (java.awt.BorderLayout)26 Button (java.awt.Button)25 Label (java.awt.Label)25 Frame (java.awt.Frame)18 GridBagLayout (java.awt.GridBagLayout)17 TextField (java.awt.TextField)17 GridBagConstraints (java.awt.GridBagConstraints)16 JPanel (javax.swing.JPanel)14 Dimension (java.awt.Dimension)13 Insets (java.awt.Insets)10 Point (java.awt.Point)10 Choice (java.awt.Choice)9 FlowLayout (java.awt.FlowLayout)9 Graphics (java.awt.Graphics)9 Checkbox (java.awt.Checkbox)7 GridLayout (java.awt.GridLayout)7 Font (java.awt.Font)6 JButton (javax.swing.JButton)6 Component (java.awt.Component)5