Java Code Examples for java.awt.Container

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project Agot-Java, under directory /src/main/java/got/ui/.

Source file: MainApplet.java

  33 
vote

private JFrame findParentFrame(){
  Container c=this;
  while (c != null) {
    if (c instanceof JFrame)     return (JFrame)c;
    c=c.getParent();
  }
  return null;
}
 

Example 2

From project BMach, under directory /src/bmach/ui/gui/.

Source file: BMachPanel.java

  32 
vote

private void updateTitle(){
  Container tla=this.getTopLevelAncestor();
  if (tla instanceof JFrame) {
    String title="BMach - " + docTitle + (docModified ? "*" : "");
    ((JFrame)tla).setTitle(title);
  }
}
 

Example 3

From project Briss, under directory /src/main/java/at/laborg/briss/gui/.

Source file: WrapLayout.java

  32 
vote

/** 
 * Layout the components in the Container using the layout logic of the parent FlowLayout class.
 * @param target the Container using this WrapLayout
 */
@Override public void layoutContainer(Container target){
  Dimension size=preferredLayoutSize(target);
  if (size.equals(preferredLayoutSize)) {
    super.layoutContainer(target);
  }
 else {
    preferredLayoutSize=size;
    Container top=target;
    while (!(top instanceof Window) && top.getParent() != null) {
      top=top.getParent();
    }
    top.validate();
  }
}
 

Example 4

From project CBCJVM, under directory /cbc/CBCJVM/src/cbccore/low/.

Source file: CBCSimulator.java

  32 
vote

private void addButtons(){
  FlowLayout buttonLayout=new FlowLayout();
  Container buttonContainer=new Container();
  buttonContainer.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
  buttonContainer.setLayout(buttonLayout);
  buttonContainer.add(input.ub);
  buttonContainer.add(input.db);
  buttonContainer.add(input.lb);
  buttonContainer.add(input.rb);
  buttonContainer.add(input.ab);
  buttonContainer.add(input.bb);
  buttonContainer.add(input.blb);
  frame.getContentPane().add(buttonContainer,BorderLayout.SOUTH);
}
 

Example 5

From project ceres, under directory /ceres-ui/src/main/java/com/bc/ceres/swing/.

Source file: CollapsiblePane.java

  32 
vote

private void revalidateParent(){
  Container parent=getParent();
  if (parent != null) {
    parent.invalidate();
    parent.validate();
  }
}
 

Example 6

From project codjo-data-process, under directory /codjo-data-process-gui/src/main/java/net/codjo/dataprocess/gui/util/.

Source file: GuiUtils.java

  32 
vote

public static JFrame getParentFrame(Component component){
  Container container=component.getParent();
  if (container instanceof JFrame || container == null) {
    return (JFrame)container;
  }
 else {
    return getParentFrame(container);
  }
}
 

Example 7

From project drugis-common, under directory /common-gui/src/main/java/org/drugis/common/gui/table/.

Source file: TablePanel.java

  32 
vote

protected Container findParent(){
  Container p=this;
  while (!(p instanceof JScrollPane) && p != null) {
    p=p.getParent();
  }
  return p;
}
 

Example 8

From project encog-java-workbench, under directory /src/main/java/org/encog/workbench/dialogs/.

Source file: BenchmarkDialog.java

  32 
vote

public BenchmarkDialog(){
  progress=new JProgressBar(0,4);
  setTitle("Please wait, benchmarking Encog.");
  setSize(640,75);
  Container content=this.getContentPane();
  content.setLayout(new BorderLayout());
  this.status=new JLabel("");
  content.add(this.status,BorderLayout.CENTER);
  content.add(progress,BorderLayout.SOUTH);
  Thread thread=new Thread(this);
  thread.start();
}
 

Example 9

From project Euclidean-Pattern-Generator, under directory /src/com/hisschemoller/sequencer/.

Source file: SequencerMain.java

  32 
vote

public SequencerMain(){
  try {
    EPGSwingEngine swingEngine=new EPGSwingEngine(this);
    swingEngine.getTaglib().registerTag("JToggleButtonForPanel",JToggleButtonForPanel.class);
    Container container=swingEngine.render("res/layout/main.xml");
    container.setVisible(true);
    new MainFrame(swingEngine);
    _facade.startup(swingEngine);
  }
 catch (  Exception exception) {
    exception.printStackTrace();
  }
}
 

Example 10

From project extension_libero_manufacturing, under directory /extension/eevolution/libero/src/main/java/org/eevolution/tools/swing/.

Source file: SwingTool.java

  32 
vote

public synchronized static void setCursorsFromParent(Container parent,boolean waiting){
  Container con=parent;
  for (int i=0; i < con.getComponentCount(); i++) {
    setCursor(con.getComponent(i),waiting);
    if (con.getComponent(i) instanceof Container) {
      setCursorsFromParent((Container)con.getComponent(i),waiting);
    }
  }
}
 

Example 11

From project flyingsaucer, under directory /flying-saucer-core/src/main/java/org/xhtmlrenderer/swing/.

Source file: RootPanel.java

  32 
vote

/** 
 * Overrides the default implementation to test for and configure any  {@link JScrollPane} parent.
 */
public void addNotify(){
  super.addNotify();
  XRLog.general(Level.FINE,"add notify called");
  Container p=getParent();
  if (p instanceof JViewport) {
    Container vp=p.getParent();
    if (vp instanceof JScrollPane) {
      setEnclosingScrollPane((JScrollPane)vp);
    }
  }
}
 

Example 12

From project freemind, under directory /freemind/freemind/view/mindmapview/.

Source file: NodeView.java

  32 
vote

boolean isParentHidden(){
  final Container parent=getParent();
  if (!(parent instanceof NodeView))   return false;
  NodeView parentView=(NodeView)parent;
  return !parentView.isContentVisible();
}
 

Example 13

From project glg2d, under directory /src/main/java/glg2d/.

Source file: GLAwareRepaintManager.java

  32 
vote

protected G2DGLPanel getGLParent(JComponent component){
  Container c=component.getParent();
  while (true) {
    if (c == null) {
      return null;
    }
 else     if (c instanceof G2DGLPanel) {
      return (G2DGLPanel)c;
    }
 else {
      c=c.getParent();
    }
  }
}
 

Example 14

From project gs-tool, under directory /src/org/graphstream/tool/.

Source file: ToolGUI.java

  32 
vote

protected void setToolGUIEnabled(boolean on){
  setEnabled(on);
  LinkedList<Component> components=new LinkedList<Component>();
  components.add(this);
  while (components.size() > 0) {
    Component c=components.poll();
    c.setEnabled(on);
    if (c instanceof Container) {
      Container cont=(Container)c;
      for (int i=0; i < cont.getComponentCount(); i++)       components.add(cont.getComponent(i));
    }
  }
}
 

Example 15

From project imageflow, under directory /src/de/danielsenff/imageflow/gui/.

Source file: WrapLayout.java

  32 
vote

/** 
 * Layout the components in the Container using the layout logic of the parent FlowLayout class.
 * @param target the Container using this WrapLayout
 */
@Override public void layoutContainer(Container target){
  Dimension size=preferredLayoutSize(target);
  if (size.equals(preferredLayoutSize)) {
    super.layoutContainer(target);
  }
 else {
    preferredLayoutSize=size;
    Container top=target;
    while (!(top instanceof Window) && top.getParent() != null) {
      top=top.getParent();
    }
    top.validate();
  }
}
 

Example 16

From project JaamSim, under directory /com/sandwell/JavaSimulation3D/.

Source file: Display2DEntity.java

  32 
vote

public void exitRegion(){
  if (displayModel == null)   return;
  Container container=displayModel.getParent();
  if (container == null)   return;
  container.remove(displayModel);
}
 

Example 17

From project jchempaint, under directory /src/main/org/openscience/jchempaint/.

Source file: AbstractJChemPaintPanel.java

  32 
