public static void main(String[] av) { JFrame f = new JFrame("Mouse Dragger"); Container cp = f.getContentPane(); if (av.length < 1) { System.err.println("Usage: MouseDragClip imagefile"); System.exit(1); } Image im = Toolkit.getDefaultToolkit().getImage(av[0]); // create a MouseDragClip object MouseDragClip j = new MouseDragClip(im); cp.setLayout(new BorderLayout()); cp.add(BorderLayout.NORTH, new Label("Hello, and welcome to the world of Java")); cp.add(BorderLayout.CENTER, j); cp.add(BorderLayout.SOUTH, status = new Label()); status.setSize(f.getSize().width, status.getSize().height); f.pack(); f.setVisible(true); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
public static void main(String[] av) { JFrame f = new JFrame("Mouse Dragger"); Container cp = f.getContentPane(); Image im = Toolkit.getDefaultToolkit().getImage( av.length == 1 ? av[0] : "graphics/duke.gif"); // create a MouseDrag object MouseDrag j = new MouseDrag(im); cp.setLayout(new BorderLayout()); cp.add(BorderLayout.NORTH, new Label("Hello, and welcome to the world of Java")); cp.add(BorderLayout.CENTER, j); cp.add(BorderLayout.SOUTH, j.status = new Label()); j.status.setSize( f.getSize().width, j.status.getSize().height); f.setSize(300, 300); f.setVisible(true); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
/** Construct the GUI for an Applet Status window */ AppletAdapter() { super(); // Must do this very early on, since the Applet's // Constructor or its init() may use showStatus() add(status = new Label()); // Give "status" the full width status.setSize(getSize().width, status.getSize().height); showStatus("AppletAdapter constructed"); // now it can be said }
private void setListEntry(ListCell<Label> listCell, Label label) { Image img = loadLableIcon(label); GridPane row = new GridPane(); row.setHgap(15); row.setVgap(15); ColumnConstraints col1 = new ColumnConstraints(); col1.setPercentWidth(90); ColumnConstraints col2 = new ColumnConstraints(); col2.setPercentWidth(10); ImageView icon = new ImageView(img); javafx.scene.control.Label name = new javafx.scene.control.Label(label.getName()); name.setMinWidth(120d); javafx.scene.control.Label amount = new javafx.scene.control.Label("" + label.getSize()); HBox iconAndName = new HBox(10); iconAndName.setAlignment(Pos.CENTER_LEFT); iconAndName.getChildren().addAll(icon, name); row.add(iconAndName, 0, 0); row.add(amount, 1, 0); row.getColumnConstraints().addAll(col1, col2); listCell.setGraphic(row); }