vote

/** 
 * Allows setting of the is modified stage (e. g. after save)
 * @param isModified is modified
 */
public void setModified(boolean isModified){
  this.modified=isModified;
  Container c=this.getTopLevelContainer();
  if (c instanceof JFrame) {
    String id=renderPanel.getChemModel().getID();
    if (isModified)     ((JFrame)c).setTitle('*' + id + this.getAppTitle());
 else     ((JFrame)c).setTitle(id + this.getAppTitle());
  }
}
 

Example 18

From project jlac, under directory /src/org/sump/analyzer/devices/.

Source file: FpgaDeviceController.java

  32 
vote

/** 
 * Creates an array of check boxes, adds it to the device controller and returns it.
 * @param label label to use on device controller component
 * @return array of created check boxes
 */
private JCheckBox[] createChannelList(JPanel pane,GridBagConstraints constraints){
  JCheckBox[] boxes=new JCheckBox[32];
  Container container=new Container();
  container.setLayout(new GridLayout(1,32));
  for (int col=31; col >= 0; col--) {
    JCheckBox box=new JCheckBox();
    box.setEnabled(false);
    container.add(box);
    if ((col % 8) == 0 && col > 0)     container.add(new JLabel());
    boxes[col]=box;
  }
  pane.add(container,constraints);
  return (boxes);
}
 

Example 19

From project JoshEdit, under directory /org/lateralgm/joshedit/.

Source file: JoshText.java

  32 
vote

/** 
 * Handle a resize. 
 */
void fireResize(){
  Container a=getParent();
  if (a == null)   return;
  int w=a.getWidth(), h=a.getHeight();
  Dimension ps=getMinimumSize();
  ps.width=Math.max(ps.width,w);
  ps.height=Math.max(ps.height,h);
  setPreferredSize(ps);
  setSize(ps);
}
 

Example 20

From project LanguageSpecCreator, under directory /src/SpecificationCreation/look/.

Source file: LiberExample.java

  32 
vote

/** 
 * Constructor
 * @param r Ontology
 * @param c Class name
 * @param dir Directory name, to find specifications
 */
public LiberExample(SpecificationOntologyReader r,String c,String dir){
  super("LIBER example");
  setBounds(100,100,500,300);
  setResizable(true);
  setBackground(Color.white);
  Container content=getContentPane();
  content.setBackground(Color.white);
  reader=r;
  className=c;
  directory=dir;
  show(generateExample(),content);
  content.validate();
  setVisible(true);
}
 

Example 21

From project LateralGM, under directory /org/lateralgm/subframes/.

Source file: EventPanel.java

  32 
vote

public void setVisible(boolean b){
  if (b == isVisible())   return;
  Container c=this, p=c.getParent();
  while (p != null && p != LGM.frame && p != LGM.content) {
    c=p;
    p=c.getParent();
  }
  if (c != this)   c.setVisible(b);
  ((BasicToolBarUI)getUI()).isFloating();
  super.setVisible(b);
  LGM.eventButton.setSelected(b);
}
 

Example 22

From project lilith, under directory /lilith/src/main/java/de/huxhorn/lilith/swing/.

Source file: TipOfTheDayDialog.java

  32 
vote

public void actionPerformed(ActionEvent e){
  setVisible(false);
  Container parentContainer=getParent();
  if (parentContainer != null) {
    parentContainer.requestFocus();
  }
}
 

Example 23

From project OMS3, under directory /src/main/java/ngmfconsole/.

Source file: JPanelButton.java

  32 
vote

@Override protected void fireActionPerformed(ActionEvent event){
  Container w=getWindow();
  if (isSelected()) {
    adjustWindow(w);
    w.setVisible(true);
    w.requestFocus();
  }
 else {
    w.setVisible(false);
  }
}
 

Example 24

From project org.openscada.external, under directory /org.eclipse.albireo/src/org/eclipse/albireo/internal/.

Source file: FocusDebugging.java

  32 
vote

static void addFocusListenerToTree(final Component comp){
  comp.addFocusListener(_AWTFocusListener);
  if (comp instanceof Container) {
    final Container cont=(Container)comp;
    cont.addContainerListener(_AWTContainerListener);
    final int n=cont.getComponentCount();
    for (int i=0; i < n; i++) {
      addFocusListenerToTree(cont.getComponent(i));
    }
  }
}
 

Example 25

From project PixelController, under directory /src/main/java/com/neophob/sematrix/generator/.

Source file: ScreenCapture.java

  32 
vote

/** 
 * draw a single border
 * @param height
 * @param x
 * @param y
 */
private static JFrame drawReadBorder(Frame frame,int width,int height,int x,int y){
  JFrame window=new JFrame(frame.getGraphicsConfiguration());
  window.setSize(width,height);
  window.setLocation(x,y);
  window.setUndecorated(true);
  Container container=window.getContentPane();
  container.setBackground(Color.RED);
  setOpacity(window,0.5f);
  window.setAlwaysOnTop(true);
  window.setVisible(false);
  return window;
}
 

Example 26

From project Project-2, under directory /.

Source file: BoggleGUI.java

  32 
vote

private void initPanels(){
  Container contentPane=getContentPane();
  humanArea=new PlayerView("Me");
  computerArea=new PlayerView("Computer");
  myBoardPanel4=new BoggleBoardPanel(4,4);
  myBoardPanel5=new BoggleBoardPanel(5,5);
  myBoardPanel=myBoardPanel5;
  wordEntryField=new WordEntryField();
  contentPane.add(wordEntryField,BorderLayout.SOUTH);
  contentPane.add(humanArea,BorderLayout.WEST);
  contentPane.add(myBoardPanel,BorderLayout.CENTER);
  contentPane.add(computerArea,BorderLayout.EAST);
  contentPane.add(makeProgressBar(),BorderLayout.NORTH);
}
 

Example 27

From project autopsy, under directory /Core/src/org/sleuthkit/autopsy/report/.

Source file: ReportFilterAction.java

  31 
vote

public void performAction(){
  Logger.noteAction(this.getClass());
  try {
    Container cpane;
    final JFrame frame=new JFrame(ACTION_NAME);
    final JDialog popUpWindow=new JDialog(frame,ACTION_NAME,true);
    cpane=frame.getContentPane();
    final ReportFilter panel=new ReportFilter();
    popUpWindow.add(panel);
    popUpWindow.pack();
    popUpWindow.setResizable(false);
    Dimension screenDimension=Toolkit.getDefaultToolkit().getScreenSize();
    double w=popUpWindow.getSize().getWidth();
    double h=popUpWindow.getSize().getHeight();
    popUpWindow.setLocation((int)((screenDimension.getWidth() - w) / 2),(int)((screenDimension.getHeight() - h) / 2));
    popUpWindow.setVisible(true);
  }
 catch (  Exception ex) {
    Logger.getLogger(ReportFilterAction.class.getName()).log(Level.WARNING,"Error displaying " + ACTION_NAME + " window.",ex);
  }
}
 

Example 28

From project des, under directory /daemon/lib/apache-log4j-1.2.16/contribs/CekiGulcu/.

Source file: AppenderTable.java

  31 
vote

static public void main(String[] args){
  if (args.length != 2) {
    System.err.println("Usage: java AppenderTable bufferSize runLength\n" + "  where bufferSize is the size of the cyclic buffer in the TableModel\n" + "  and runLength is the total number of elements to add to the table in\n"+ "  this test run.");
    return;
  }
  JFrame frame=new JFrame("JTableAppennder test");
  Container container=frame.getContentPane();
  AppenderTable tableAppender=new AppenderTable();
  int bufferSize=Integer.parseInt(args[0]);
  AppenderTableModel model=new AppenderTableModel(bufferSize);
  tableAppender.setModel(model);
  int runLength=Integer.parseInt(args[1]);
  JScrollPane sp=new JScrollPane(tableAppender);
  sp.setPreferredSize(new Dimension(250,80));
  container.setLayout(new BoxLayout(container,BoxLayout.X_AXIS));
  container.add(sp);
  JButton button=new JButton("ADD");
  container.add(button);
  button.addActionListener(new JTableAddAction(tableAppender));
  frame.setSize(new Dimension(500,300));
  frame.setVisible(true);
  long before=System.currentTimeMillis();
  int i=0;
  while (i++ < runLength) {
    LoggingEvent event=new LoggingEvent("x",logger,Level.ERROR,"Message " + i,null);
    tableAppender.doAppend(event);
  }
  long after=System.currentTimeMillis();
  long totalTime=(after - before);
  System.out.println("Total time :" + totalTime + " milliseconds for "+ "runLength insertions.");
  System.out.println("Average time per insertion :" + (totalTime * 1000 / runLength) + " micro-seconds.");
}
 

Example 29

From project e4-rendering, under directory /com.toedter.e4.ui.workbench.renderers.swing/src/com/toedter/e4/ui/workbench/renderers/swing/.

Source file: WorkbenchWindowRenderer.java

  31 
vote

@Override public void doLayout(MElementContainer<?> element){
  if ((MUIElement)element instanceof MWindow) {
    JFrame jFrame=(JFrame)element.getWidget();
    PresentationEngine engine=(PresentationEngine)context.get(IPresentationEngine.class.getName());
    MWindow window=(MWindow)((MUIElement)element);
    Container root=(Container)jFrame.getContentPane();
    if (window instanceof MTrimmedWindow) {
      MTrimmedWindow tWindow=(MTrimmedWindow)window;
      for (      MTrimBar trim : tWindow.getTrimBars()) {
        Component n=(Component)trim.getWidget();
        if (n != null) {
          boolean isVisible=trim.isVisible();
          if (!isVisible) {
            root.remove(n);
          }
 else {
switch (trim.getSide()) {
case BOTTOM:
              root.add(n,BorderLayout.SOUTH);
            break;
case LEFT:
          root.add(n,BorderLayout.WEST);
        break;
case RIGHT:
      root.add(n,BorderLayout.EAST);
    break;
case TOP:
  root.add(n,BorderLayout.NORTH);
break;
}
}
}
}
}
jFrame.invalidate();
jFrame.doLayout();
jFrame.setVisible(true);
}
}
 

Example 30

From project encog-java-core, under directory /src/main/java/org/encog/platformspecific/j2se/.

Source file: TrainingDialog.java

  31 
vote

/** 
 * Construct the training dialog.
 */
public TrainingDialog(){
  this.setSize(320,100);
  setTitle("Training");
  final Container content=getContentPane();
  content.setLayout(new BorderLayout());
  final JPanel statsPanel=new JPanel();
  statsPanel.setLayout(new GridLayout(3,2));
  statsPanel.add(new JLabel("Current Error:"));
  statsPanel.add(this.labelError=new JLabel("Starting..."));
  statsPanel.add(new JLabel("Iterations:"));
  statsPanel.add(this.labelIterations=new JLabel(""));
  statsPanel.add(new JLabel("Training Time:"));
  statsPanel.add(this.labelTime=new JLabel(""));
  content.add(this.buttonStop=new JButton("Stop"),BorderLayout.SOUTH);
  content.add(statsPanel,BorderLayout.CENTER);
  this.buttonStop.addActionListener(this);
}
 

Example 31

From project encog-java-examples, under directory /src/main/java/org/encog/examples/gui/elementary/.

Source file: ElementaryExample.java

  31 
vote

public ElementaryExample(){
  setSize(500,500);
  setTitle("Elementary CA");
  Container c=getContentPane();
  c.setLayout(new BorderLayout());
  JPanel buttonPanel=new JPanel();
  buttonPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
  c.add(buttonPanel,BorderLayout.NORTH);
  c.add(this.status=new JLabel(),BorderLayout.SOUTH);
  buttonPanel.add(new JLabel("Rule:"));
  buttonPanel.add(this.ruleText=new JTextField("110"));
  buttonPanel.add(new JLabel("Size:"));
  buttonPanel.add(this.sizeText=new JTextField("500"));
  buttonPanel.add(generateButton=new JButton("Generate"));
  this.worldArea=new DisplayPanel();
  this.scroll=new JScrollPane(this.worldArea);
  c.add(this.scroll,BorderLayout.CENTER);
  generateButton.addActionListener(this);
  String[] test={"1x","2x","3x","5x","10x"};
  this.zoomCombo=new JComboBox(test);
  buttonPanel.add(new JLabel("Zoom:"));
  buttonPanel.add(zoomCombo);
  zoomCombo.addItemListener(this);
  this.addWindowListener(this);
}
 

Example 32

From project formic, under directory /src/java/org/formic/wizard/impl/gui/.

Source file: GuiWizardStep.java

  31 
vote

/** 
 * {@inheritDoc}
 * @see PanelWizardStep#setBusy(boolean)
 */
public void setBusy(boolean busy){
  super.setBusy(busy);
  Container grandparent=getParent().getParent().getParent();
  Container parent=getParent().getParent();
  if (step.isBusyAnimated()) {
    if (busy) {
      if (infiniteProgress == null) {
        infiniteProgress=new SingleComponentInfiniteProgress(false);
        infiniteProgress.setFont(new Font(null,Font.BOLD,15));
        grandparent.remove(parent);
        MGlassPaneContainer container=new MGlassPaneContainer(parent);
        grandparent.add(container,BorderLayout.CENTER);
        container.setGlassPane(infiniteProgress);
        String busyText=Installer.getString(step.getName() + ".busy");
        infiniteProgress.setText(busyText != null ? busyText : BUSY_TEXT);
      }
      infiniteProgress.setVisible(true);
    }
 else {
      if (infiniteProgress != null) {
        infiniteProgress.setVisible(false);
      }
    }
  }
}
 

Example 33

From project FScape, under directory /src/main/java/de/sciss/fscape/gui/.

Source file: OpConnector.java

  31 
vote

/** 
 * Zeichnet den Pfeil zwischen den zum Connector gehoerenden Icons; nimmt dazu getParent().getGraphics();
 * @param mode	false, um statt mit schwarz zu zeichnen, den Pfeil zu loeschen
 */
public void drawArrow(boolean mode){
  final Container c=getParent();
  Graphics2D g;
  Point tempP;
  if (c != null) {
    g=(Graphics2D)c.getGraphics();
    if (g != null) {
      g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
      g.setColor(mode ? Color.black : c.getBackground());
      if (isVisible()) {
        g.drawLine(srcP.x,srcP.y,thisP.x,thisP.y);
        drawArrow(g,thisP.x,thisP.y,destP.x,destP.y,mode);
      }
 else {
        drawArrow(g,srcP.x,srcP.y,destP.x,destP.y,mode);
      }
      g.dispose();
    }
    g=(Graphics2D)srcIcon.getGraphics();
    if (g != null) {
      g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
      tempP=isVisible() ? thisP : destP;
      g.setColor(mode ? Color.black : c.getBackground());
      g.drawLine(srcP.x - srcLoc.x,srcP.y - srcLoc.y,tempP.x - srcLoc.x,tempP.y - srcLoc.y);
      g.dispose();
    }
    g=(Graphics2D)destIcon.getGraphics();
    if (g != null) {
      g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
      tempP=isVisible() ? thisP : srcP;
      g.setColor(mode ? Color.black : c.getBackground());
      drawArrow(g,tempP.x - destLoc.x,tempP.y - destLoc.y,destP.x - destLoc.x,destP.y - destLoc.y,mode);
      g.dispose();
      if (!mode)       destIcon.repaint();
    }
  }
}
 

Example 34

From project GenericKnimeNodes, under directory /com.genericworkflownodes.knime.base_plugin/src/com/genericworkflownodes/knime/generic_node/dialogs/param_dialog/itemlist/.

Source file: ItemListFillerDialog.java

  31 
vote

public ItemListFillerDialog(ItemListFillerDialogModel mdl){
  super();
  this.setTitle("List editor");
  if (mdl.hasRestrictedValues()) {
    choices=mdl.getRestrictedValues();
  }
  Container pane=this.getContentPane();
  pane.setLayout(new GridBagLayout());
  this.model=mdl;
  list=new JList(model);
  list.setFixedCellWidth(200);
  JScrollPane listScrollPane=new JScrollPane(list);
  UIHelper.addComponent(pane,listScrollPane,0,0,1,1,GridBagConstraints.CENTER,GridBagConstraints.BOTH,2,2);
  addButton=new JButton("Add");
  addButton.addActionListener(this);
  delButton=new JButton("Del");
  delButton.addActionListener(this);
  okButton=new JButton("OK");
  okButton.addActionListener(this);
  makeButtonWidthEqual(addButton,delButton,okButton);
  Box box=Box.createVerticalBox();
  box.add(addButton);
  box.add(delButton);
  box.add(okButton);
  box.add(Box.createVerticalGlue());
  UIHelper.addComponent(pane,box,1,0,1,1,GridBagConstraints.CENTER,GridBagConstraints.BOTH,0,0);
  setDefaultCloseOperation(DISPOSE_ON_CLOSE);
  setModalityType(ModalityType.APPLICATION_MODAL);
  setSize(300,200);
  pack();
}
 

Example 35

From project huiswerk, under directory /print/zxing-1.6/javase/src/com/google/zxing/client/j2se/.

Source file: GUIRunner.java

  31 
vote

private GUIRunner(){
  imageLabel=new JLabel();
  textArea=new JTextArea();
  textArea.setEditable(false);
  textArea.setMaximumSize(new Dimension(400,200));
  Container panel=new JPanel();
  panel.setLayout(new FlowLayout());
  panel.add(imageLabel);
  panel.add(textArea);
  setTitle("ZXing");
  setSize(400,400);
  setDefaultCloseOperation(EXIT_ON_CLOSE);
  setContentPane(panel);
  setLocationRelativeTo(null);
}
 

Example 36

From project jASM_16, under directory /src/main/java/de/codesourcery/jasm16/utils/.

Source file: ASTInspector.java

  31 
vote

public void centerCurrentLineInScrollPane(){
  final Container container=SwingUtilities.getAncestorOfClass(JViewport.class,editorPane);
  if (container == null) {
    return;
  }
  try {
    final Rectangle r=editorPane.modelToView(editorPane.getCaretPosition());
    final JViewport viewport=(JViewport)container;
    final int extentHeight=viewport.getExtentSize().height;
    final int viewHeight=viewport.getViewSize().height;
    int y=Math.max(0,r.y - (extentHeight / 2));
    y=Math.min(y,viewHeight - extentHeight);
    viewport.setViewPosition(new Point(0,y));
  }
 catch (  BadLocationException ble) {
  }
}
 

Example 37

From project jCAE, under directory /jcae/mesh-algos/src/org/jcae/netbeans/viewer3d/.

Source file: ViewCameraList.java

  31 
vote

private Container createButtons(){
  JPanel panel=new JPanel();
  panel.setLayout(new GridLayout(2,1));
  JButton button=new JButton();
  button.setToolTipText("Remove");
  button.setIcon(removeIcon);
  button.addActionListener(new ActionListener(){
    public void actionPerformed(    ActionEvent e){
      removePerformed();
    }
  }
);
  panel.add(button);
  goButton=new JButton();
  goButton.setToolTipText("Go");
  goButton.addActionListener(new ActionListener(){
    public void actionPerformed(    ActionEvent e){
      goPerformed();
    }
  }
);
  goButton.setIcon(goIcon);
  panel.add(goButton);
  Container buttonContainer=javax.swing.Box.createVerticalBox();
  buttonContainer.add(javax.swing.Box.createVerticalStrut(10));
  buttonContainer.add(javax.swing.Box.createVerticalGlue());
  buttonContainer.add(panel);
  buttonContainer.add(javax.swing.Box.createVerticalStrut(10));
  return buttonContainer;
}
 

Example 38

From project JGit, under directory /org.spearce.jgit/src/org/spearce/jgit/transport/.

Source file: DefaultSshSessionFactory.java

  31 
vote

public String[] promptKeyboardInteractive(final String destination,final String name,final String instruction,final String[] prompt,final boolean[] echo){
  final GridBagConstraints gbc=new GridBagConstraints(0,0,1,1,1,1,GridBagConstraints.NORTHWEST,GridBagConstraints.NONE,new Insets(0,0,0,0),0,0);
  final Container panel=new JPanel();
  panel.setLayout(new GridBagLayout());
  gbc.weightx=1.0;
  gbc.gridwidth=GridBagConstraints.REMAINDER;
  gbc.gridx=0;
  panel.add(new JLabel(instruction),gbc);
  gbc.gridy++;
  gbc.gridwidth=GridBagConstraints.RELATIVE;
  final JTextField[] texts=new JTextField[prompt.length];
  for (int i=0; i < prompt.length; i++) {
    gbc.fill=GridBagConstraints.NONE;
    gbc.gridx=0;
    gbc.weightx=1;
    panel.add(new JLabel(prompt[i]),gbc);
    gbc.gridx=1;
    gbc.fill=GridBagConstraints.HORIZONTAL;
    gbc.weighty=1;
    if (echo[i]) {
      texts[i]=new JTextField(20);
    }
 else {
      texts[i]=new JPasswordField(20);
    }
    panel.add(texts[i],gbc);
    gbc.gridy++;
  }
  if (JOptionPane.showConfirmDialog(null,panel,destination + ": " + name,JOptionPane.OK_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION) {
    String[] response=new String[prompt.length];
    for (int i=0; i < prompt.length; i++) {
      response[i]=texts[i].getText();
    }
    return response;
  }
  return null;
}
 

Example 39

From project log4j, under directory /contribs/CekiGulcu/.

Source file: AppenderTable.java

  31 
vote

static public void main(String[] args){
  if (args.length != 2) {
    System.err.println("Usage: java AppenderTable bufferSize runLength\n" + "  where bufferSize is the size of the cyclic buffer in the TableModel\n" + "  and runLength is the total number of elements to add to the table in\n"+ "  this test run.");
    return;
  }
  JFrame frame=new JFrame("JTableAppennder test");
  Container container=frame.getContentPane();
  AppenderTable tableAppender=new AppenderTable();
  int bufferSize=Integer.parseInt(args[0]);
  AppenderTableModel model=new AppenderTableModel(bufferSize);
  tableAppender.setModel(model);
  int runLength=Integer.parseInt(args[1]);
  JScrollPane sp=new JScrollPane(tableAppender);
  sp.setPreferredSize(new Dimension(250,80));
  container.setLayout(new BoxLayout(container,BoxLayout.X_AXIS));
  container.add(sp);
  JButton button=new JButton("ADD");
  container.add(button);
  button.addActionListener(new JTableAddAction(tableAppender));
  frame.setSize(new Dimension(500,300));
  frame.setVisible(true);
  long before=System.currentTimeMillis();
  int i=0;
  while (i++ < runLength) {
    LoggingEvent event=new LoggingEvent("x",logger,Level.ERROR,"Message " + i,null);
    tableAppender.doAppend(event);
  }
  long after=System.currentTimeMillis();
  long totalTime=(after - before);
  System.out.println("Total time :" + totalTime + " milliseconds for "+ "runLength insertions.");
  System.out.println("Average time per insertion :" + (totalTime * 1000 / runLength) + " micro-seconds.");
}
 

Example 40

From project log4jna, under directory /thirdparty/log4j/contribs/CekiGulcu/.

Source file: AppenderTable.java

  31 
vote

static public void main(String[] args){
  if (args.length != 2) {
    System.err.println("Usage: java AppenderTable bufferSize runLength\n" + "  where bufferSize is the size of the cyclic buffer in the TableModel\n" + "  and runLength is the total number of elements to add to the table in\n"+ "  this test run.");
    return;
  }
  JFrame frame=new JFrame("JTableAppennder test");
  Container container=frame.getContentPane();
  AppenderTable tableAppender=new AppenderTable();
  int bufferSize=Integer.parseInt(args[0]);
  AppenderTableModel model=new AppenderTableModel(bufferSize);
  tableAppender.setModel(model);
  int runLength=Integer.parseInt(args[1]);
  JScrollPane sp=new JScrollPane(tableAppender);
  sp.setPreferredSize(new Dimension(250,80));
  container.setLayout(new BoxLayout(container,BoxLayout.X_AXIS));
  container.add(sp);
  JButton button=new JButton("ADD");
  container.add(button);
  button.addActionListener(new JTableAddAction(tableAppender));
  frame.setSize(new Dimension(500,300));
  frame.setVisible(true);
  long before=System.currentTimeMillis();
  int i=0;
  while (i++ < runLength) {
    LoggingEvent event=new LoggingEvent("x",logger,Level.ERROR,"Message " + i,null);
    tableAppender.doAppend(event);
  }
  long after=System.currentTimeMillis();
  long totalTime=(after - before);
  System.out.println("Total time :" + totalTime + " milliseconds for "+ "runLength insertions.");
  System.out.println("Average time per insertion :" + (totalTime * 1000 / runLength) + " micro-seconds.");
}
 

Example 41

From project medsavant, under directory /medsavant/MedSavantClient/src/org/ut/biolab/medsavant/view/dialog/.

Source file: IndeterminateProgressDialog.java

  31 
vote

public IndeterminateProgressDialog(String title,String message){
  super(DialogUtils.getFrontWindow(),title,Dialog.ModalityType.APPLICATION_MODAL);
  setResizable(false);
  Container p=getContentPane();
  p.setLayout(new GridBagLayout());
  messageLabel=new JLabel(message);
  JProgressBar bar=new JProgressBar();
  bar.setIndeterminate(true);
  GridBagConstraints gbc=new GridBagConstraints();
  gbc.gridwidth=GridBagConstraints.REMAINDER;
  gbc.fill=GridBagConstraints.HORIZONTAL;
  gbc.insets=new Insets(10,60,10,60);
  p.add(messageLabel,gbc);
  gbc.insets=new Insets(10,60,30,60);
  p.add(bar,gbc);
  pack();
  setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
  setLocationRelativeTo(getParent());
}
 

Example 42

From project Mobile-Tour-Guide, under directory /zxing-2.0/javase/src/com/google/zxing/client/j2se/.

Source file: GUIRunner.java

  31 
vote

private GUIRunner(){
  imageLabel=new JLabel();
  textArea=new JTextArea();
  textArea.setEditable(false);
  textArea.setMaximumSize(new Dimension(400,200));
  Container panel=new JPanel();
  panel.setLayout(new FlowLayout());
  panel.add(imageLabel);
  panel.add(textArea);
  setTitle("ZXing");
  setSize(400,400);
  setDefaultCloseOperation(EXIT_ON_CLOSE);
  setContentPane(panel);
  setLocationRelativeTo(null);
}
 

Example 43

From project multibit, under directory /src/main/java/org/multibit/viewsystem/swing/.

Source file: MultiBitFrame.java

  31 
vote

/** 
 * recreate all views
 */
public void recreateAllViews(boolean clearCache,boolean initUI){
  if (View.SEND_BITCOIN_CONFIRM_VIEW == currentView) {
    return;
  }
  if (currentView != 0) {
    navigateAwayFromView(currentView,View.TRANSACTIONS_VIEW,ViewSystem.NEW_VIEW_IS_PARENT_OF_PREVIOUS);
  }
  if (initUI) {
    this.localiser=controller.getLocaliser();
    Container contentPane=getContentPane();
    contentPane.removeAll();
    initUI();
    applyComponentOrientation(ComponentOrientation.getOrientation(controller.getLocaliser().getLocale()));
  }
  updateOnlineStatusText();
  updateHeader();
  setTitle(localiser.getString("multiBitFrame.title"));
  invalidate();
  validate();
  repaint();
  View yourWalletsView=null;
  if (!clearCache && viewFactory != null) {
    yourWalletsView=viewFactory.getView(View.YOUR_WALLETS_VIEW);
  }
  viewFactory=new ViewFactory(controller,this);
  if (!clearCache && yourWalletsView != null) {
    viewFactory.addView(View.YOUR_WALLETS_VIEW,yourWalletsView);
  }
}
 

Example 44

From project narya, under directory /core/src/main/java/com/threerings/crowd/client/.

Source file: PlaceViewUtil.java

  31 
vote

/** 
 * Dispatches a call to  {@link PlaceView#willEnterPlace} to all UI elements in the hierarchyrooted at the component provided via the <code>root</code> parameter.
 * @param root the component at which to start traversing the UI hierarchy.
 * @param plobj the place object that is about to be entered.
 */
public static void dispatchWillEnterPlace(Object root,PlaceObject plobj){
  if (root instanceof PlaceView) {
    try {
      ((PlaceView)root).willEnterPlace(plobj);
    }
 catch (    Exception e) {
      log.warning("Component choked on willEnterPlace()","component",root,"plobj",plobj,e);
    }
  }
  if (root instanceof Container) {
    Container cont=(Container)root;
    int ccount=cont.getComponentCount();
    for (int ii=0; ii < ccount; ii++) {
      dispatchWillEnterPlace(cont.getComponent(ii),plobj);
    }
  }
}
 

Example 45

From project netifera, under directory /platform/com.netifera.platform.ui.visualizations/com.netifera.platform.ui.graphs/src/com/netifera/platform/ui/graphs/utils/.

Source file: AWTEmbeddedControl.java

  31 
vote

public AWTEmbeddedControl(Composite parent){
  super(parent,SWT.NO_BACKGROUND | SWT.BORDER | SWT.EMBEDDED);
  Frame locationFrame=SWT_AWT.new_Frame(this);
  Panel panel=new Panel(new BorderLayout()){
    private static final long serialVersionUID=3447368094074143729L;
    public void update(    java.awt.Graphics g){
      paint(g);
    }
  }
;
  locationFrame.add(panel);
  JRootPane root=new JRootPane();
  panel.add(root);
  Container contentPane=root.getContentPane();
  RGB backgroundColor=getBackground().getRGB();
  locationFrame.setBackground(new java.awt.Color(backgroundColor.red,backgroundColor.green,backgroundColor.blue));
  locationFrame.setIgnoreRepaint(false);
  locationFrame.setVisible(true);
  embeddee=createAWTComponent();
  contentPane.add(embeddee);
}
 

Example 46

From project Openbravo-POS-iPhone-App, under directory /UnicentaPOS/src-pos/com/openbravo/pos/util/.

Source file: JRViewer300.java

  31 
vote

void pnlLinksMouseDragged(java.awt.event.MouseEvent evt){
  Container container=pnlInScroll.getParent();
  if (container instanceof JViewport) {
    JViewport viewport=(JViewport)container;
    Point point=viewport.getViewPosition();
    int newX=point.x - (evt.getX() - downX);
    int newY=point.y - (evt.getY() - downY);
    int maxX=pnlInScroll.getWidth() - viewport.getWidth();
    int maxY=pnlInScroll.getHeight() - viewport.getHeight();
    if (newX < 0) {
      newX=0;
    }
    if (newX > maxX) {
      newX=maxX;
    }
    if (newY < 0) {
      newY=0;
    }
    if (newY > maxY) {
      newY=maxY;
    }
    viewport.setViewPosition(new Point(newX,newY));
  }
}
 

Example 47

From project OpenSettlers, under directory /src/java/soc/client/.

Source file: PlayerClient.java

  31 
vote

/** 
 * handle the "join authorization" message
 * @param mes  the message
 */
protected void handleJOINAUTH(JoinAuth mes){
  nick.setEditable(false);
  pass.setText("");
  pass.setEditable(false);
  gotPassword=true;
  if (!hasJoinedServer) {
    Container c=getParent();
    if ((c != null) && (c instanceof Frame)) {
      Frame fr=(Frame)c;
      fr.setTitle(fr.getTitle() + " [" + nick.getText()+ "]");
    }
    hasJoinedServer=true;
  }
  ChannelFrame cf=new ChannelFrame(mes.getChannel(),this);
  cf.setVisible(true);
  channels.put(mes.getChannel(),cf);
}
 

Example 48

From project OpenTripPlanner, under directory /opentripplanner-gui/src/main/java/org/opentripplanner/gui/.

Source file: RouteDialog.java

  31 
vote

public RouteDialog(JFrame owner,String initialFrom){
  super(owner,true);
  fromField=new JTextField(initialFrom,30);
  toField=new JTextField(30);
  goButton=new JButton("Go");
  Container pane=getContentPane();
  pane.setLayout(new BoxLayout(pane,BoxLayout.PAGE_AXIS));
  pane.add(new JLabel("From"));
  pane.add(fromField);
  pane.add(new JLabel("To"));
  pane.add(toField);
  pane.add(goButton);
  pack();
  final RouteDialog outer=this;
  goButton.addActionListener(new ActionListener(){
    public void actionPerformed(    ActionEvent e){
      from=fromField.getText().trim();
      to=toField.getText().trim();
      outer.setVisible(false);
    }
  }
);
  setVisible(true);
}
 

Example 49

From project Pipeline, under directory /src/gui/.

Source file: PipelineWindow.java

  31 
vote

public PipelineWindow(){
  super("Pipeliner");
  try {
    String plaf=UIManager.getSystemLookAndFeelClassName();
    String gtkLookAndFeel="com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
    if (plaf.contains("metal")) {
      UIManager.setLookAndFeel(gtkLookAndFeel);
    }
    UIManager.setLookAndFeel(plaf);
  }
 catch (  Exception e) {
    System.err.println("Could not set look and feel, exception : " + e.toString());
  }
  this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  Container contentPane=this.getContentPane();
  contentPane.setLayout(new BorderLayout());
  AnalysisBox analyses=new AnalysisBox(this);
  centerScrollPane=new JScrollPane(analyses);
  centerScrollPane.setViewportBorder(BorderFactory.createEmptyBorder());
  centerScrollPane.setBorder(BorderFactory.createEmptyBorder(6,6,6,6));
  contentPane.add(centerScrollPane,BorderLayout.CENTER);
  JPanel bottomPanel=new JPanel();
  bottomPanel.setLayout(new BorderLayout());
  bottomPanel.add(new JSeparator(JSeparator.HORIZONTAL));
  contentPane.add(bottomPanel,BorderLayout.SOUTH);
  this.setSize(500,500);
  this.setPreferredSize(new Dimension(500,400));
  pack();
  setLocationRelativeTo(null);
}
 

Example 50

From project pos_1, under directory /src-pos/com/openbravo/pos/util/.

Source file: JRViewer300.java

  31 
vote

void pnlLinksMouseDragged(java.awt.event.MouseEvent evt){
  Container container=pnlInScroll.getParent();
  if (container instanceof JViewport) {
    JViewport viewport=(JViewport)container;
    Point point=viewport.getViewPosition();
    int newX=point.x - (evt.getX() - downX);
    int newY=point.y - (evt.getY() - downY);
    int maxX=pnlInScroll.getWidth() - viewport.getWidth();
    int maxY=pnlInScroll.getHeight() - viewport.getHeight();
    if (newX < 0) {
      newX=0;
    }
    if (newX > maxX) {
      newX=maxX;
    }
    if (newY < 0) {
      newY=0;
    }
    if (newY > maxY) {
      newY=maxY;
    }
    viewport.setViewPosition(new Point(newX,newY));
  }
}
 

Example 51

From project Possom, under directory /data-model-javabean-impl/src/main/java/no/sesat/search/datamodel/.

Source file: BeanContextSupport.java

  30 
vote

/** 
 * <p> This method is typically called from the environment in order to determine if the implementor "needs" a GUI. </p> <p> The algorithm used herein tests the BeanContextPeer, and its current children to determine if they are either Containers, Components, or if they implement Visibility and return needsGui() == true. </p>
 * @return <tt>true</tt> if the implementor needs a GUI
 */
public synchronized boolean needsGui(){
  BeanContext bc=getBeanContextPeer();
  if (bc != this) {
    if (bc instanceof Visibility)     return ((Visibility)bc).needsGui();
    if (bc instanceof Container || bc instanceof Component)     return true;
  }
synchronized (children) {
    for (Iterator i=children.keySet().iterator(); i.hasNext(); ) {
      Object c=i.next();
      try {
        return ((Visibility)c).needsGui();
      }
 catch (      ClassCastException cce) {
      }
      if (c instanceof Container || c instanceof Component)       return true;
    }
  }
  return false;
}
 

Example 52

From project addis, under directory /application/src/main/java/org/drugis/addis/gui/.

Source file: Main.java

  29 
vote

public static void bindPrintScreen(Container container){
  final JComponent content=(JComponent)container;
  content.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(PRINT_SCREEN),"printWindow");
  content.getActionMap().put("printWindow",new AbstractAction("printWindow"){
    public void actionPerformed(    ActionEvent evt){
      try {
        ImageExporter.writeImage(content,content,content.getWidth(),content.getHeight());
      }
 catch (      Exception e) {
        throw new RuntimeException("Error writing image: " + e.getMessage(),e);
      }
    }
  }
);
}
 

Example 53

From project beanmill_1, under directory /src/main/java/de/cismet/beanmill/.

Source file: NetbeansPanel.java

  29 
vote

/** 
 * DOCUMENT ME!
 * @param c  DOCUMENT ME!
 * @return  DOCUMENT ME!
 */
private Dialog getParentDialog(final Container c){
  if (c == null) {
    return null;
  }
 else   if (c instanceof Dialog) {
    return (Dialog)c;
  }
 else {
    return getParentDialog(c.getParent());
  }
}
 

Example 54

From project Cinch, under directory /example/com/palantir/ptoss/cinch/example/.

Source file: Examples.java

  29 
vote

public static JFrame getFrameFor(String title,Container container){
  JFrame frame=new JFrame(title);
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.setLocation(100,100);
  frame.setSize(400,600);
  frame.setContentPane(container);
  return frame;
}
 

Example 55

From project Clotho-Core, under directory /ClothoApps/CollectionViewTool/src/org/clothocad/tool/collectionview/.

Source file: GlassMessage.java

  29 
vote

/** 
 * Creates a new instance of SmoothAnimation 
 */
public GlassMessage(String msg,String secondmsg,int wide,int high,Container cont,Color bkg,ActionListener al){
  imageW=wide;
  imageH=high;
  container=cont;
  message=msg;
  bkgColor=bkg;
  actionOnClick=al;
  message2=secondmsg;
  addMouseListener(new MouseAdapter(){
    @Override public void mousePressed(    MouseEvent e){
      if (closeCircle == null) {
        return;
      }
      if (closeCircle.getBounds().contains(e.getPoint())) {
        dumpit();
      }
 else {
        if (actionOnClick != null) {
          actionOnClick.actionPerformed(null);
        }
      }
    }
  }
);
  startTimer(currentResolution);
}
 

Example 56

From project dawn-isencia, under directory /com.isencia.passerelle.commons/src/main/java/com/isencia/util/swing/layout/.

Source file: AbsoluteLayout.java

  29 
vote

/** 
 * Calculates the preferred dimension for the specified panel given the be.isencia.util.swing.components in the specified parent container.
 * @param parent the component to be laid out
 * @see #minimumLayoutSize
 */
public Dimension preferredLayoutSize(Container parent){
  int maxWidth=0;
  int maxHeight=0;
  for (Enumeration<Component> e=constraints.keys(); e.hasMoreElements(); ) {
    Component comp=e.nextElement();
    AbsoluteConstraints ac=constraints.get(comp);
    Dimension size=comp.getPreferredSize();
    int width=ac.getWidth();
    if (width == -1)     width=size.width;
    int height=ac.getHeight();
    if (height == -1)     height=size.height;
    if (ac.x + width > maxWidth)     maxWidth=ac.x + width;
    if (ac.y + height > maxHeight)     maxHeight=ac.y + height;
  }
  return new Dimension(maxWidth,maxHeight);
}
 

Example 57

From project drools-planner, under directory /drools-planner-examples/src/main/java/org/drools/planner/examples/app/.

Source file: DroolsPlannerExamplesApp.java

  29 
vote

private Container createContentPane(){
  JPanel contentPane=new JPanel(new BorderLayout(10,10));
  contentPane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
  JLabel titleLabel=new JLabel("Which example do you want to see?",JLabel.CENTER);
  titleLabel.setFont(titleLabel.getFont().deriveFont(20.0f));
  contentPane.add(titleLabel,BorderLayout.NORTH);
  JScrollPane examplesScrollPane=new JScrollPane(createExamplesPanel());
  examplesScrollPane.getHorizontalScrollBar().setUnitIncrement(20);
  examplesScrollPane.getVerticalScrollBar().setUnitIncrement(20);
  contentPane.add(examplesScrollPane,BorderLayout.CENTER);
  contentPane.add(createDescriptionPanel(),BorderLayout.SOUTH);
  return contentPane;
}
 

Example 58

From project droolsjbpm-integration, under directory /droolsjbpm-integration-examples/src/main/java/org/drools/examples/.

Source file: DroolsJbpmIntegrationExamplesApp.java

  29 
vote

private Container createContentPane(){
  JPanel contentPane=new JPanel(new GridLayout(0,1));
  contentPane.add(new JLabel("Which GUI example do you want to see?"));
  contentPane.add(new JButton(new AbstractAction("ConwayGUI"){
    public void actionPerformed(    ActionEvent e){
      new ConwayRuleFlowGroupRun().init(false);
    }
  }
));
  contentPane.add(new JButton(new AbstractAction("BrokerExample (Fusion CEP)"){
    public void actionPerformed(    ActionEvent e){
      new BrokerExample().init(false);
    }
  }
));
  contentPane.add(new JLabel("Which output example do you want to see?"));
  contentPane.add(new JButton(new AbstractAction("NumberGuessExample"){
    public void actionPerformed(    ActionEvent e){
      NumberGuessExample.main(new String[0]);
    }
  }
));
  return contentPane;
}
 

Example 59

From project Gmote, under directory /gmoteserver/src/org/gmote/server/.

Source file: GmoteHttpServer.java

  29 
vote

private void sendImage(File originalImagePath,BufferedOutputStream dataOut) throws InterruptedException, ImageFormatException, IOException {
  LOGGER.info("Converting image to smaller scale");
  Image image=Toolkit.getDefaultToolkit().getImage(originalImagePath.getAbsolutePath());
  MediaTracker mediaTracker=new MediaTracker(new Container());
  mediaTracker.addImage(image,0);
  mediaTracker.waitForID(0);
  int imageWidth=image.getWidth(null);
  int imageHeight=image.getHeight(null);
  int thumbWidth=imageWidth;
  int thumbHeight=imageHeight;
  int MAX_SIZE=500;
  if (imageWidth > MAX_SIZE || imageHeight > MAX_SIZE) {
    double imageRatio=(double)imageWidth / (double)imageHeight;
    if (imageWidth > imageHeight) {
      thumbWidth=MAX_SIZE;
      thumbHeight=(int)(thumbWidth / imageRatio);
    }
 else {
      thumbHeight=MAX_SIZE;
      thumbWidth=(int)(thumbHeight * imageRatio);
    }
  }
  BufferedImage thumbImage;
  thumbImage=new BufferedImage(thumbWidth,thumbHeight,BufferedImage.TYPE_INT_RGB);
  Graphics2D graphics2D=thumbImage.createGraphics();
  graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION,RenderingHints.VALUE_INTERPOLATION_BILINEAR);
  graphics2D.drawImage(image,0,0,thumbWidth,thumbHeight,null);
  if (PlatformUtil.isLinux()) {
    ImageIO.write(thumbImage,"JPEG",dataOut);
  }
 else {
    JPEGImageEncoder encoder=JPEGCodec.createJPEGEncoder(dataOut);
    JPEGEncodeParam param=encoder.getDefaultJPEGEncodeParam(thumbImage);
    float quality=80;
    param.setQuality(quality / 100.0f,false);
    encoder.encode(thumbImage,param);
  }
  dataOut.close();
  LOGGER.info("Done sending image");
}
 

Example 60

From project gridland, under directory /src/org/grid/server/.

Source file: StackLayout.java

  29 
vote

/** 
 * Places the components.
 * @see LayoutManager#layoutContainer(Container)
 */
public void layoutContainer(Container arg0){
  Dimension base=arg0.getSize();
  Insets insets=arg0.getInsets();
  base.width-=insets.left + insets.right;
  base.height-=insets.top + insets.bottom;
switch (orientation) {
case HORIZONTAL:
{
      int offset=hPadding + insets.left;
      base.height-=2 * vPadding;
      for (int i=0; i < arg0.getComponentCount(); i++) {
        Component c=arg0.getComponent(i);
        if (!c.isVisible())         continue;
        Dimension d=c.getPreferredSize();
        c.setBounds(offset,vPadding + insets.top,d.width,align ? base.height : Math.min(d.height,base.height));
        offset+=d.width + hPadding;
      }
      break;
    }
case VERTICAL:
{
    int offset=vPadding + insets.top;
    base.width-=2 * hPadding;
    for (int i=0; i < arg0.getComponentCount(); i++) {
      Component c=arg0.getComponent(i);
      if (!c.isVisible())       continue;
      Dimension d=c.getPreferredSize();
      c.setBounds(hPadding + insets.left,offset,align ? base.width : Math.min(d.width,base.width),d.height);
      offset+=d.height + vPadding;
    }
    break;
  }
}
}
 

Example 61

From project gs-core, under directory /src/org/graphstream/ui/swingViewer/.

Source file: GraphRendererBase.java

  29 
vote

public void open(GraphicGraph graph,Container renderingSurface){
  if (this.graph != null)   throw new RuntimeException("renderer already open, cannot open twice");
  this.graph=graph;
  this.renderingSurface=renderingSurface;
  this.graph.getStyleGroups().addListener(this);
}
 

Example 62

From project ib-ruby, under directory /misc/IBController 2-9-0/src/ibcontroller/.

Source file: Utils.java

  29 
vote

/** 
 * Traverse a container hierarchy and returns the button with the given text
 */
static JButton findButton(Container container,String text){
  Component[] components=container.getComponents();
  for (  Component component : components) {
    if (component instanceof JButton) {
      JButton button=(JButton)component;
      if (button.getText().equals(text)) {
        return button;
      }
    }
 else     if (component instanceof Container) {
      JButton button=findButton((Container)component,text);
      if (button != null) {
        return button;
      }
    }
  }
  return null;
}
 

Example 63

From project JDave, under directory /jdave-jemmy/src/java/jdave/jemmy/.

Source file: JLabelContainment.java

  29 
vote

public String error(Container container){
  List<JLabel> labels=findLabels(container);
  if (labels.isEmpty()) {
    return "Expected label with text \"" + expected + "\", but there are no labels in container.";
  }
  return "Expected label with text \"" + expected + "\", but container has only the following labels: "+ format(labels)+ ".";
}
 

Example 64

From project jsmaa, under directory /main/src/main/java/fi/smaa/jsmaa/gui/.

Source file: SMAA2GUIFactory.java

  29 
vote

private void addUtilityAddItemsToMenu(Container item){
  JMenuItem cardCrit=createAddScaleCriterionItem();
  JMenuItem ordCrit=createAddOrdinalCriterionItem();
  item.add(cardCrit);
  item.add(ordCrit);
}
 

Example 65

From project jupload, under directory /src/wjhk/jupload2/gui/.

Source file: JUploadPanel.java

  29 
vote

/** 
 * Standard constructor.
 * @param containerParam The container, where all GUI elements are to becreated.
 * @param logWindow The log window that should already have been created.This allows putting text into it, before the effective creation of the layout.
 * @param uploadPolicyParam The current UploadPolicy. Null if a new one mustbe created.
 * @throws Exception 
 * @see UploadPolicyFactory#getUploadPolicy(wjhk.jupload2.JUploadApplet)
 */
public JUploadPanel(@SuppressWarnings("unused") Container containerParam,JUploadTextArea logWindow,UploadPolicy uploadPolicyParam) throws Exception {
  this.logWindow=logWindow;
  this.uploadPolicy=uploadPolicyParam;
  this.jUploadPopupMenu=new JUploadPopupMenu(this.uploadPolicy);
  createStandardComponents();
  logWindow.addMouseListener(this);
  this.uploadPolicy.addComponentsToJUploadPanel(this);
  dndListener=new DnDListener(this,uploadPolicy);
  new DropTarget(this,dndListener);
  new DropTarget(this.filePanel.getDropComponent(),dndListener);
  new DropTarget(this.logWindow,dndListener);
  browseButton.addMouseListener(this);
  removeAllButton.addMouseListener(this);
  removeButton.addMouseListener(this);
  stopButton.addMouseListener(this);
  uploadButton.addMouseListener(this);
  jLogWindowPane.addMouseListener(this);
  logWindow.addMouseListener(this);
  if (null != progressBar) {
    progressBar.addMouseListener(this);
  }
  statusLabel.addMouseListener(this);
  try {
    this.fileChooser=uploadPolicyParam.createFileChooser();
  }
 catch (  Exception e) {
    this.uploadPolicy.displayErr(e);
  }
}
 

Example 66

From project kabeja, under directory /blocks/ui/src/main/java/org/kabeja/ui/impl/.

Source file: ProcessingRunViewComponent.java

  29 
vote

protected void enableChildren(boolean b,Container c){
  for (int i=0; i < c.getComponentCount(); i++) {
    Component comp=c.getComponent(i);
    comp.setEnabled(b);
    if (comp instanceof Container) {
      enableChildren(b,(Container)comp);
    }
  }
}
 

Example 67

From project Maimonides, under directory /src/com/codeko/apps/maimonides/.

Source file: MaimonidesInputBlocker.java

  29 
vote

private void blockingDialogComponents(Component root,List<Component> rv){
  String rootName=root.getName();
  if ((rootName != null) && rootName.startsWith("BlockingDialog")) {
    rv.add(root);
  }
  if (root instanceof Container) {
    for (    Component child : ((Container)root).getComponents()) {
      blockingDialogComponents(child,rv);
    }
  }
}
 

Example 68

From project maple-ide, under directory /build/windows/launcher/launch4j/src/net/sf/launch4j/form/.

Source file: BasicForm.java

  29 
vote

/** 
 * Adds fill components to empty cells in the first row and first column of the grid. This ensures that the grid spacing will be the same as shown in the designer.
 * @param cols an array of column indices in the first row where fill components should be added.
 * @param rows an array of row indices in the first column where fill components should be added.
 */
void addFillComponents(Container panel,int[] cols,int[] rows){
  Dimension filler=new Dimension(10,10);
  boolean filled_cell_11=false;
  CellConstraints cc=new CellConstraints();
  if (cols.length > 0 && rows.length > 0) {
    if (cols[0] == 1 && rows[0] == 1) {
      panel.add(Box.createRigidArea(filler),cc.xy(1,1));
      filled_cell_11=true;
    }
  }
  for (int index=0; index < cols.length; index++) {
    if (cols[index] == 1 && filled_cell_11) {
      continue;
    }
    panel.add(Box.createRigidArea(filler),cc.xy(cols[index],1));
  }
  for (int index=0; index < rows.length; index++) {
    if (rows[index] == 1 && filled_cell_11) {
      continue;
    }
    panel.add(Box.createRigidArea(filler),cc.xy(1,rows[index]));
  }
}
 

Example 69

From project niravCS2103, under directory /CS2103/lib/apache-log4j-1.2.16/src/main/java/org/apache/log4j/lf5/viewer/.

Source file: LogFactor5Dialog.java

  29 
vote

protected void wrapStringOnPanel(String message,Container container){
  GridBagConstraints c=getDefaultConstraints();
  c.gridwidth=GridBagConstraints.REMAINDER;
  c.insets=new Insets(0,0,0,0);
  GridBagLayout gbLayout=(GridBagLayout)container.getLayout();
  while (message.length() > 0) {
    int newLineIndex=message.indexOf('\n');
    String line;
    if (newLineIndex >= 0) {
      line=message.substring(0,newLineIndex);
      message=message.substring(newLineIndex + 1);
    }
 else {
      line=message;
      message="";
    }
    Label label=new Label(line);
    label.setFont(DISPLAY_FONT);
    gbLayout.setConstraints(label,c);
    container.add(label);
  }
}
 

Example 70

From project oops, under directory /application/src/main/java/nl/rug/ai/mas/oops/render/.

Source file: TidyTreeLayout.java

  29 
vote

public void layoutContainer(Container parent){
  if (d_tsd == null) {
    return;
  }
  Placement<ComponentCell> p=d_tsd.getPlacement();
  for (  Map.Entry<ComponentCell,Point> e : p.entrySet()) {
    Point q=e.getValue();
    Dimension d=e.getKey().getComponent().getPreferredSize();
    e.getKey().getComponent().setBounds(q.x,q.y,d.width,d.height);
  }
}
 

Example 71

From project OpenEMRConnect, under directory /reception/src/ke/go/moh/oec/reception/gui/.

Source file: MainView.java

  29 
vote

private void clearFields(Container container){
  for (  Component component : container.getComponents()) {
    if (component instanceof Container) {
      if (component instanceof ImagePanel) {
        ((ImagePanel)component).setImage(mainViewHelper.getMissingFingerprint().getImage());
      }
 else {
        clearFields((Container)component);
      }
    }
    if (component instanceof JTextComponent) {
      ((JTextComponent)component).setText("");
    }
 else     if (component instanceof JToggleButton) {
      ((JToggleButton)component).setSelected(false);
    }
 else     if (component instanceof JDateChooser) {
      ((JDateChooser)component).setDate(new Date());
    }
 else     if (component instanceof JComboBox) {
      ((JComboBox)component).setSelectedItem(null);
    }
  }
  resetState();
}
 

Example 72

From project pegadi, under directory /storysketch/src/main/java/org/pegadi/storysketch/views/plugins/.

Source file: NTNUPhoneSearch.java

  29 
vote

private void makeLabel(Component comp,Container p,GridBagLayout gridbag,GridBagConstraints c){
  c.gridwidth=1;
  c.anchor=GridBagConstraints.EAST;
  c.insets=new Insets(3,3,3,3);
  gridbag.setConstraints(comp,c);
  p.add(comp);
}
 

Example 73

From project pomodoro4nb, under directory /src/org/matveev/pomodoro4nb/.

Source file: PomodoroMainController.java

  29 
vote

public Container createContent(){
  final JPanel content=new JPanel(new BorderLayout());
  content.add(controllers.get(TimerController.ID).createUI(),BorderLayout.NORTH);
  content.add(controllers.get(TaskController.ID).createUI(),BorderLayout.CENTER);
  return content;
}